답안 #48108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48108 2018-05-10T05:21:18 Z rocketninja7 도서관 (JOI18_library) C++14
0 / 100
297 ms 428 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

void Solve(int N)
{
    pair<int, int> neighbour[N+1];
    for(int i=1;i<N+1;i++){
        neighbour[i].first=-1;
        neighbour[i].second=-1;
    }
	for(int i=1;i<N+1;i++) {
		for(int j=1;j<N+1;j++){
            if(i==j){
                continue;
            }
            vector<int> M(N);
            M[i]=1;
            M[j]=1;
            if(Query(M)==1){
                if(neighbour[i].first==-1){
                    neighbour[i].first=j;
                }
                else{
                    neighbour[i].second=j;
                }
                if(neighbour[j].first==-1){
                    neighbour[j].first=i;
                }
                else{
                    neighbour[j].second=i;
                }
            }
		}
	}

	vector<int> res(N);

	for(int i=1;i<N+1;i++){
        if(neighbour[i].second==-1){
            res[0]=i;
            break;
        }
	}
	if(neighbour[res[0]].first!=-1){
        res[1]=neighbour[res[0]].first;
	}
	for(int i=2;i<N;i++){
        if(neighbour[res[i-1]].first==res[i-2]){
            res[i]=neighbour[res[i-1]].second;
        }
        else{
            res[i]=neighbour[res[i-1]].first;
        }
	}

	Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 297 ms 428 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 297 ms 428 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -