답안 #887996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887996 2023-12-15T17:40:31 Z Ahmed_Solyman Klasika (COCI20_klasika) C++14
33 / 110
98 ms 52820 KB
/*
In the name of Allah
made by: Ahmed_Solyman
*/
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
const int N=6e6+5;
int trie[N][2];
int id=1;
void insert(int x){
    int p=0;
    for(int i=29;i>=0;i--){
        bool g=x & (1<<i);
        if(~trie[p][g])p=trie[p][g];
        else p=trie[p][g]=id++;
    }
}
int solve(int x){
    int p=0,ret=0;
    for(int i=29;i>=0;i--){
        bool g=x & (1<<i);g^=1;
        if(~trie[p][g])p=trie[p][g],ret|=(1<<i);
        else p=trie[p][g^1];
    }
    return ret;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #ifndef ONLINE_JUDGE
  ////  freopen("input.in", "r", stdin);
  ////  freopen("output.out", "w", stdout);
    #endif
    fast
    fil(trie,-1);
    int q;cin>>q;
    vector<int>d(q+1);
    int v=2;
    insert(0);
    while(q--){
        string s;cin>>s;
        if(s=="Add"){
            int u,w;cin>>u>>w;
            d[v]=d[u]^w;
            insert(d[v++]);
        }
        else{
            int a,b;cin>>a>>b;
            cout<<solve(d[a])<<endl;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 47196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 47196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 52740 KB Output is correct
2 Correct 84 ms 52560 KB Output is correct
3 Correct 83 ms 52456 KB Output is correct
4 Correct 81 ms 52308 KB Output is correct
5 Correct 89 ms 52648 KB Output is correct
6 Correct 88 ms 52564 KB Output is correct
7 Correct 88 ms 52408 KB Output is correct
8 Correct 76 ms 52148 KB Output is correct
9 Correct 89 ms 52820 KB Output is correct
10 Correct 85 ms 52616 KB Output is correct
11 Correct 98 ms 52364 KB Output is correct
12 Correct 75 ms 52304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 47196 KB Output isn't correct
2 Halted 0 ms 0 KB -