Submission #1068847

#TimeUsernameProblemLanguageResultExecution timeMemory
1068847naneosmicNaval battle (CEOI24_battle)C++14
0 / 100
3038 ms9296 KiB
#include <bits/stdc++.h> #define int long long #define endl "\n" using namespace std; void solve(){ int n; cin>>n; vector<pair<pair<int,int>,int>>v(n); vector<bool>gone(n,false); for(int i=0;i<n;i++){ int x,y;char c; cin>>x>>y>>c; int num; if(c=='N'){ num=0; }else if(c=='S'){ num=1; }else if(c=='E'){ num=2; }else if(c=='W'){ num=3; } v[i]=make_pair(make_pair(x,y),num); } set<pair<int,pair<int,int>>>collisions; for(int i=0;i<n;i++){ pair<pair<int,int>,int>cur=v[i]; int num1=cur.second; for(int j=0;j<n;j++){ pair<pair<int,int>,int>novi=v[j]; int num2=novi.second; if(num1==0&&num2==1){ if(cur.first.first==novi.first.first){ collisions.insert(make_pair((cur.first.second-novi.first.second)/2,make_pair(i,j))); } }else if(num1==0&&num2==2){ if(cur.first.first+novi.first.second==cur.first.second+novi.first.first){ collisions.insert(make_pair(cur.first.second-novi.first.second,make_pair(i,j))); } }else if(num1==0&&num2==3){ if(cur.first.first+novi.first.first==cur.first.second+novi.first.second){ collisions.insert(make_pair(cur.first.second-novi.first.second,make_pair(i,j))); } }else if(num1==1&&num2==0){ if(cur.first.first==novi.first.first){ collisions.insert(make_pair((novi.first.second-cur.first.second)/2,make_pair(i,j))); } }else if(num1==1&&num2==2){ if(cur.first.first+novi.first.first==cur.first.second+novi.first.second){ collisions.insert(make_pair(novi.first.second-cur.first.second,make_pair(i,j))); } }else if(num1==1&&num2==3){ if(cur.first.first+novi.first.second==cur.first.second+novi.first.first){ collisions.insert(make_pair(novi.first.second-cur.first.second,make_pair(i,j))); } }else if(num1==2&&num2==0){ if(cur.first.first+novi.first.second==cur.first.second+novi.first.first){ collisions.insert(make_pair(novi.first.second-cur.first.second,make_pair(i,j))); } }else if(num1==2&&num2==1){ if(cur.first.first+novi.first.first==cur.first.second+novi.first.second){ collisions.insert(make_pair(cur.first.second-novi.first.second,make_pair(i,j))); } }else if(num1==2&&num2==3){ if(cur.first.second==novi.first.second){ collisions.insert(make_pair((novi.first.first-cur.first.first)/2,make_pair(i,j))); } }else if(num1==3&&num2==0){ if(cur.first.first+novi.first.first==cur.first.second+novi.first.second){ collisions.insert(make_pair(novi.first.second-cur.first.second,make_pair(i,j))); } }else if(num1==3&&num2==1){ if(cur.first.first+novi.first.second==cur.first.second+novi.first.first){ collisions.insert(make_pair(cur.first.second-novi.first.second,make_pair(i,j))); }else if(num1==3&&num2==2){ if(cur.first.second==novi.first.second){ collisions.insert(make_pair((cur.first.first-novi.first.first)/2,make_pair(i,j))); } } } } } auto it1=collisions.lower_bound(make_pair(0,make_pair(0,0))); vector<int>tobeerased; int val=-1; while(it1!=collisions.end()){ if((!gone[(*it1).second.first])&&(!gone[(*it1).second.second])){ if(val=-1){ val=(*it1).first; tobeerased.push_back((*it1).second.first); tobeerased.push_back((*it1).second.second); }else if(val!=(*it1).first){ for(int neznamvise=0;neznamvise<tobeerased.size();neznamvise++){ gone[tobeerased[neznamvise]]=true; } tobeerased.clear(); val=(*it1).first; tobeerased.push_back((*it1).second.first); tobeerased.push_back((*it1).second.second); }else{ tobeerased.push_back((*it1).second.first); tobeerased.push_back((*it1).second.second); } } it1++; } for(int i=0;i<n;i++){ if(!gone[i]){ cout<<i+1<<" "; } } cout<<'\n'; } signed main(){ solve(); }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:88:19: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   88 |             if(val=-1){
      |                ~~~^~~
Main.cpp:93:48: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |                 for(int neznamvise=0;neznamvise<tobeerased.size();neznamvise++){
      |                                      ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#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...