답안 #48119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48119 2018-05-10T05:40:46 Z ShaneOng 도서관 (JOI18_library) C++14
19 / 100
2000 ms 880 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

vector<int> ans,ans1,ans2,adjList[10009];
vector<bool> vis;
void dfs2(int u,int a){
    if(a==0)
        ans1.push_back(u);
    for(int x=0;x<(int)adjList[u].size();x++){
        int v=adjList[u][x];
        if(!vis[v]){
            vis[v]=true;
            dfs2(v,a);
        }

    }
    if(a==1)
        ans2.push_back(u);
}
void dfs1(int u){
    for(int x=0;x<(int)adjList[u].size();x++){
        int v=adjList[u][x];
        vis[v]=true;
        dfs2(v,x);

    }
    ans2.push_back(u);
}

void Solve(int N)
{
	vector<int> M(N),arr(N,0);

	for(int i = 0; i < N; i++) {
        if(arr[i]==2)
            continue;
        M[i] = 1;
        for(int j=i+1;j<N;j++){
            if(arr[i]==2)
                break;
            if(arr[j]==2)
                continue;
            M[j] = 1;
            int A = Query(M);
            M[j]=0;
            if(A==1){
                adjList[i].push_back(j);
                adjList[j].push_back(i);
                arr[i]++;
                arr[j]++;
            }

        }
        M[i]=0;
	}
	vis.assign(N,false);
	vis[0]=true;
    dfs1(0);
	for(int x:ans2){
        ans.push_back(x+1);
        //printf("%d ",x);
	}
    for(int x:ans1){
        ans.push_back(x+1);
        //printf("%d ",x);
	}
	//printf("\n");
	Answer(ans);


}
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 632 KB Output is correct
2 Correct 127 ms 728 KB Output is correct
3 Correct 143 ms 728 KB Output is correct
4 Correct 145 ms 800 KB Output is correct
5 Correct 136 ms 800 KB Output is correct
6 Correct 130 ms 800 KB Output is correct
7 Correct 149 ms 800 KB Output is correct
8 Correct 141 ms 800 KB Output is correct
9 Correct 101 ms 880 KB Output is correct
10 Correct 49 ms 880 KB Output is correct
11 Correct 2 ms 880 KB Output is correct
12 Correct 2 ms 880 KB Output is correct
13 Correct 2 ms 880 KB Output is correct
14 Correct 2 ms 880 KB Output is correct
15 Correct 2 ms 880 KB Output is correct
16 Correct 6 ms 880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 632 KB Output is correct
2 Correct 127 ms 728 KB Output is correct
3 Correct 143 ms 728 KB Output is correct
4 Correct 145 ms 800 KB Output is correct
5 Correct 136 ms 800 KB Output is correct
6 Correct 130 ms 800 KB Output is correct
7 Correct 149 ms 800 KB Output is correct
8 Correct 141 ms 800 KB Output is correct
9 Correct 101 ms 880 KB Output is correct
10 Correct 49 ms 880 KB Output is correct
11 Correct 2 ms 880 KB Output is correct
12 Correct 2 ms 880 KB Output is correct
13 Correct 2 ms 880 KB Output is correct
14 Correct 2 ms 880 KB Output is correct
15 Correct 2 ms 880 KB Output is correct
16 Correct 6 ms 880 KB Output is correct
17 Execution timed out 2031 ms 880 KB Time limit exceeded
18 Halted 0 ms 0 KB -