Submission #47838

# Submission time Handle Problem Language Result Execution time Memory
47838 2018-05-08T05:59:33 Z Inovak Library (JOI18_library) C++14
19 / 100
554 ms 580 KB
#include <bits/stdc++.h>
#include "library.h"
//#include "grader.cpp"

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

bool u[3000];

void Solve(int n)
{
	vector<int> M(n);
    deque <int> dq;
    dq.pb(1);
    u[0] = 1;
    M[0] = 1;
    int ans = -1, anb = -1;

    for(int i = 0; i < n; i++) {
        if(u[i]) continue;
        M[i] = 1;
        int A = Query(M);
        if(A == 1 && ans == -1) ans = i;
        else if(A == 1) anb = i;
        M[i] = 0;
    }
    M[0] = 0;
    if(n > 1) {
        u[ans] = 1;
        dq.pb(ans + 1);
    }

    while(dq.size() < n) {
        M[ans] = 1;
        int an = -1;
        for(int i = 0; i < n; i++) {
            if(u[i]) continue;
            M[i] = 1;
            int A = Query(M);
            M[i] = 0;
            if(A == 1) an = i;
        }
        M[ans] = 0;
        if(an == -1) break;
        u[an] = 1;
        ans = an;
        dq.pb(ans + 1);
    }
    if(dq.size() < n) {
        ans = anb;
        u[ans] = 1;
        dq.push_front(ans + 1);

        while(dq.size() < n) {
            M[ans] = 1;
            int an = -1;
            for(int i = 0; i < n; i++) {
                if(u[i]) continue;
                M[i] = 1;
                int A = Query(M);
                M[i] = 0;
                if(A == 1) an = i;
            }
            M[ans] = 0;
            if(an == -1) break;
            u[an] = 1;
            ans = an;
            dq.push_front(ans + 1);
        }
    }
    vector <int> res;
    while(!dq.empty())
        res.pb(dq.front()), dq.pop_front();
    Answer(res);
}
/**
5
4 2 5 3 1
**/

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(dq.size() < n) {
           ~~~~~~~~~~^~~
library.cpp:57:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(dq.size() < n) {
        ~~~~~~~~~~^~~
library.cpp:62:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(dq.size() < n) {
               ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 222 ms 376 KB Output is correct
2 Correct 268 ms 376 KB Output is correct
3 Correct 309 ms 408 KB Output is correct
4 Correct 326 ms 540 KB Output is correct
5 Correct 292 ms 540 KB Output is correct
6 Correct 304 ms 540 KB Output is correct
7 Correct 289 ms 540 KB Output is correct
8 Correct 263 ms 540 KB Output is correct
9 Correct 330 ms 540 KB Output is correct
10 Correct 115 ms 540 KB Output is correct
11 Correct 2 ms 540 KB Output is correct
12 Correct 2 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 3 ms 580 KB Output is correct
16 Correct 7 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 222 ms 376 KB Output is correct
2 Correct 268 ms 376 KB Output is correct
3 Correct 309 ms 408 KB Output is correct
4 Correct 326 ms 540 KB Output is correct
5 Correct 292 ms 540 KB Output is correct
6 Correct 304 ms 540 KB Output is correct
7 Correct 289 ms 540 KB Output is correct
8 Correct 263 ms 540 KB Output is correct
9 Correct 330 ms 540 KB Output is correct
10 Correct 115 ms 540 KB Output is correct
11 Correct 2 ms 540 KB Output is correct
12 Correct 2 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 3 ms 580 KB Output is correct
16 Correct 7 ms 580 KB Output is correct
17 Incorrect 554 ms 580 KB Wrong Answer [3]
18 Halted 0 ms 0 KB -