답안 #227507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227507 2020-04-27T15:25:21 Z MKopchev 도서관 (JOI18_library) C++14
19 / 100
2000 ms 2812 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

const int nmax=1e5+42;

vector<int> adj[nmax];

vector<int> order={4,2,5,3,1};
/*
int Query(vector<int> in)
{
    bool active=0;
    int ret=0;
    for(auto k:order)
    {
        if(in[k-1])
        {
            if(active==0)ret++;
            active=1;
        }
        else active=0;
    }
    return ret;
}
void Answer(vector<int> outp)
{
    for(auto k:outp)printf("%i ",k);
}
*/
vector<int> outp;
void dfs(int node,int par)
{
    outp.push_back(node);
    for(auto k:adj[node])
        if(k!=par)dfs(k,node);
}

void Solve(int n_)
{
    if(n_==1)
    {
        Answer({1});
    }

    vector<int> help={};
    for(int i=0;i<n_;i++)help.push_back(0);

    for(int i=0;i<n_;i++)
        for(int j=i+1;j<n_;j++)
        {
            help[i]=1;
            help[j]=1;

            if(Query(help)==1)
            {
                //cout<<i+1<<" to "<<j+1<<endl;
                adj[i+1].push_back(j+1);
                adj[j+1].push_back(i+1);
            }

            help[i]=0;
            help[j]=0;
        }

    for(int i=1;i<=n_;i++)
        if(adj[i].size()==1)
        {
            dfs(i,0);
            Answer(outp);
            return;
        }

}
/*
int main()
{
    Solve(5);

    return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 2688 KB # of queries: 18336
2 Correct 256 ms 2808 KB # of queries: 18145
3 Correct 268 ms 2716 KB # of queries: 19900
4 Correct 281 ms 2688 KB # of queries: 19900
5 Correct 301 ms 2808 KB # of queries: 19900
6 Correct 262 ms 2688 KB # of queries: 19900
7 Correct 264 ms 2728 KB # of queries: 19900
8 Correct 277 ms 2808 KB # of queries: 18528
9 Correct 288 ms 2688 KB # of queries: 19701
10 Correct 104 ms 2720 KB # of queries: 8256
11 Correct 6 ms 2688 KB # of queries: 0
12 Correct 6 ms 2688 KB # of queries: 1
13 Correct 7 ms 2688 KB # of queries: 3
14 Correct 6 ms 2688 KB # of queries: 6
15 Correct 7 ms 2688 KB # of queries: 105
16 Correct 10 ms 2612 KB # of queries: 351
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 2688 KB # of queries: 18336
2 Correct 256 ms 2808 KB # of queries: 18145
3 Correct 268 ms 2716 KB # of queries: 19900
4 Correct 281 ms 2688 KB # of queries: 19900
5 Correct 301 ms 2808 KB # of queries: 19900
6 Correct 262 ms 2688 KB # of queries: 19900
7 Correct 264 ms 2728 KB # of queries: 19900
8 Correct 277 ms 2808 KB # of queries: 18528
9 Correct 288 ms 2688 KB # of queries: 19701
10 Correct 104 ms 2720 KB # of queries: 8256
11 Correct 6 ms 2688 KB # of queries: 0
12 Correct 6 ms 2688 KB # of queries: 1
13 Correct 7 ms 2688 KB # of queries: 3
14 Correct 6 ms 2688 KB # of queries: 6
15 Correct 7 ms 2688 KB # of queries: 105
16 Correct 10 ms 2612 KB # of queries: 351
17 Execution timed out 3011 ms 2688 KB Time limit exceeded
18 Execution timed out 3064 ms 2808 KB Time limit exceeded
19 Execution timed out 3001 ms 2752 KB Time limit exceeded
20 Execution timed out 3101 ms 2808 KB Time limit exceeded
21 Execution timed out 3090 ms 2808 KB Time limit exceeded
22 Execution timed out 3069 ms 2812 KB Time limit exceeded
23 Execution timed out 3079 ms 2808 KB Time limit exceeded
24 Incorrect 1041 ms 2688 KB Wrong Answer [3]
25 Execution timed out 3016 ms 2808 KB Time limit exceeded
26 Execution timed out 3071 ms 2688 KB Time limit exceeded
27 Incorrect 989 ms 2688 KB Wrong Answer [3]
28 Execution timed out 3022 ms 2688 KB Time limit exceeded
29 Execution timed out 3087 ms 2688 KB Time limit exceeded
30 Execution timed out 3008 ms 2688 KB Time limit exceeded