Submission #1300612

#TimeUsernameProblemLanguageResultExecution timeMemory
1300612iq500Naval battle (CEOI24_battle)C++20
6 / 100
2831 ms1114112 KiB
//naval battle #include <bits/stdc++.h> #define int long long #define fir first #define sec second using namespace std; const int inf=LLONG_MAX; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; int ans[n]; pair<char, pair<int, int>> g[n]; for(int i=0; i<n; i++){ ans[i]=inf; cin>>g[i].sec.fir>>g[i].sec.sec>>g[i].fir; } priority_queue<pair<int, pair<int, int>>> pq; for(int i=0; i<n; i++){ int c=g[i].fir, x=g[i].sec.fir, y=g[i].sec.sec; for(int j=i+1; j<n; j++){ int c2=g[j].fir, x2=g[j].sec.fir, y2=g[j].sec.sec; //cout<<i<<" "<<j<<"...\n"; if(c=='S'){ if(c2=='N' && x==x2 && y<y2) pq.push({-(y2-y)/2, {i, j}}); if(c2=='E' && x2<x && y<y2 && x-x2==y2-y) pq.push({-(y2-y), {i, j}}); if(c2=='W' && x<x2 && y<y2 && x2-x==y2-y) pq.push({-(y2-y), {i, j}}); } if(c=='N'){ if(c2=='S' && x==x2 && y>y2) pq.push({-(y-y2)/2, {i, j}}); if(c2=='E' && x2<x && y>y2 && x-x2==y-y2) pq.push({-(y-y2), {i, j}}); if(c2=='W' && x<x2 && y>y2 && x2-x==y-y2) pq.push({-(y-y2), {i, j}}); } if(c=='E'){ if(c2=='W' && y==y2 && x<x2) pq.push({-(x2-x)/2,{i, j}}); if(c2=='S' && x<x2 && y>y2 && x2-x==y-y2) pq.push({-(y-y2), {i, j}}); if(c2=='N' && x2>x && y2>y && x2-x==y2-y) pq.push({-(y2-y), {i, j}}); } if(c=='W'){ if(c2=='E' && y==y2 && x>x2) pq.push({-(x-x2)/2,{i, j}}); if(c2=='S' && x2<x && y2<y && x-x2==y-y2) pq.push({-(y-y2), {i, j}}); if(c2=='N' && x2<x && y2>y && x-x2==y2-y) pq.push({-(y2-y), {i, j}}); } } } while(pq.size()){ int c=pq.top().fir, x=pq.top().sec.fir, y=pq.top().sec.sec; pq.pop(); if(ans[x]<c || ans[y]<c) continue; ans[x]=c; ans[y]=c; } for(int i=0; i<n; i++){ if(ans[i]==inf) cout<<i+1<<"\n"; } return 0; }
#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...