Submission #1137631

#TimeUsernameProblemLanguageResultExecution timeMemory
1137631ghammazhassanNaval battle (CEOI24_battle)C++20
6 / 100
3094 ms5188 KiB
// #include <bits/stdc++.h> #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> using namespace std; #define int long long #define endl "\n"; const int N=2e5+5; const int M=1e9+7; void solve() { int n; cin >> n; vector<pair<int,int>>a(n); vector<char>s(n); for (int i=0;i<n;i++){ int d1,d2; char r; cin >> d1 >> d2 >> r; a[i]={d1,d2}; s[i]=r; } vector<int>vi(n,1); for (int i=0;i<n;i++){ for (int j=i+1;j<n;j++){ int x1,y1,x2,y2; char s1,s2; x1=a[i].first; x2=a[j].first; y1=a[i].second; y2=a[j].second; s1=s[i]; s2=s[j]; if (s1==s2){ continue; } if (s1=='S' and s2=='N'){ if (y1>y2 or x1!=x2){ continue; } vi[i]=0; vi[j]=0; } if (s1=='N' and s2=='S'){ if (y1<y2 or x1!=x2){ continue; } vi[i]=0; vi[j]=0; } if (s1=='E' and s2=='W'){ if (x1>x2 or y1!=y2){ continue; } vi[i]=0; vi[j]=0; } if (s1=='W' and s2=='E'){ if (x1<x2 or y1!=y2){ continue; } vi[i]=0; vi[j]=0; } int o=abs(x1-x2); if (s1=='S'){ y1+=o; } else if (s1=='N'){ y1-=o; } else if (s1=='E'){ x1+=o; } else if (s1=='W'){ x1-=o; } if (s2=='S'){ y2+=o; } else if (s2=='N'){ y2-=o; } else if (s2=='E'){ x2+=o; } else if (s2=='W'){ x2-=o; } if (x1!=x2 or y1!=y2){ continue; } vi[i]=0; vi[j]=0; } } for (int i=0;i<n;i++){ if (vi[i]){ cout << i+1 << endl; } } } signed main() { ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE cout << fixed<<setprecision(9); int t=1; // cin >> t; for (int _=1;_<=t;_++){ solve(); } }
#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...