Careful about the problem description, things to check : there are no more than 10 digits X is at the 10th position to avoid PE avoid the trailing and leading spaces and keep the internal spaces #include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; int num[15]; int main() { string str,p; while(getline(cin,str))
Month: July 2015
12748
#include <iostream> #include <cstdio> using namespace std; struct router{ int x,y,r; }; struct location{ int x,y; }; router rr[105]; location loc[12]; int main() { int t,kase=1; int a,b,c,d,e; bool f,found; cin>>t; int routers,locations; while(t–) { cin>>routers>>locations; f=0; for(int i=0;i<routers;i++) { cin>>rr[i].x>>rr[i].y>>rr[i].r; } for(int i=0;i<locations;i++) { cin>>loc[i].x>>loc[i].y; } for(int i=0;i<locations;i++) { a=loc[i].x;b=loc[i].y; found=0; for(int j=0;j<routers;j++) {
12854
#include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; int connector1[5]; int connector2[5]; int main() { bool f; while(scanf("%d",&connector1[0])!=EOF) { for(int i=1;i<5;i++) cin>>connector1[i]; for(int i=0;i<5;i++) cin>>connector2[i]; f=1; for(int i=0;i<5;i++) { if(connector1[i]+connector2[i]!=1) { f=0; break; } } if(f) cout<<"Y\n"; else cout<<"N\n"; } }
11063
This one is a shitty problem. #include <iostream> #include <cstdio> #include <cstring> using namespace std; bool arr[20000+5]; int main() { int n,a,kase=1; int prev=-1; int val[105]; bool Bseq; while(scanf ("%d", &n) != EOF) { Bseq=1; for(int i=0;i<n;i++) { cin>>val[i]; } for(int i=0;i<n-1;i++) { if(val[i]<1 || val[i]>=val[i+1]) { Bseq=0; break; } } if(Bseq) { memset(arr,0,sizeof(arr)); for(int
467
#include <iostream> #include <cstdio> #include <sstream> #include <string> #include <cstring> #include <algorithm> using namespace std; int signal[4000]; int main() { string str; int kase=1; stringstream ss; int a,b,c,mx; int arr[12]; while(getline(cin,str)) { ss.clear(); ss<<str; int k=1; int time=0; while(ss>>arr[k])k++; sort(arr+1,arr+k); memset(signal,0,sizeof(signal)); for(int i=1;i<k;i++) { for(int j=0;j<3601;) { a=arr[i]-5; b=5; c=arr[i]; while(a–)signal[j++]++; while(b–)signal[j++]=0; while(c–)signal[j++]=0; } }
507
#include <iostream> #include <cstdio> using namespace std; int arr[25000]; struct path{ int len,st,en; }; path p; int kadanesAlgo(int rd,int first) { int max_end_here=0,max_so_far=0; int begin=first,length; int finish=0,start=first; for(int i=first;i<rd;i++) { max_end_here+=arr[i]; if(max_end_here<0) { max_end_here=0; begin=i+1; } if(max_end_here>max_so_far) { max_so_far = max_end_here; start=begin; finish=i+1; length=finish-start+1; p.len=length; p.en=finish; p.st=start; } else if(max_end_here==max_so_far) { max_so_far = max_end_here; start=begin;
10196
#include <iostream> #include <string> #include <cstring> #include <cstdio> using namespace std; char board[8][8]; struct IDX{ int i,j; }; bool isCheck_knight(int I,int J,int color) { int dx[8]={1,1,-1,-1,2,2,-2,-2}; int dy[8]={2,-2,2,-2,1,-1,1,-1}; int a,b; for(int i=0;i<8;i++) { a=dx[i]+I; b=dy[i]+J; if(a>=0 && a<8 && b>=0 && b<8) { if(board[a][b]=='N' && color==0) return 1; else if(board[a][b]=='n' && color==1) return 1; }
694
#include <iostream> #include <cstdio> #define ll long long using namespace std; int check(ll num,ll limit) { ll a=num,b=limit; int cnt=0; while(a<=limit) { if(a%2) { a=(a*3+1); cnt+=1; if(a>limit) return cnt-1; } else { a/=2; cnt+=1; if(a==1) return cnt; } } return cnt; } int main() { ll num,limit; int c; int kase=1; while(cin>>num) { cin>>limit; if(num==-1
11713
#include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; int main() { int t; string st1,st2; cin>>t; while(t–) { cin>>st1; cin>>st2; if(st2.size()!=st1.size()) { cout<<"No\n"; continue; } bool f=0; for(int i=0;i<st1.size();i++) { if(st1[i]!=st2[i]) { char a=st1[i]; char b=st2[i]; if(a!='a' && a!='e' && a!='i' && a!='o' && a!='u') { f=1; } else if(b!='a' && b!='e'
455
#include <iostream> #include <cstdio> #include <string> using namespace std; string str; bool check(string p,string s) { int ll=s.size(); int k=0; while(k!=ll) { for(int i=0;i<p.size();i++) { if(p[i]!=s[k++]) return 0; } } return 1; } int main() { int t; bool line=0,done=0; bool f; string blnk,p; cin>>t; getline(cin,blnk); getline(cin,blnk); //addxascc //abcsabcxsabcs while(t–) { if(line) cout<<endl; line=1; getline(cin,str);