Submission #70101482
Source Code Expand
//#include "atcoder/modint" #pragma GCC optimize("Ofast") #include "atcoder/all" #include <bits/stdc++.h> #include <string> using namespace std; using namespace atcoder; #define int long long template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } //const int MOD =1e9+7; //constexpr int MOD =10; constexpr int MOD =998244353; const long long M1=167772161,M2=469762049,M3=1224736769; //const int MOD =31607; //using mint = static_modint<MOD>; //using mint = double; using mint = modint; ostream& operator << (ostream& ost, const mint& m){ost << m.val();return ost;} istream& operator >> (istream& ost, mint& m){int a;ost >> a;m=a;return ost;} double time_limit = 100.0,start_temp=0.01,end_temp=0.0; std::mt19937 rng(std::random_device{}()); int solve(){ int c,x; cin>>c>>x; if((c^x)>x){ cout<<(c^x)<<endl; return 0; } int n=(1ll<<55); bool k=false; for(int i=0;i<55;i++){ if(!k){ if(bool(c&(1ll<<i))!=bool(x&(1ll<<i))){ cout<<-1<<endl; return 0; } if(bool(c&(1ll<<i)))k=true; }else{ if(bool(c&(1ll<<i))){ if(x&(1ll<<i)){ k=true; }else{ if(i!=0)n|=(1ll<<(i-1)); k=true; } }else{ if(x&(1ll<<i)){ if(i!=0)n|=(1ll<<(i-1)); k=true; }else{ k=false; } } } } if((c^(x+n))==n){ cout<<n<<endl; }else{ cout<<-1<<endl; } return 0; } signed main(){ //ios_base::sync_with_stdio(false); //cin.tie(NULL); int t; cin>>t; for(int i=0;i<t;i++)solve(); }
Submission Info
Submission Time | |
---|---|
Task | C - Mod of XOR |
User | yatuba |
Language | C++ 20 (gcc 12.2) |
Score | 700 |
Code Size | 1802 Byte |
Status | AC |
Exec Time | 343 ms |
Memory | 4068 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt |
All | 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3528 KiB |
01_handmade_00.txt | AC | 306 ms | 3536 KiB |
01_handmade_01.txt | AC | 282 ms | 3520 KiB |
01_handmade_02.txt | AC | 276 ms | 3728 KiB |
01_handmade_03.txt | AC | 252 ms | 3584 KiB |
01_handmade_04.txt | AC | 332 ms | 4024 KiB |
01_handmade_05.txt | AC | 322 ms | 4044 KiB |
02_random_00.txt | AC | 301 ms | 3596 KiB |
02_random_01.txt | AC | 300 ms | 3600 KiB |
02_random_02.txt | AC | 306 ms | 3452 KiB |
02_random_03.txt | AC | 305 ms | 3728 KiB |
02_random_04.txt | AC | 307 ms | 3536 KiB |
02_random_05.txt | AC | 301 ms | 3584 KiB |
02_random_06.txt | AC | 302 ms | 3456 KiB |
02_random_07.txt | AC | 301 ms | 3576 KiB |
02_random_08.txt | AC | 295 ms | 3600 KiB |
02_random_09.txt | AC | 295 ms | 3600 KiB |
02_random_10.txt | AC | 294 ms | 3600 KiB |
02_random_11.txt | AC | 339 ms | 3968 KiB |
02_random_12.txt | AC | 341 ms | 4068 KiB |
02_random_13.txt | AC | 343 ms | 4012 KiB |
02_random_14.txt | AC | 295 ms | 3532 KiB |