Submission #55043

#TimeUsernameProblemLanguageResultExecution timeMemory
55043spencercomptonBroken Device (JOI17_broken_device)C++17
69 / 100
113 ms3968 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; string tostr(ll x){ string ret = ""; for(int i = 0; i<60; i++){ if((x&(1LL<<i))!=0){ ret += "1"; } else{ ret += "0"; } } return ret; } void Anna( int N, long long X, int K, int P[] ){ srand(42); vector<int> rands; bool res[N]; for(int i = 0; i<N; i++){ res[i] = false; } for(int i = 0; i<1000; i++){ rands.push_back(rand()%2); } for(int i = 0; i<K; i++){ res[P[i]] = true; } string str = tostr(X); int pos = 0; int cur = 0; // if rands[i] = 0, 10 = 00, 11 = 01, 01 = 1 for(int i = 0; i<N && pos<60; i+=2){ if(res[i] || res[i+1]){ continue; } cur++; if(pos==59){ if(str[pos]=='0'){ res[i] = false; res[i+1] = true; } else{ res[i] = true; res[i+1] = true; } pos++; break; } if(str[pos]-'0'==rands[cur]){ res[i] = true; if(str[pos+1]-'0'==rands[cur]){ res[i+1] = true; } else{ res[i+1] = false; } pos += 2; } else{ res[i] = false; res[i+1] = true; pos++; } } for(int i = 0; i<N; i++){ Set(i,res[i]?1:0); } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll fromstr(string s){ ll ret = 0LL; for(int i = 0; i<60; i++){ if(s[i]=='1'){ ret += (1LL<<i); } } return ret; } long long Bruno( int N, int A[] ){ srand(42); vector<int> rands; for(int i = 0; i<1000; i++){ rands.push_back(rand()%2); } string str = ""; int pos = 0; int cur = 0; // if rands[i] = 0, 10 = 00, 11 = 01, 01 = 1 for(int i = 0; i<N && (int)str.length()<60; i+=2){ if(A[i]==0 && A[i+1]==0){ continue; } cur++; if((int)str.length()==59){ if(A[i]==0){ str += "0"; } else{ str += "1"; } break; } if(A[i]==1){ str += (char)(rands[cur]+'0'); if(A[i+1]==1){ str += (char)(rands[cur]+'0'); } else{ str += (char)((1-rands[cur])+'0'); } } else{ str += (char)((1-rands[cur])+'0'); } } return fromstr(str); }

Compilation message (stderr)

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:21:6: warning: unused variable 'pos' [-Wunused-variable]
  int pos = 0;
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...