Submission #565304

#TimeUsernameProblemLanguageResultExecution timeMemory
565304SortingBroken Device 2 (JOI22_device2)C++17
25 / 100
99 ms3592 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; static const int BITS = 60; static const int C = 3; int Declare() { return C * BITS; } pair<vector<int>, vector<int>> Anna(ll a) { vector<int> v1, v2; for(ll i = 0; i < C * BITS; i += 2){ v1.push_back(0); v1.push_back(1); } for(ll i = 0; i < BITS; ++i){ ll bit = (a >> i) & 1ll; for(ll j = 0; j < C; ++j) v2.push_back(bit); } return {v1, v2}; }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; static const int BITS = 60; static const int C = 3; ll Bruno(vector<int> u) { ll curr = 0, prefix = 0; vector<int> bits; for(ll i = 0; i < u.size(); ++i){ prefix += u[i] ? 1 : -1; if(prefix <= curr - C){ bits.push_back(0); curr -= C; } else if(prefix >= curr + C - 1){ bits.push_back(1); curr += C; } } ll ans = 0; for(ll i = 0; i < bits.size(); ++i) ans += bits[i] << i; assert(bits.size() == BITS); return ans; }

Compilation message (stderr)

Bruno.cpp: In function 'll Bruno(std::vector<int>)':
Bruno.cpp:14:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(ll i = 0; i < u.size(); ++i){
      |                   ~~^~~~~~~~~~
Bruno.cpp:28:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(ll i = 0; i < bits.size(); ++i)
      |                   ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...