Submission #908281

#TimeUsernameProblemLanguageResultExecution timeMemory
908281shoryu386Coreputer (IOI23_coreputer)C++17
20 / 100
1 ms500 KiB
#include "coreputer.h" #include <bits/stdc++.h> using namespace std; vector<int> ntwo(){ int res = run_diagnostic({0}); if (res == 1){ return {1, 0}; } else if (res == 0){ int any = run_diagnostic({0, 1}); if (any == 0){ return {0, 0}; } else return {1, 1}; } else return {0, 1}; } vector<int> malfunctioning_cores(int N) { if (N == 2){ return ntwo(); } //if malfunctioning cores is even int results[16]; for (int x = 0; x < 16; x++){ vector<int> bruh; for (int y = 0; y <= x; y++) bruh.push_back(y); results[x] = run_diagnostic(bruh); } int firstZero = -1, lastZero = -1; for (int x = 0; x < 16; x++){ if (results[x] == 0){ if (firstZero == -1) firstZero = x; lastZero = x; } } assert(lastZero != -1); //even case assert(not (firstZero == 0 && lastZero == 15)); //cerr << firstZero << ' ' << lastZero << '\n'; //our malfunctions are at firstZero, and lastZero+1 //we also now know that there are an equal number of malfunctions in the two segments [0, firstZero-1] and [lastZero+2, 15] vector<int> ans(16, 0); ans[firstZero] = 1; ans[lastZero+1] = 1; for (int x = 15; x > lastZero+1; x--){ //include [0, firstZero], include [lastZero+1, 15], except one element vector<int> cur; #define ADDRANGE(a, b) for (int y = a; y <= b; y++) cur.push_back(y); ADDRANGE(0, firstZero); //ADDRANGE(lastZero+1, 15); //cur.erase(find(cur.begin(), cur.end(), x)); ADDRANGE(x, x); int res = run_diagnostic(cur); //cerr << "\n run: \n"; //for (auto y : cur) cerr << y << ' '; //cerr << '\n'; //cerr << res << '\n'; if (res == 0){ ans[x] = 0; } else ans[x] = 1; } for (int x = 0; x < firstZero; x++){ //include [0, firstZero], exclude [lastZero+1, 15], except one element vector<int> cur; #define ADDRANGE(a, b) for (int y = a; y <= b; y++) cur.push_back(y); //ADDRANGE(0, firstZero); ADDRANGE(lastZero+1, 15); ADDRANGE(x, x); //cur.erase(find(cur.begin(), cur.end(), x)); int res = run_diagnostic(cur); if (res == 0){ ans[x] = 0; } else ans[x] = 1; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...