Submission #1159548

#TimeUsernameProblemLanguageResultExecution timeMemory
1159548PagodePaivaShopping (JOI21_shopping)C++20
0 / 100
71 ms12408 KiB
#include "Anna.h" #include <vector> #include<bits/stdc++.h> using namespace std; namespace { int N, L, R; int count; std::vector <int> valores; int v[220]; int pos; } // namespace void InitA(int n, int l, int r) { L = l; R = r; int x = l/100; for(int bit = 0;bit < 7;bit++){ if(((1<<bit)&x)) SendA(true); else SendA(false); } x = r/100; for(int bit = 0;bit < 7;bit++){ if(((1<<bit)&x)) SendA(true); else SendA(false); } return; } void ReceiveA(bool x) { valores.push_back(x); } int Answer() { for(int i = 0;i < 200;i++){ v[i] = 0; for(int j = 0;j < 14;j++){ // // cout << valores[14*i+j] << ' '; if(valores[14*i+j] == 1) v[i] |= (1<<j); } } pos = 0; for(int i = 0;i < 14;i++){ if(valores[14*200+i] == 1) pos |= (1<<i); } int ans = v[200]; // cout << ans << ' '; int d = L%100; if((L/100) == (R/100)){ int d2 = R%100; // cout << d << ' ' << d2 << endl; for(int i = d;i <= d2;i++){ // cout << v[i] << ' '; if(ans > v[i]){ ans = v[i]; pos = (L/100)*100+i; } } // cout << pos << endl; return pos; } for(int i = d;i < 100;i++){ if(ans > v[i]){ ans = v[i]; pos = (L/100)*100+i; } } d = R%100; for(int i = 100;i <= 100+d;i++){ if(ans > v[i]){ ans = v[i]; pos = (R/100)*100+(i-100); } } // cout << pos << endl; return pos; }
#include "Bruno.h" #include <vector> #include<bits/stdc++.h> using namespace std; namespace { int N; int v[1000000]; int count; std::vector <int> valores; bool FunctionExample(bool P) { return !P; } } // namespace void InitB(int N, std::vector<int> P) { ::N = N; for(int i = 0; i < N; i++) { v[i] = P[i]; } for(int i = N;i < 1000000;i++){ v[i] = 0; } } void enviar(int x){ for(int j = 0;j < 14;j++){ if(((1<<j)&x)) SendB(true); else SendB(false); } } void ReceiveB(bool y) { valores.push_back(y); if(valores.size() == 14){ for(auto x : valores){ // cout << x << ' '; } // cout << endl; int l = 0; for(int i = 0;i < 7;i++){ if(valores[i]) l |= (1<<i); } int r = 0; for(int i = 7;i < 14;i++){ if(valores[i]) r |= (1<<(i-7)); } //// cout << l << ' ' << r << endl; int t = l/100; t *= 100; for(int i = t;i < t+100;i++){ enviar(v[i]); } t = r/100; t *= 100; for(int i = t;i < t+100;i++){ enviar(v[i]); } int ans = (1<<14)-1, pos = 0; for(int i = (l/100+1)*100;i < (r/100)*100;i++){ if(ans > v[i]){ ans = v[i]; pos = i; } } enviar(ans); enviar(pos); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...