Submission #55112

#TimeUsernameProblemLanguageResultExecution timeMemory
55112ksun48Broken Device (JOI17_broken_device)C++14
100 / 100
77 ms4096 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; typedef long long LL; void done(vector<LL> message, vector<LL> perm){ for(int i = 0; i < message.size(); i++){ Set(i, message[perm[i]]); } } void Anna(int N, long long X, int K, int P[]){ // shared initialization static mt19937_64 mt1(4848); static mt19937_64 mt2(48222); static LL B = 60; LL Y = mt1() & ((1LL << B) - 1); vector<LL> perm(N); for(int i = 0; i < N; i++){ perm[i] = i; } for(int i = N-1; i >= 0; i--){ int d = mt2() % (i+1); if(d < 0){ d += (i+1); } swap(perm[i], perm[d]); } // shared initialization Y = 0; X ^= Y; vector<LL> message(N, 0); // boilerplate // ---------------------------------- vector<LL> bad(N, 0); for(int i = 0; i < K; i++){ bad[perm[P[i]]] = 1; } vector<LL> usable; for(int i = 0; i * 2 < N; i++){ if(!bad[2*i] && !bad[2*i+1]){ usable.push_back(i); } } // 01 10 11 vector<LL> num; for(int i = 0; i < 38; i++){ num.push_back(1 + (X % 3)); X /= 3; } reverse(num.begin(), num.end()); int r = 0; for(int j = 0; j < 75; j++){ if(r == 38) continue; int a = num[r] / 2; int b = num[r] % 2; if(a == 1 && bad[2*j]) continue; if(b == 1 && bad[2*j+1]) continue; message[2*j] = a; message[2*j+1] = b; r++; } // ---------------------------------- done(message, perm); }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; typedef long long LL; using namespace std; long long Bruno(int N, int A[]){ // shared initialization static mt19937_64 mt1(4848); static mt19937_64 mt2(48222); static LL B = 60; LL Y = mt1() & ((1LL << B) - 1); vector<LL> perm(N); for(int i = 0; i < N; i++){ perm[i] = i; } for(int i = N-1; i >= 0; i--){ int d = mt2() % (i+1); if(d < 0){ d += (i+1); } swap(perm[i], perm[d]); } // shared initialization Y = 0; vector<LL> message(N); for(int i = 0; i < N; i++){ message[perm[i]] = A[i]; } // boilerplate // ---------------------------------- LL X = 0; for(int i = 0; i * 2 < N; i++){ if(message[2*i] == 0 && message[2*i+1] == 0) continue; LL r = message[2*i] * 2 + message[2*i+1] - 1; X = (X * 3 + r); } // ---------------------------------- return X ^ Y; }

Compilation message (stderr)

Anna.cpp: In function 'void done(std::vector<long long int>, std::vector<long long int>)':
Anna.cpp:7:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < message.size(); i++){
                 ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...