답안 #582142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
582142 2022-06-23T12:30:53 Z YaserFaisal 도서관 (JOI18_library) C++14
0 / 100
284 ms 284 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

void Solve(int n)
{
    
	vector < int > ans , v(n,0) , cur ;
    
    for ( int i = 0 ; i < n ; i++ )
    {
        int sum = 0 ; 
        for ( int j = 0 ; j < n ; j++ )
        {
            if ( i == j ) continue;
            cur = v ;
            cur[i] = cur[j] = 1 ;
            if ( Query(cur) == 1 ) sum++ ;
        }
        if ( sum == 1 ) { ans.push_back(i+1) ; break ; }
    }
    
    for ( int j = 1 ; j < n ; j++ )
    {
        v[ans[ans.size()-1]-1] = 1 ;
        for ( int i = 0 ; i < n ; i++ )
        {
            if ( v[i] == 1 ) continue;
            cur = v ;
            cur[i] = 1 ;
            if ( Query(cur) == 1 )
            {
                ans.push_back(i+1) ;
                break ;
            }
        }
    }
    Answer(ans) ;
}
// Query(x) , x : where x is a vector with 0 or 1 
// Answer(x) . x : where x is a vector with number from 1 -> n 
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 276 KB # of queries: 12617
2 Runtime error 284 ms 284 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 276 KB # of queries: 12617
2 Runtime error 284 ms 284 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -