Submission #1113539

#TimeUsernameProblemLanguageResultExecution timeMemory
1113539EfeBabagilNaval battle (CEOI24_battle)C++14
0 / 100
3025 ms6056 KiB
using namespace std; #include <bits/stdc++.h> #define int long long int srt(array<int,3> a, array<int,3> b) { return a[1] < b[1]; } int srt2(array<int,3> a,array<int,3> b) { return a[1] + a[0]< b[0] + b[1]; } int32_t main() { int t; cin>>t; vector<array<int,3>> n,e,w,s; vector<int> ans; for(int i=0;i<t;i++) { int a,b; char c; cin>>a>>b>>c; if(c=='N') { n.push_back({a,b,1+i}); } if(c=='E') { e.push_back({a,b,1+i}); } if(c=='W') { w.push_back({a,b,1+i}); } if(c=='S') { s.push_back({a,b,1+i}); } } sort(e.begin(),e.end()); sort(s.begin(),s.end(),srt); sort(e.begin(),e.end(),srt2); sort(s.begin(),s.end(),srt2); /*for(int i=0;i<e.size();i++) { cout<<e[i][0]<<" "<<e[i][1]<<endl; } cout<<endl<<endl; for(int i=0;i<s.size();i++) { cout<<s[i][0]<<" "<<s[i][1]<<endl; }*/ int i=0; int j=0; while(i<e.size()&&j<s.size()) { if(s[i][0]<=e[i][0]) { i++; } else if(e[i][0]+e[i][1]==s[j][0]+s[j][1]) { ans.push_back(e[i][2]); ans.push_back(s[j][2]); i++; j++; } else if(e[i][0]+e[i][1]<s[j][0]+s[j][1]) { i++; } else if(e[i][0]+e[i][1]>s[i][0]+s[i][1]) { j++; } } ans.push_back(0); sort(ans.begin(),ans.end()); for(int i=0;i<t;i++) { /* int l=0,r=ans.size()-1; int flag=0; while(l+1<r) { int mid=(r+l)/2; if(ans[mid]==i+1) flag=1; else if(ans[mid]>i+1) r=mid; else l=mid; }*/ auto it=lower_bound(ans.begin(),ans.end(),i+1); if(it==ans.end()||*it!=1+i) cout<<i+1<<" "; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:58:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     while(i<e.size()&&j<s.size())
      |           ~^~~~~~~~~
Main.cpp:58:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     while(i<e.size()&&j<s.size())
      |                       ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...