제출 #1044025

#제출 시각아이디문제언어결과실행 시간메모리
1044025gagik_2007Naval battle (CEOI24_battle)C++17
46 / 100
1170 ms199568 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; int dir; }; Ship a[N]; vector<pair<int,pair<int,int>>>p; int dead[N]; int whenCollide(Ship b, Ship c){ if(b.dir==c.dir){ return MOD; } if(b.dir>c.dir){ swap(b,c); } if(b.dir==0){ if(c.dir==1){ int d=b.x-c.x; if(d<=0){ return MOD; } int d2=b.y-c.y; if(d==d2){ return d; } return MOD; } else if(c.dir==2){ if(b.x!=c.x){ return MOD; } int d=(b.y-c.y)/2; if(d<=0){ return MOD; } return d; } else if(c.dir==3){ int d=c.x-b.x; if(d<=0){ return MOD; } int d2=b.y-c.y; if(d==d2){ return d; } return MOD; } } else if(b.dir==1){ if(c.dir==2){ int d=c.x-b.x; if(d<=0){ return MOD; } int d2=b.y-c.y; if(d==d2){ return d; } return MOD; } else if(c.dir==3){ if(b.y!=c.y){ return MOD; } int d=(c.x-b.x)/2; if(d<=0){ return MOD; } return d; } } else if(b.dir==2){ if(c.dir==3){ int d=c.x-b.x; if(d<=0){ return MOD; } int d2=c.y-b.y; if(d==d2){ return d; } return MOD; } } return MOD; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("inputA.txt","r",stdin); // freopen("outputA.txt","w",stdout); arr['N']=0; arr['E']=1; arr['S']=2; arr['W']=3; 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=arr[c]; a[i].ind=i; dead[i]=MOD; } for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ p.push_back({whenCollide(a[i],a[j]),{i,j}}); } } sort(p.begin(),p.end()); for(auto x:p){ if(x.ff==MOD){ break; } if(dead[x.ss.ff]>=x.ff&&dead[x.ss.ss]>=x.ff){ dead[x.ss.ff]=x.ff; dead[x.ss.ss]=x.ff; } } for(int i=0;i<n;i++){ if(dead[i]==MOD){ cout<<i+1<<endl; } } }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:127:22: warning: array subscript has type 'char' [-Wchar-subscripts]
  127 |         a[i].dir=arr[c];
      |                      ^
#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...