Submission #1044068

#TimeUsernameProblemLanguageResultExecution timeMemory
1044068gagik_2007Naval battle (CEOI24_battle)C++17
0 / 100
43 ms16576 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second ll ttt; const ll INF=1e18; const ll MOD=1e9+7; const ll N=100007; ll n,m,k; int arr[2007]; struct Ship{ int ind; int x; int y; char dir; }; Ship a[N]; bool dead[N]; bool fri[N]; unordered_map<int,set<pair<int,int>>>p; vector<Ship>s; vector<Ship>e; void recurs(int ind){ // cout<<ind<<endl; if(dead[ind]||fri[ind])return; if(a[ind].dir!='S')return; int x=a[ind].x; int y=a[ind].y; int i=a[ind].ind; auto it=p[x+y].lower_bound({y,MOD}); if(it==p[x+y].end()){ fri[ind]=true; p[x+y].erase(p[x+y].find({y,ind})); return; } if(a[(*it).ss].dir=='S'){ recurs((*it).ss); recurs(ind); } else{ dead[ind]=true; dead[(*it).ss]=true; p[x+y].erase(p[x+y].find({y,ind})); p[x+y].erase(it); } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("inputA.txt","r",stdin); // freopen("outputA.txt","w",stdout); cin>>n; for(int i=0;i<n;i++){ int x,y; char c; cin>>x>>y>>c; a[i].x=x; a[i].y=y; a[i].dir=c; a[i].ind=i; dead[i]=false; // cout<<"OK"<<endl; if(c=='S'){ s.push_back(a[i]); } else{ e.push_back(a[i]); } p[x+y].insert({y,i}); } // cout<<"OK"<<endl; for(int i=0;i<s.size();i++){ recurs(s[i].ind); } for(int i=0;i<n;i++){ if(!dead[i]){ cout<<i+1<<endl; } } }

Compilation message (stderr)

Main.cpp: In function 'void recurs(int)':
Main.cpp:39:9: warning: unused variable 'i' [-Wunused-variable]
   39 |     int i=a[ind].ind;
      |         ^
Main.cpp: In function 'int main()':
Main.cpp:84:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Ship>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
#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...