Submission #991276

#TimeUsernameProblemLanguageResultExecution timeMemory
991276abczzBroken Device (JOI17_broken_device)C++14
100 / 100
31 ms2944 KiB
#include "Annalib.h" #include <iostream> #include <random> #include <vector> #include <algorithm> #define ll long long using namespace std; void Anna( int N, long long X, int K, int P[] ){ mt19937_64 mt(69); ll perm[150]; for (int i=0; i<N; ++i) { perm[i] = i; } shuffle(perm, perm+N, mt); bool B[150], F[150]; for (int i=0; i<N; ++i) B[i] = F[i] = 0; for (int i=0; i<K; ++i) B[P[i]] = 1; for (int i=0; i<N; i+=2) { ll cur = X % 3; if (B[perm[i]] && B[perm[i+1]]) continue; else if (B[perm[i]] && (cur == 1 || cur == 2)) continue; else if (B[perm[i+1]] && (!cur || cur == 2)) continue; X /= 3; if (!cur) F[perm[i+1]] = 1; else if (cur == 1) F[perm[i]] = 1; else F[perm[i]] = F[perm[i+1]] = 1; if (!X) break; } for (int i=0; i<N; ++i) { Set(i, F[i]); } }
#include "Brunolib.h" #include <iostream> #include <vector> #include <random> #include <algorithm> #define ll long long using namespace std; long long Bruno( int N, int A[] ){ mt19937_64 mt(69); ll x = 0, s = 1; ll perm[150]; for (int i=0; i<N; ++i) { perm[i] = i; } shuffle(perm, perm+N, mt); for (int i=0; i<N; i+=2) { if (A[perm[i]] && A[perm[i+1]]) { x += s * 2; s *= 3; } else if (A[perm[i]]) { x += s; s *= 3; } else if (A[perm[i+1]]) { s *= 3; } } return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...