Submission #1125994

#TimeUsernameProblemLanguageResultExecution timeMemory
1125994Kel_MahmutShopping (JOI21_shopping)C++20
0 / 100
94 ms12364 KiB
#include "Anna.h" #include <bits/stdc++.h> #define pb push_back #define endl ("\n") #define all(aa) aa.begin(), aa.end() typedef long long ll; using namespace std; namespace { int N, L, R; int cnt; int getcount; vector<int> v; const int blocksize = 512; void send_int(int x){ for(int i = 8; i >= 0; i--){ SendA((1 << i) & x); cnt++; } } } // namespace void InitA(int N, int L, int R) { ::N = N; ::L = L; ::R = R; getcount = cnt = 0; send_int(L / blocksize); send_int(R / blocksize); } void ReceiveA(bool x) { if(getcount % 22 == 0){ v.pb(0); } int cur = x; v.back() += (cur << (21 - (getcount % 22))); getcount++; } int Answer() { for(int i : v){ if(L <= i && i <= R) return i; } return -1; }
#include "Bruno.h" #include <bits/stdc++.h> #define pb push_back #define endl ("\n") #define all(aa) aa.begin(), aa.end() typedef long long ll; using namespace std; namespace { int N; vector<int> p; int cnt; int getcount; int bl, br; const int blocksize = 512; void send_index(int ind){ for(int i = 21; i >= 0; i--){ SendB((1 << i) & ind); cnt++; } } } // namespace void InitB(int N, std::vector<int> P) { ::N = N; p.resize(N); for(int i = 0; i < N; i++) { p[i] = P[i]; } cnt = 0; getcount = 0; bl = br = 0; } void ReceiveB(bool y) { int get = y; if(getcount <= 8){ bl += (get << (8 - getcount)); } else{ br += (get << (8 - (getcount - 9))); } getcount++; if(getcount == 18){ int minmid = -1; int mn = INT_MAX; for(int i = (bl + 1) * blocksize; i < min(N, br * blocksize); i++){ if(p[i] < mn){ mn = p[i]; minmid = i; } } vector<pair<int, int>> v; if(minmid != -1) v.pb({mn, minmid}); for(int i = bl * blocksize; i < min(N, (bl + 1) * blocksize); i++){ v.pb({p[i], i}); } for(int i = br * blocksize; i < min(N, (br + 1) * blocksize); i++){ v.pb({p[i], i}); } sort(all(v)); for(auto [val, ind] : v){ send_index(ind); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...