Submission #55102

#TimeUsernameProblemLanguageResultExecution timeMemory
55102ksun48Broken Device (JOI17_broken_device)C++14
85 / 100
92 ms3904 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 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()); for(int j = 0; j < num.size() && j < usable.size(); j++){ int a = usable[j]; message[2*a] = num[j] / 2; message[2*a+1] = num[j] % 2; } // ---------------------------------- 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 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++){
                 ~~^~~~~~~~~~~~~~~~
Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:57:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j = 0; j < num.size() && j < usable.size(); j++){
                 ~~^~~~~~~~~~~~
Anna.cpp:57:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j = 0; j < num.size() && j < usable.size(); j++){
                                   ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...