Submission #1078432

#TimeUsernameProblemLanguageResultExecution timeMemory
1078432antonBroken Device (JOI17_broken_device)C++17
85 / 100
30 ms3028 KiB
#include "Annalib.h" #include<bits/stdc++.h> using namespace std; #define ll long long int N; ll X; void Anna( int _N, long long _X, int K, int P[] ){ N = _N; X = _X; vector<int> base3; while(X>0){ base3.push_back(X%3LL); X/=3LL; } vector<bool> broken(N, false); for(int i = 0; i<K; i++){ broken[P[i]] = true; } vector<int> res(N); auto mySet = [&](int pos, int val){ if(pos<N){ res[pos] = val; } }; for(int i = 0; i<N; i++){ if(broken[i]){ broken[i^1] = true; } } vector<int> info_bits; for(auto e: base3){ if(e==0){ info_bits.push_back(0); info_bits.push_back(1); } else if(e==1){ info_bits.push_back(1); info_bits.push_back(0); } else if(e==2){ info_bits.push_back(1); info_bits.push_back(1); } } reverse(info_bits.begin(), info_bits.end()); for(int i =0; i<N; i++){ if(!broken[i] && info_bits.size()>0){ res[i] = info_bits.back(); info_bits.pop_back(); } } for(int i = 0; i<N; i++){ Set(i, res[i]); if(!broken[i]){ } } }
#include "Brunolib.h" #include<bits/stdc++.h> using namespace std; #define ll long long long long Bruno( int N, int A[] ){ vector<ll> bits; for(int i = 0; i<N; i+=2){ if(A[i]>0 || A[i+1]>0){ bits.push_back(A[i]); bits.push_back(A[i+1]); } } ll res= 0; vector<int> base3; for(int i = 0; i<bits.size(); i+=2){ if(bits[i] == 0 && bits[i+1] == 0){ } else{ if(bits[i] == 0 && bits[i+1] == 1){ base3.push_back(0); } if(bits[i] == 1&& bits[i+1] == 0){ base3.push_back(1); } if(bits[i] == 1 && bits[i+1] == 1){ base3.push_back(2); } } } ll X= 0; while(base3.size()>0){ X*=3LL; X += (ll)(base3.back()); base3.pop_back(); } return X; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:28:8: warning: variable 'mySet' set but not used [-Wunused-but-set-variable]
   28 |   auto mySet = [&](int pos, int val){
      |        ^~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:20:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i = 0; i<bits.size(); i+=2){
      |                  ~^~~~~~~~~~~~
Bruno.cpp:15:6: warning: unused variable 'res' [-Wunused-variable]
   15 |   ll res= 0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...