제출 #1113554

#제출 시각아이디문제언어결과실행 시간메모리
1113554EfeBabagilNaval battle (CEOI24_battle)C++14
0 / 100
3006 ms6996 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] + a[0]< b[0] + b[1] && a[0] < b[0]; } int srt2(array<int,3> a,array<int,3> b) { return a[1] + a[0]< b[0] + b[1] && a[1] < 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(),srt); 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; vector<int> sunk(t+1); 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]) { sunk[e[i][2]]++; sunk[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=1;i<t+1;i++) { if(!sunk[i]) cout<<i<<" "; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int32_t main()':
Main.cpp:56: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]
   56 |     while(i<e.size()&&j<s.size())
      |           ~^~~~~~~~~
Main.cpp:56: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]
   56 |     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...