답안 #744264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744264 2023-05-18T10:09:54 Z MON 도서관 (JOI18_library) C++14
0 / 100
296 ms 408 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

void Solve(int N)
{
	vector<int> m(N,0); int queries = 0;
	vector<int> vecini[N + 1]; int luat[N] = {0};
	for(int i = 0 ; i < N - 1 ; i++)
        {
            for(int j = i + 1 ; j < N ; j++)
                {
                    m[i] = 1;
                    m[j] = 1;

                    int sunt = Query(m) & 1; queries++;
                    if(sunt) vecini[i].emplace_back(j),vecini[j].emplace_back(i);

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

    vector<int> ans; if(queries > 20000) return;
    for(int i = 0; i < N ; i++)
        {
            if(vecini[i].size() == 1)
                {
                    ans.emplace_back(i);
                    luat[i] = 1; break;
                }
        }

    while(ans.size() != N)
        {
            for(auto &it : vecini[ans.back()])
                {
                    if(!luat[it])
                        {
                            luat[it] = 1;
                            ans.emplace_back(it);
                            break;
                        }
                }
        }

    for(auto &it : ans) it++;
    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:35:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |     while(ans.size() != N)
      |           ~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 288 KB # of queries: 18336
2 Correct 198 ms 296 KB # of queries: 18145
3 Correct 223 ms 288 KB # of queries: 19900
4 Correct 287 ms 408 KB # of queries: 19900
5 Correct 216 ms 284 KB # of queries: 19900
6 Correct 295 ms 288 KB # of queries: 19900
7 Correct 260 ms 292 KB # of queries: 19900
8 Correct 191 ms 332 KB # of queries: 18528
9 Correct 296 ms 292 KB # of queries: 19701
10 Correct 110 ms 284 KB # of queries: 8256
11 Runtime error 1 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 288 KB # of queries: 18336
2 Correct 198 ms 296 KB # of queries: 18145
3 Correct 223 ms 288 KB # of queries: 19900
4 Correct 287 ms 408 KB # of queries: 19900
5 Correct 216 ms 284 KB # of queries: 19900
6 Correct 295 ms 288 KB # of queries: 19900
7 Correct 260 ms 292 KB # of queries: 19900
8 Correct 191 ms 332 KB # of queries: 18528
9 Correct 296 ms 292 KB # of queries: 19701
10 Correct 110 ms 284 KB # of queries: 8256
11 Runtime error 1 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -