제출 #1087779

#제출 시각아이디문제언어결과실행 시간메모리
1087779cjtsaiNaval battle (CEOI24_battle)C++14
46 / 100
1822 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define piii pair<int, pii> #define pb push_back #define all(x) x.begin(),x.end() #define ff first #define ss second const int dx[4]={0, 0, 1, -1}; const int dy[4]={-1, 1, 0, 0}; signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); int n;cin>>n; vector<int> x(n); vector<int> y(n); vector<int> d(n); for(int i=0; i<n; i++){ cin>>x[i]>>y[i]; char t;cin>>t; if(t=='N') d[i]=0; else if(t=='S') d[i]=1; else if(t=='E') d[i]=2; else d[i]=3; } vector<piii> q; for(int i=0; i<n; i++){ for(int j=i; j<n; j++){ if(i==j) continue; int ti=i, tj=j; if(x[i]==x[j]){ if(y[ti]>y[tj]) swap(ti, tj); if(d[ti]==1&&d[tj]==0) q.pb({(y[tj]-y[ti])/2, {i, j}}); }else if(y[i]==y[j]){ if(x[ti]>x[tj]) swap(ti, tj); if(d[ti]==2&&d[tj]==3) q.pb({(x[tj]-x[ti])/2, {i, j}}); }else{ if(abs(x[ti]-x[tj])==abs(y[ti]-y[tj])){ int ts=abs(x[ti]-x[tj]); //cout<<i<<' '<<j<<'\n'; if((x[ti]+ts*dx[d[ti]])==(x[tj]+ts*dx[d[tj]])){ // cout<<i<<' '<<j<<'\n'; if((y[ti]+ts*dy[d[ti]])==(y[tj]+ts*dy[d[tj]])){ // cout<<i<<' '<<j<<'\n'; q.pb({abs(x[ti]-x[tj]), {i, j}}); } } } } } } sort(all(q)); vector<int> alive(n+1, 1e17); for(auto [a, b]:q){ auto [x, y]=b; //cout<<a<<' '<<x<<' '<<y<<'\n'; if((alive[x]>=a)&&(alive[y]>=a)){ alive[x]=a; alive[y]=a; } } int ans=0; for(int i=0; i<n; i++) if(alive[i]==1e17) cout<<i+1<<'\n'; }

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

Main.cpp: In function 'int main()':
Main.cpp:56:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   56 |  for(auto [a, b]:q){
      |           ^
Main.cpp:57:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   57 |   auto [x, y]=b;
      |        ^
Main.cpp:64:6: warning: unused variable 'ans' [-Wunused-variable]
   64 |  int ans=0;
      |      ^~~
#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...