답안 #1103202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103202 2024-10-20T13:37:06 Z horiaboeriu Mouse (info1cup19_mouse) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int MAXN = 256;
const int MOD = 2007;
int v[MAXN + 1], vrez[MAXN];
set<int> cand[MAXN + 1];
vector<int> q;
set<int> fr;
int rez2;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
static inline unsigned int genrand() {
  return uniform_int_distribution<unsigned int>(0, (unsigned int)-1)(rng);
}
void solve(int n) {
    int i, j, x, rez;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            cand[i].insert(j);
        }
    }
    for (i = 1; i <= n; i++) {
        while ((int)cand[i].size() > 1) {
            fr.clear();
            for (j = 1; j <= n; j++) {
                fr.insert(j);
            }
            q.clear();
            for (j = 1; j < i; j++) {
                q.push_back(v[j]);
                fr.erase(v[j]);
            }

            x = genrand() % n + 1;
            auto poz = cand[i].lower_bound(x);
            if (poz == cand[i].end()) {
                poz--;
            }
            q.push_back(*poz);//candidat random
            fr.erase(q[i - 1]);
            //in q sunt indexate de la 0
            for (j = i + 1; j <= n; j++) {
                x = genrand() % n + 1;
                auto poz = fr.lower_bound(x);
                if (poz == fr.end()) {
                    poz--;
                }
                x = *poz;
                q.push_back(x);
                fr.erase(x);
            }

            rez = query(q);
            rez2++;
            if (rez == i - 1) {
                //nu sunt pe pozitiile bune cei de la i la n
                for (j = i; j <= n; j++) {
                    cand[j].erase(q[j - 1]);
                }
            } else if (rez == n) {
                //am gasit permutarea
                for (j = 1; j <= n; j++) {
                    cand[j].clear();
                }
            }
        }

        v[i] = *cand[i].begin();
        for (j = i + 1; j <= n; j++) {
            cand[j].erase(v[i]);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct! Number of queries: 49
2 Correct 1 ms 336 KB Correct! Number of queries: 5
3 Correct 1 ms 336 KB Correct! Number of queries: 47
4 Correct 1 ms 336 KB Correct! Number of queries: 63
5 Incorrect 1 ms 336 KB Unexpected end of file - int32 expected
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct! Number of queries: 49
2 Correct 1 ms 336 KB Correct! Number of queries: 5
3 Correct 1 ms 336 KB Correct! Number of queries: 47
4 Correct 1 ms 336 KB Correct! Number of queries: 63
5 Incorrect 1 ms 336 KB Unexpected end of file - int32 expected
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct! Number of queries: 49
2 Correct 1 ms 336 KB Correct! Number of queries: 5
3 Correct 1 ms 336 KB Correct! Number of queries: 47
4 Correct 1 ms 336 KB Correct! Number of queries: 63
5 Incorrect 1 ms 336 KB Unexpected end of file - int32 expected
6 Halted 0 ms 0 KB -