제출 #158276

#제출 시각아이디문제언어결과실행 시간메모리
158276kig9981통행료 (IOI18_highway)C++17
46 / 100
3086 ms9240 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; vector<int> adj[90000]; int dist1[90000], dist2[90000]; bool chk[90000]; void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int M=U.size(), S, T, s, e, E; vector<int> W(M,0), C1, C2; queue<int> Q; long long D=ask(W); for(int i=0;i<M;i++) { adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); } s=0; e=N-1; while(s<=e) { int m=(s+e)>>1; for(int i=0;i<N;i++) W[i]=i<=m; if(ask(W)!=D) e=m-1; else s=m+1; } E=s; memset(dist1,0x7f,sizeof(dist1)); memset(dist2,0x7f,sizeof(dist2)); dist1[U[E]]=0; Q.push(U[E]); while(!Q.empty()) { int c=Q.front(); Q.pop(); for(auto n: adj[c]) if(dist1[n]>dist1[c]+1) { dist1[n]=dist1[c]+1; Q.push(n); } } dist2[V[E]]=0; Q.push(V[E]); while(!Q.empty()) { int c=Q.front(); Q.pop(); for(auto n: adj[c]) if(dist2[n]>dist2[c]+1) { dist2[n]=dist2[c]+1; Q.push(n); } } s=0; e=D/A-1; while(s<=e) { int m=(s+e)>>1; for(int i=0;i<M;i++) W[i]=(dist1[U[i]]<dist2[U[i]] && dist1[U[i]]>=m)^(dist1[V[i]]<dist2[V[i]] && dist1[V[i]]>=m); if(ask(W)!=D) s=m+1; else e=m-1; } while(0>e && e>=D/A); for(int i=0;i<N;i++) { if(dist1[i]<dist2[i] && dist1[i]==e) C1.push_back(i); if(dist1[i]>dist2[i] && dist2[i]==D/A-s) C2.push_back(i); chk[i]=false; } while(C1.empty() || C2.empty()); s=0; e=C1.size()-1; while(s<=e) { int m=(s+e)>>1; for(int i=0;i<N;i++) chk[i]=false; for(int i=0;i<=m;i++) chk[C1[i]]=true; for(int i=0;i<M;i++) W[i]=chk[U[i]]^chk[V[i]]; if(ask(W)!=D) e=m-1; else s=m+1; } while(0>s && s>=C1.size()); S=C1[s]; s=0; e=C2.size()-1; while(s<=e) { int m=(s+e)>>1; for(int i=0;i<N;i++) chk[i]=false; for(int i=0;i<=m;i++) chk[C2[i]]=true; for(int i=0;i<M;i++) W[i]=chk[U[i]]^chk[V[i]]; if(ask(W)!=D) e=m-1; else s=m+1; } while(0>s && s>=C2.size()); T=C2[s]; answer(S,T); }

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

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:55:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(0>e && e>=D/A);
   ^~~~~
highway.cpp:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  for(int i=0;i<N;i++) {
  ^~~
highway.cpp:61:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(C1.empty() || C2.empty());
   ^~~~~
highway.cpp:62:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  s=0; e=C1.size()-1;
  ^
highway.cpp:71:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(0>s && s>=C1.size());
                ~^~~~~~~~~~~
highway.cpp:71:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(0>s && s>=C1.size());
   ^~~~~
highway.cpp:72:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  S=C1[s];
  ^
highway.cpp:82:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(0>s && s>=C2.size());
                ~^~~~~~~~~~~
highway.cpp:82:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(0>s && s>=C2.size());
   ^~~~~
highway.cpp:83:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  T=C2[s];
  ^
#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...