Submission #1103186

#TimeUsernameProblemLanguageResultExecution timeMemory
1103186horiaboeriuMouse (info1cup19_mouse)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; #define MAXN 256 int v[MAXN + 1]; set<int> cand[MAXN + 1]; vector<int> q; set<int> fr; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); static inline unsigned long long genrand() { return uniform_int_distribution<unsigned long long>(0, (unsigned long long)-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 (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; if (cand[i].lower_bound(x) == cand[i].end()) { q.push_back(*cand[i].lower_bound(x) - 1);//candidat random } else { q.push_back(*cand[i].lower_bound(x));//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; if (fr.lower_bound(x) == fr.end()) { x = *fr.lower_bound(x) - 1; } else { x = *fr.lower_bound(x); } q.push_back(x); fr.erase(x); } rez = query(q); 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]); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...