Submission #48112

# Submission time Handle Problem Language Result Execution time Memory
48112 2018-05-10T05:28:22 Z jeff Library (JOI18_library) C++14
0 / 100
44 ms 600 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

vector<vector<int> > adj;
vector<int> M, res, nv;

void Solve(int N) {
    int l, r, m, c, d, e, s, t = 0, z, i, j;
    for (i = 0; i < N; ++i) adj.push_back(nv), M.push_back(0), res.push_back(-1);
    for (i = 0; i < N; ++i) {
        ++t;
        if (!i) continue;
        for (j = 0; j < M.size(); ++j) M[j] = 0;
        for (j = 0; j < i + 1; ++j) M[j] = 1;
        for (c = Query(M); c < t; --t) {
            l = 0;
            r = i - 1;
            while (l < r) {
                m = (l + r) / 2;
                for (j = s = 0; j < M.size(); ++j) M[j] = 0;
                for (j = l; j < m + 1; ++j) s += M[j] = j != z;
                assert(s);
                d = Query(M);
                M[i] = 1;
                e = Query(M);
                (e < d + 1 ? r : l) = m + (e > d);
            }
            z = (l + r) / 2;
            adj[i].push_back(z);
            adj[z].push_back(i);
        }
        z = -1;
    }
    for (i = 0; i < N; ++i) if (adj[i].size() <= 1) {
        for (j = 0, c = i, t = -1; j < N - 1; ++j) {
            res[j] = c;
            if (adj[c][0] != t) c = adj[t = c][0];
            else c = adj[t = c][1];
        }
        res[j] = c;
        break;
    }
    for (i = 0; i < N; ++i) ++res[i];
    Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < M.size(); ++j) M[j] = 0;
                     ~~^~~~~~~~~~
library.cpp:21:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (j = s = 0; j < M.size(); ++j) M[j] = 0;
                                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 44 ms 312 KB Output is correct
2 Correct 31 ms 352 KB Output is correct
3 Runtime error 7 ms 600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 312 KB Output is correct
2 Correct 31 ms 352 KB Output is correct
3 Runtime error 7 ms 600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -