Submission #120275

# Submission time Handle Problem Language Result Execution time Memory
120275 2019-06-24T06:23:31 Z 이온조(#2949) Highway Tolls (IOI18_highway) C++14
51 / 100
370 ms 20148 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int n, M;
long long ori;
vector<pii> adj[90009];
int D[90009];

int any(vector<int> S) {
    int K = S.size();
    if(K == 1) return S[0];
    vector<int> W(M, 0), nxt;
    for(int i=0; i<K/2; i++) for(auto& it: adj[S[i]]) W[it.second] = 1;
    if(ori != ask(W)) for(int i=0; i<K/2; i++) nxt.push_back(S[i]);
    else for(int i=K/2; i<K; i++) nxt.push_back(S[i]);
    return any(nxt);
}

vector<int> f(int root) {
    int c = 1;
    for(int i=0; i<n; i++) D[i] = 0;
    queue<int> que; que.push(root); D[root] = 1;
    while(que.size()) {
        int sz = que.size();
        while(sz--) {
            int now; now = que.front(); que.pop();
            for(auto& it: adj[now]) {
                if(!D[it.first]) {
                    D[it.first] = c+1;
                    que.push(it.first);
                }
            }
        }
        ++c;
    }
    vector<int> S;
    for(int i=0; i<n; i++) S.push_back(i);
    sort(S.begin(), S.end(), [&](int P, int Q) {return D[P] > D[Q];});
    return S;
}

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
    n = N; M = U.size();
    for(int i=0; i<M; i++) {
        adj[U[i]].push_back({V[i], i});
        adj[V[i]].push_back({U[i], i});
    }
    vector<int> W(M), S; ori = ask(W);
    for(int i=0; i<N; i++) S.push_back(i);
    int P = any(f(any(S)));
    int Q = any(f(P));
    answer(P, Q);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2436 KB Output is correct
2 Correct 4 ms 2448 KB Output is correct
3 Correct 4 ms 2424 KB Output is correct
4 Correct 4 ms 2440 KB Output is correct
5 Correct 4 ms 2524 KB Output is correct
6 Correct 4 ms 2444 KB Output is correct
7 Correct 4 ms 2424 KB Output is correct
8 Correct 4 ms 2424 KB Output is correct
9 Correct 4 ms 2436 KB Output is correct
10 Correct 4 ms 2424 KB Output is correct
11 Correct 4 ms 2344 KB Output is correct
12 Correct 4 ms 2444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2580 KB Output is correct
2 Correct 29 ms 3680 KB Output is correct
3 Correct 278 ms 15284 KB Output is correct
4 Correct 258 ms 15848 KB Output is correct
5 Correct 277 ms 15368 KB Output is correct
6 Correct 288 ms 15308 KB Output is correct
7 Correct 277 ms 15672 KB Output is correct
8 Correct 306 ms 15640 KB Output is correct
9 Correct 305 ms 15732 KB Output is correct
10 Correct 267 ms 15296 KB Output is correct
11 Correct 270 ms 15172 KB Output is correct
12 Correct 314 ms 14760 KB Output is correct
13 Correct 273 ms 14764 KB Output is correct
14 Correct 314 ms 14748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 3680 KB Output is correct
2 Correct 40 ms 5068 KB Output is correct
3 Correct 63 ms 6424 KB Output is correct
4 Correct 200 ms 14784 KB Output is correct
5 Correct 225 ms 14808 KB Output is correct
6 Correct 184 ms 14760 KB Output is correct
7 Correct 206 ms 14752 KB Output is correct
8 Correct 193 ms 14792 KB Output is correct
9 Correct 193 ms 14848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2552 KB Output is correct
2 Correct 26 ms 3760 KB Output is correct
3 Correct 232 ms 12528 KB Output is correct
4 Correct 319 ms 15372 KB Output is correct
5 Correct 267 ms 15444 KB Output is correct
6 Correct 251 ms 15360 KB Output is correct
7 Correct 282 ms 15648 KB Output is correct
8 Correct 276 ms 15448 KB Output is correct
9 Correct 280 ms 15364 KB Output is correct
10 Correct 274 ms 15220 KB Output is correct
11 Correct 290 ms 14760 KB Output is correct
12 Correct 301 ms 14844 KB Output is correct
13 Correct 284 ms 14860 KB Output is correct
14 Correct 300 ms 15088 KB Output is correct
15 Correct 255 ms 15372 KB Output is correct
16 Correct 263 ms 15280 KB Output is correct
17 Correct 285 ms 14832 KB Output is correct
18 Correct 310 ms 15192 KB Output is correct
19 Correct 281 ms 15336 KB Output is correct
20 Correct 290 ms 15052 KB Output is correct
21 Correct 258 ms 15868 KB Output is correct
22 Correct 241 ms 15904 KB Output is correct
23 Correct 260 ms 15828 KB Output is correct
24 Correct 236 ms 15720 KB Output is correct
25 Correct 346 ms 14952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3836 KB Output is correct
2 Correct 33 ms 3980 KB Output is correct
3 Correct 303 ms 16720 KB Output is correct
4 Correct 289 ms 17788 KB Output is correct
5 Correct 345 ms 19828 KB Output is correct
6 Incorrect 369 ms 20148 KB Output is incorrect: {s, t} is wrong.
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3840 KB Output is correct
2 Correct 34 ms 3944 KB Output is correct
3 Partially correct 287 ms 16944 KB Output is partially correct
4 Partially correct 301 ms 17320 KB Output is partially correct
5 Partially correct 317 ms 17724 KB Output is partially correct
6 Partially correct 362 ms 19992 KB Output is partially correct
7 Partially correct 294 ms 16496 KB Output is partially correct
8 Correct 304 ms 16988 KB Output is correct
9 Partially correct 317 ms 17808 KB Output is partially correct
10 Partially correct 370 ms 20108 KB Output is partially correct
11 Correct 357 ms 19644 KB Output is correct
12 Correct 331 ms 19476 KB Output is correct
13 Correct 306 ms 17104 KB Output is correct
14 Correct 306 ms 16576 KB Output is correct
15 Correct 285 ms 17092 KB Output is correct
16 Correct 268 ms 16660 KB Output is correct
17 Correct 291 ms 17356 KB Output is correct
18 Correct 276 ms 16596 KB Output is correct
19 Incorrect 283 ms 19460 KB Output is incorrect: {s, t} is wrong.
20 Halted 0 ms 0 KB -