Submission #1230937

#TimeUsernameProblemLanguageResultExecution timeMemory
1230937PVM_pvmNaval battle (CEOI24_battle)C++20
6 / 100
3046 ms846924 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 200'007 struct ship { int x,y; int tp; ///N 0, E 1, S 2, W 3 int ind; } sh[MAXN]; int n; int kg[MAXN]; struct event { int vreme; int k1,k2; }; bool operator<(event a, event b) { return a.vreme<b.vreme; } bool operator>(event a, event b) { return a.vreme>b.vreme; } int main() { cin>>n; for (int q=1;q<=n;q++) { sh[q].ind=q; cin>>sh[q].x>>sh[q].y; char c; cin>>c; if (c=='N') sh[q].tp=0; else if (c=='E') sh[q].tp=1; else if (c=='S') sh[q].tp=2; else if (c=='W') sh[q].tp=3; } priority_queue<event> qu; for (int q=1;q<=n;q++) { for (int w=1;w<=n;w++) { if (q==w) continue; if (sh[q].tp==sh[w].tp) continue; if (sh[q].tp==0) { if (sh[w].tp==2) { if (sh[q].x!=sh[w].x) continue; if ((sh[q].y%2)!=(sh[w].y%2)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; dff/=2; qu.push({dff,q,w}); } if (sh[w].tp==1) { if ((sh[q].x-sh[q].y)!=(sh[w].x-sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } if (sh[w].tp==3) { if ((sh[q].x+sh[q].y)!=(sh[w].x+sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } } if (sh[q].tp==2) { if (sh[w].tp==0) { if (sh[q].x!=sh[w].x) continue; if ((sh[q].y%2)!=(sh[w].y%2)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; dff/=2; qu.push({dff,q,w}); } if (sh[w].tp==1) { if ((sh[q].x+sh[q].y)!=(sh[w].x+sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } if (sh[w].tp==3) { if ((sh[q].x-sh[q].y)!=(sh[w].x-sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } } if (sh[q].tp==1) { if (sh[w].tp==3) { if (sh[q].y!=sh[w].y) continue; if ((sh[q].x%2)!=(sh[w].x%2)) continue; int dff=sh[q].x-sh[w].x; if (dff<0) dff*=-1; dff/=2; qu.push({dff,q,w}); } if (sh[w].tp==0) { if ((sh[q].x-sh[q].y)!=(sh[w].x-sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } if (sh[w].tp==2) { if ((sh[q].x+sh[q].y)!=(sh[w].x+sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } } if (sh[q].tp==3) { if (sh[w].tp==1) { if (sh[q].y!=sh[w].y) continue; if ((sh[q].x%2)!=(sh[w].x%2)) continue; int dff=sh[q].x-sh[w].x; if (dff<0) dff*=-1; dff/=2; qu.push({dff,q,w}); } if (sh[w].tp==2) { if ((sh[q].x-sh[q].y)!=(sh[w].x-sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } if (sh[w].tp==0) { if ((sh[q].x+sh[q].y)!=(sh[w].x+sh[w].y)) continue; int dff=sh[q].y-sh[w].y; if (dff<0) dff*=-1; qu.push({dff,q,w}); } } } } while (!qu.empty()) { event tp=qu.top(); qu.pop(); if (kg[ tp.k1 ]!=0 && kg[tp.k2]!=0) continue; if (kg[tp.k1]!=0) { if (tp.vreme==kg[tp.k1]) { kg[tp.k2]=tp.vreme; } continue; } if (kg[tp.k2]!=0) { if (tp.vreme==kg[tp.k2]) { kg[tp.k1]=tp.vreme; } continue; } kg[tp.k1]=tp.vreme; kg[tp.k2]=tp.vreme; } for (int q=1;q<=n;q++) { if (kg[q]==0) cout<<q<<"\n"; } }
#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...