Submission #272886

# Submission time Handle Problem Language Result Execution time Memory
272886 2020-08-18T18:01:44 Z Kastanda Cup of Jamshid (IOI17_cup) C++11
100 / 100
2 ms 384 KB
// M
#include<bits/stdc++.h>
#include "cup.h"
using namespace std;

vector < int > find_cup()
{
        int K = 5e8;
        int Xor = ask_shahrasb(-K, -K);

        int LG = 30;

        vector < int > Rs = {0, 0};
        for (int i = 0; i < LG - 1; i ++)
        {
                int a = ask_shahrasb(-K - (1 << i), -K);
                int df = a ^ Xor;

                int lb = -1;
                for (int j = i; j < LG; j ++)
                        if (df >> j & 1)
                                lb = j;

                assert(lb != -1);
                for (int j = i; j < lb; j ++)
                        Rs[0] |= 1 << j;
                i = lb;
        }

        {
                int a2 = Rs[0] | (1 << (LG - 1)), b2 = a2 ^ Xor;
                a2 -= K; b2 -= K;

                int f1 = ask_shahrasb(a2 - 1, b2);
                //int f2 = ask_shahrasb(a2, b2);
                int f3 = ask_shahrasb(a2 + 1, b2);

                if (f1 == 1 && f3 == 1)
                        Rs[0] |= 1 << (LG - 1);
        }

        Rs[1] = Rs[0] ^ Xor;
        Rs[0] -= K;
        Rs[1] -= K;
        return Rs;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct