Submission #1226600

#TimeUsernameProblemLanguageResultExecution timeMemory
1226600salmonBroken Device (JOI17_broken_device)C++20
100 / 100
28 ms1552 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; /* 0 0 1 -> 0 0 1 0 -> 10 1 0 0 -> 1 0 1 1 -> 11 1 1 0 -> 0 1 0 1 -> 00 1 1 1 -> 01 */ namespace{ void pack(int i,vector<int>v){ for(int k = 0; k < 3; k++) Set(i * 3 + k, v[k]); } } void Anna( int N, long long X, int K, int P[] ){ bool die[150]; bool send[100 + 5]; for(int i = 0; i < N; i++) die[i] = false; for(int i = 0; i < K; i++){ die[P[i]] = true; } for(int i = 0; i<= 100; i++) send[i] = 0; for(int i = 0; i < 60; i++){ send[i] = ((X&(1LL<<i))>0); } int cont = 0; for( int i = 0; i < 50; i++ ){ if(die[i * 3] + die[i * 3 + 1] + die[i * 3 + 2] >= 2){ pack(i,{0,0,0}); continue; } if(die[i * 3] + die[i * 3 + 1] + die[i * 3 + 2] == 1){ if(die[i * 3]){ if(!send[cont]){ Set(i * 3,0); Set(i * 3 + 1,0); Set(i * 3 + 2,1); cont++; } else{ Set(i * 3,0); Set(i * 3 + 1,1); if(send[cont+1]) Set(i * 3 + 2,1); else Set(i * 3 + 2,0); cont+=2; } } else if(die[i * 3 + 1]){ if(send[cont]){ Set(i * 3,1); Set(i * 3 + 1,0); Set(i * 3 + 2,0); cont++; } else{ Set(i * 3,0); Set(i * 3 + 1,0); Set(i * 3 + 2,1); cont++; } } else if(die[i * 3 + 2]){ Set(i * 3,1); Set(i * 3 + 1,!send[cont]); Set(i * 3 + 2,0); cont++; } } else if(die[i * 3] + die[i * 3 + 1] + die[i * 3 + 2] == 0){ if(!send[cont] && !send[cont + 1]){ pack(i,vector<int>({1,0,1})); } if(!send[cont] && send[cont + 1]){ pack(i,{1,1,1}); } if(send[cont] && !send[cont + 1]){ pack(i,{0,1,0}); } if(send[cont] && send[cont + 1]){ pack(i,{0,1,1}); } cont+=2; } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; /* 0 0 1 -> 0 0 1 0 -> 10 1 0 0 -> 1 0 1 1 -> 11 1 1 0 -> 0 1 0 1 -> 00 1 1 1 -> 01 */ namespace{ vector<int> v; void decode(vector<int> v1){ if(v1 == vector<int>({0,0,1})) v.push_back(0); if(v1 == vector<int>({0,1,0})){ v.push_back(1); v.push_back(0);} if(v1 == vector<int>({1,0,0})) v.push_back(1); if(v1 == vector<int>({0,1,1})){ v.push_back(1); v.push_back(1);} if(v1 == vector<int>({1,1,0})) v.push_back(0); if(v1 == vector<int>({1,0,1})){ v.push_back(0); v.push_back(0);} if(v1 == vector<int>({1,1,1})){ v.push_back(0); v.push_back(1);} } } long long Bruno( int N, int A[] ){ v.clear(); for(int i = 0; i < 50; i++){ if(A[i * 3] + A[i * 3 + 1] + A[i * 3 + 2] == 0) continue; decode({A[i * 3], A[i * 3 + 1], A[i * 3 + 2]}); } long long int ans = 0; for(int i = 0; i < 60 ; i++){ if(v[i]) ans |= (1LL<<i); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...