Submission #148139

#TimeUsernameProblemLanguageResultExecution timeMemory
148139WhipppedCreamCup of Jamshid (IOI17_cup)C++17
0 / 100
3 ms376 KiB
#include "cup.h" #include <bits/stdc++.h> using namespace std; int ask(int a, int b) { return ask_shahrasb(a, b); } const int maxn = 28; vector<int> find_cup() { vector<int> result(2); int mulx, muly; mulx = muly = 1; int base = ask(0, 0); int check1 = ask((1<<29)-1, 0); int check2 = ask(0, (1<<29)-1); if(check1 & (1<<29)) mulx = -1; if(check2 & (1<<29)) muly = -1; int resx, resy; resx = resy = 0; //check for the case where x = 0 //printf("*%d %d\n", mulx, muly); int temp = ask(-mulx*((1<<29)-1), 0); if((temp&(1<<29)) == 0) { //x = 0 result[0] = 0; result[1] = muly*base; return result; } for(int i = maxn; i>= 0; i--) { //make everything subtraction! int res = ask(mulx*(resx+(1<<i)), muly*(resy)); //the 1 bit always yield 0 no matter what if((1<<i)&res) { //this bit of yis 1 resy += (1<<i); if(((1<<i)&base) == 0) { resx += (1<<i); } } else { if((1<<i)&base) { resx += (1<<i); } } } result[0] = mulx*resx; result[1] = muly*resy; return result; }
#Verdict Execution timeMemoryGrader output
Fetching results...