# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
158157 | 2019-10-15T06:22:59 Z | kig9981 | 통행료 (IOI18_highway) | C++17 | 38 ms | 7672 KB |
#include "highway.h" #include <bits/stdc++.h> using namespace std; vector<int> adj[90000]; set<int> gv[90000]; int g[90000]; void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int M=U.size(), sg=0, tg=0, gnum=0; vector<int> W(M); long long dist=ask(W); queue<int> Q; for(int i=0;i<M;i++) { adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); } for(int i=0;i<N;i++) gv[0].insert(i); while(gv[sg].size()>1) { do { int c=*gv[sg].begin(); Q.push(c); g[c]=++gnum; gv[sg].erase(c); gv[gnum].insert(c); while(!Q.empty()) { c=Q.front(); Q.pop(); for(auto n: adj[c]) if(gv[gnum].size()<gv[sg].size() && g[n]==sg) { g[n]=gnum; gv[sg].erase(n); gv[gnum].insert(n); Q.push(n); } } } while(gv[gnum].size()<gv[sg].size()); if(gv[gnum].size()==1) { for(int i=0;i<M;i++) W[i]=g[U[i]]==gnum || g[V[i]]==gnum; if(ask(W)==dist+B-A) sg=gnum; } else { long long temp; for(int i=0;i<M;i++) W[i]=g[U[i]]==gnum && g[V[i]]!=gnum || g[U[i]]!=gnum && g[V[i]]==gnum; temp=(ask(W)-dist)/(B-A); if(sg==tg) { if(temp&1) sg=gnum; else if(temp) sg=tg=gnum; } else if(temp&1) sg=gnum; } } while(gv[tg].size()>1) { do { int c=*gv[tg].begin(); Q.push(c); g[c]=++gnum; gv[tg].erase(c); gv[gnum].insert(c); while(!Q.empty()) { c=Q.front(); Q.pop(); for(auto n: adj[c]) if(gv[gnum].size()<gv[tg].size() && g[n]==tg) { g[n]=gnum; gv[tg].erase(n); gv[gnum].insert(n); Q.push(n); } } } while(gv[gnum].size()<gv[tg].size()); if(gv[gnum].size()==1) { for(int i=0;i<M;i++) W[i]=g[U[i]]==gnum || g[V[i]]==gnum; if(ask(W)==dist+B-A) tg=gnum; } else { for(int i=0;i<M;i++) W[i]=g[U[i]]==gnum && g[V[i]]!=gnum || g[U[i]]!=gnum && g[V[i]]==gnum; if((ask(W)-dist)/(B-A)&1) tg=gnum; } } answer(*gv[sg].begin(),*gv[tg].begin()); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 6668 KB | Output is incorrect: {s, t} is wrong. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 6780 KB | Output is incorrect: {s, t} is wrong. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 38 ms | 7592 KB | Output is incorrect: {s, t} is wrong. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 6776 KB | Output is incorrect: {s, t} is wrong. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 34 ms | 7672 KB | Output is incorrect: {s, t} is wrong. |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 33 ms | 7672 KB | Output is incorrect: {s, t} is wrong. |
2 | Halted | 0 ms | 0 KB | - |