Submission #436277

# Submission time Handle Problem Language Result Execution time Memory
436277 2021-06-24T11:23:12 Z LouayFarah Library (JOI18_library) C++14
19 / 100
523 ms 292 KB
#include "bits/stdc++.h"
#include "library.h"
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
void Solve(int n)
{
    if(n==1)
    {
        vector<int> res(1);
        res[0] = 1;
        Answer(res);
        return;
    }
    if(n==2)
    {
        vector<int> res(2);
        res[0] = 1, res[1] = 2;
        Answer(res);
        return;
    }
    
    vector<pair<int, int>> arr;
    vector<int> m(n, 0);
    for(int i = 1; i<=n; i++)
    {
        for(int j = i+1; j<=n; j++)
        {
            m.assign(n, 0);
            m[i-1] = 1, m[j-1] = 1;
            int cnt = Query(m);
            if(cnt==1)
            {
                arr.pb(mp(i, j));
            }
        }
    }
 
    vector<int> adj[n+1];
    for(int i = 0; i<(int)arr.size(); i++)
    {
        adj[arr[i].fi].pb(arr[i].se);
        adj[arr[i].se].pb(arr[i].fi);
    }
 
    int beg = 1;
    for(int i = 1; i<=n; i++)
    {
        if((int)adj[i].size()==1)
        {
            beg = i;
            break;
        }
    }
 
    vector<bool> visited(n+1, false);
    queue<int> q;
 
    q.push(beg);
    visited[beg] = true;
 
    vector<int> res;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
 
        res.pb(u);
 
        for(auto v: adj[u])
        {
            if(visited[v])
                continue;
            visited[v] = true;
            q.push(v);
        }
    }
 
    Answer(res);
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 212 ms 200 KB # of queries: 18336
2 Correct 280 ms 272 KB # of queries: 18145
3 Correct 275 ms 280 KB # of queries: 19900
4 Correct 373 ms 276 KB # of queries: 19900
5 Correct 226 ms 272 KB # of queries: 19900
6 Correct 448 ms 272 KB # of queries: 19900
7 Correct 376 ms 276 KB # of queries: 19900
8 Correct 300 ms 272 KB # of queries: 18528
9 Correct 401 ms 272 KB # of queries: 19701
10 Correct 163 ms 280 KB # of queries: 8256
11 Correct 1 ms 200 KB # of queries: 0
12 Correct 1 ms 212 KB # of queries: 0
13 Correct 1 ms 200 KB # of queries: 3
14 Correct 1 ms 200 KB # of queries: 6
15 Correct 3 ms 200 KB # of queries: 105
16 Correct 7 ms 292 KB # of queries: 351
# Verdict Execution time Memory Grader output
1 Correct 212 ms 200 KB # of queries: 18336
2 Correct 280 ms 272 KB # of queries: 18145
3 Correct 275 ms 280 KB # of queries: 19900
4 Correct 373 ms 276 KB # of queries: 19900
5 Correct 226 ms 272 KB # of queries: 19900
6 Correct 448 ms 272 KB # of queries: 19900
7 Correct 376 ms 276 KB # of queries: 19900
8 Correct 300 ms 272 KB # of queries: 18528
9 Correct 401 ms 272 KB # of queries: 19701
10 Correct 163 ms 280 KB # of queries: 8256
11 Correct 1 ms 200 KB # of queries: 0
12 Correct 1 ms 212 KB # of queries: 0
13 Correct 1 ms 200 KB # of queries: 3
14 Correct 1 ms 200 KB # of queries: 6
15 Correct 3 ms 200 KB # of queries: 105
16 Correct 7 ms 292 KB # of queries: 351
17 Runtime error 523 ms 200 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -