Submission #1134310

#TimeUsernameProblemLanguageResultExecution timeMemory
1134310ReLiceNaval battle (CEOI24_battle)C++20
6 / 100
2394 ms1114112 KiB
#include <bits/stdc++.h> #define ll long long #define ld double #define pb push_back #define pf push_front #define ins insert #define fr first #define sc second #define endl "\n" #define ar array #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() using namespace std; void start(){ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);} void solve() { ll i, j; ll n; cin>>n; ll x[n + 1], y[n + 1]; ll d[n + 1]; for(i=1;i<=n;i++){ char ch; cin>>x[i]>>y[i]>>ch; if(ch == 'N') d[i] = 0; if(ch == 'S') d[i] = 1; if(ch == 'W') d[i] = 2; if(ch == 'E') d[i] = 3; } vector<ar<ll, 3>> v; for(i=1;i<=n;i++){ for(j=i + 1;j<=n;j++){ if(d[i] == d[j]) continue; if(d[i] > d[j]) swap(i, j); if(d[i] == 0 && d[j] == 1 && x[i] == x[j]){ v.pb({abs(y[i] - y[j]) / 2, i, j}); } if(d[i] == 2 && d[j] == 3 && y[i] == y[j]){ v.pb({abs(x[i] - x[j]) / 2, i, j}); } if(d[i] <= 1 && d[j] >= 2){ bool f = 0; if(d[i] == 0 && d[j] == 2 && x[j] - x[i] == y[i] - y[j] && x[j] > x[i]) f = 1; if(d[i] == 0 && d[j] == 3 && x[i] - x[j] == y[i] - y[j] && x[i] > x[j]) f = 1; if(d[i] == 1 && d[j] == 2 && x[j] - x[i] == y[j] - y[i] && x[j] > x[i]) f = 1; if(d[i] == 1 && d[j] == 3 && x[i] - x[j] == y[j] - y[i] && x[i] > x[j]) f = 1; if(f){ v.pb({abs(x[i] - x[j]), i, j}); } } if(i > j) swap(i, j); } } vector<bool> f(n + 1, true); sort(rall(v)); while(v.size()){ vector<ll> vv; ll x = v.back()[0]; while(v.size() && v.back()[0] == x){ i = v.back()[1], j = v.back()[2]; v.pop_back(); if(f[i] && f[j]){ vv.pb(i); vv.pb(j); } } for(auto i : vv){ f[i] = 0; } } for(i=1;i<=n;i++) { if(f[i]) cout<<i<<endl; } } signed main(){ start(); ll t = 1; //cin>>t; while(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...