Submission #994861

# Submission time Handle Problem Language Result Execution time Memory
994861 2024-06-08T07:46:51 Z Aiperiii Library (JOI18_library) C++14
19 / 100
356 ms 600 KB
#include <bits/stdc++.h>
#include "library.h"
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
void Solve(int N){
    vector <int> g[N+1];
    vector <int> x(N),res,used(N+1);
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(i!=j && g[i].size()<2 && g[j].size()<2){
                x[i-1]=1;x[j-1]=1;
                if(g[i].size()==0 or g[i][0]!=j){
                    if(Query(x)==1){
                        g[i].pb(j);
                        g[j].pb(i);
                    }
                }
                x[i-1]=0;x[j-1]=0;
            }
        }
    }
    int st=1,cnt=1;
    for(int i=1;i<=N;i++){
        if(g[i].size()==1)st=i;
    }
    res.pb(st);
    used[st]=1;
    while(res.size()<N){
        for(auto x : g[st]){
            if(!used[x]){
                res.pb(x);
                used[x]=1;
                st=x;
            }
        }
    }
    Answer(res);
}





Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:31:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     while(res.size()<N){
      |           ~~~~~~~~~~^~
library.cpp:25:14: warning: unused variable 'cnt' [-Wunused-variable]
   25 |     int st=1,cnt=1;
      |              ^~~
# Verdict Execution time Memory Grader output
1 Correct 98 ms 420 KB # of queries: 8402
2 Correct 121 ms 416 KB # of queries: 8304
3 Correct 116 ms 600 KB # of queries: 9243
4 Correct 88 ms 440 KB # of queries: 9276
5 Correct 106 ms 416 KB # of queries: 9348
6 Correct 109 ms 420 KB # of queries: 8916
7 Correct 113 ms 420 KB # of queries: 9149
8 Correct 90 ms 416 KB # of queries: 8441
9 Correct 117 ms 436 KB # of queries: 9342
10 Correct 43 ms 436 KB # of queries: 3938
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 1
13 Correct 1 ms 344 KB # of queries: 4
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 69
16 Correct 2 ms 344 KB # of queries: 220
# Verdict Execution time Memory Grader output
1 Correct 98 ms 420 KB # of queries: 8402
2 Correct 121 ms 416 KB # of queries: 8304
3 Correct 116 ms 600 KB # of queries: 9243
4 Correct 88 ms 440 KB # of queries: 9276
5 Correct 106 ms 416 KB # of queries: 9348
6 Correct 109 ms 420 KB # of queries: 8916
7 Correct 113 ms 420 KB # of queries: 9149
8 Correct 90 ms 416 KB # of queries: 8441
9 Correct 117 ms 436 KB # of queries: 9342
10 Correct 43 ms 436 KB # of queries: 3938
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 1
13 Correct 1 ms 344 KB # of queries: 4
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 69
16 Correct 2 ms 344 KB # of queries: 220
17 Runtime error 356 ms 440 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -