Submission #999133

#TimeUsernameProblemLanguageResultExecution timeMemory
999133AdamGSBroken Device (JOI17_broken_device)C++17
100 / 100
37 ms2888 KiB
#include "Annalib.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() void Anna(int n, ll x, int k, int P[]) { vector<ll>A={-1, 0, 1, 2, 0, 1, 1, 3}, B={-1, 4, 2, 4, 2, 2, 4, 4}; vector<int>czy(n), T(n); rep(i, k) czy[P[i]]=1; ll akt=0; for(int i=0; i<n; i+=3) { int s=czy[i]+czy[i+1]+czy[i+2]; if(s>=2) continue; ll a=x%4; bool ok=false; rep(j, 8) if(A[j]==a && B[j]==4) { bool ok2=true; rep(l, 3) if(czy[i+l] && (j&(1<<l))) ok2=false; if(!ok2) continue; rep(l, 3) if(j&(1<<l)) T[i+l]=1; ok=true; x/=4; break; } if(ok) continue; a=x%2; rep(j, 8) if(A[j]==a && B[j]==2) { bool ok2=true; rep(l, 3) if(czy[i+l] && (j&(1<<l))) ok2=false; if(!ok2) continue; rep(l, 3) if(j&(1<<l)) T[i+l]=1; ok=true; x/=2; break; } } rep(i, n) Set(i, T[i]); }
#include "Brunolib.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() ll Bruno(int n, int T[]) { vector<ll>A={-1, 0, 1, 2, 0, 1, 1, 3}, B={-1, 4, 2, 4, 2, 2, 4, 4}; ll x=0, p=1; for(int i=0; i<n; i+=3) { if(T[i]+T[i+1]+T[i+2]==0) continue; ll c=T[i]+2*T[i+1]+4*T[i+2]; x+=p*A[c]; p*=B[c]; } return x; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, ll, int, int*)':
Anna.cpp:14:6: warning: unused variable 'akt' [-Wunused-variable]
   14 |   ll akt=0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...