제출 #1262753

#제출 시각아이디문제언어결과실행 시간메모리
1262753niepamietamhaslaBroken Device (JOI17_broken_device)C++20
0 / 100
24 ms1344 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; void Anna(int n, ll x, int k, int* S){ vector<int> czy(n, 0); for(int i = 0; i < k; ++i){ czy[S[i]] = 1; } vector<int> P; for(int i = 0; i < n; ++i){ P.push_back(i); } unsigned seed = 5; shuffle (P.begin(), P.end(), default_random_engine(seed)); int it = 0; while(x > 0){ int reszta = x % 3; ll C = P[it]; ll N = P[it+1]; if(czy[C] == 0 and czy[N] == 0){ if(reszta == 2){ Set(C, 1); Set(N, 1); it+=2; } else if(reszta == 1){ Set(C, 1); Set(N, 0); it+=2; } else{ Set(C, 0); Set(N, 1); it+=2; } x /= 3; } else if(czy[C] == 0 and reszta == 1){ Set(C, 1); Set(N, 0); it += 2; x /= 3; } else if(czy[N] == 0 and reszta == 0){ Set(C, 0); Set(N, 1); it += 2; x /= 3; } else{ Set(C, 0); Set(N, 0); it += 2; } } while(it < n) { ll C = P[it]; Set(C, 0); ++it; } return; }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll Bruno(int n, int* A){ vector<int> P; for(int i = 0; i < n; ++i){ P.push_back(i); } unsigned seed = 5; shuffle (P.begin(), P.end(), default_random_engine(seed)); ll pot = 1; ll S = 0; for(int i = 0; i < n; i += 2){ if(A[i] == 0 and A[i+1] == 0){ continue; } else if(A[i] == 1 and A[i+1] == 1){ S += 2 * pot; pot *= 3; } else if(A[i] == 1){ S += pot; pot *= 3; } else{ pot *= 3; } } return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...