Submission #581031

# Submission time Handle Problem Language Result Execution time Memory
581031 2022-06-22T08:37:22 Z AGE Klasika (COCI20_klasika) C++14
33 / 110
5000 ms 27920 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pb push_back

using namespace std;
const int N=1e6,M=2e3,mod=1e9+7;
pair<int,pair<int,int> > a[N];
int ans[N],p[N];
vector<int>adj[N];
int mux=-1e18;
void dfs(int node,int par,int a){

    mux=max(mux,ans[node]^ans[a]);
    for(auto x:adj[node]){

        if(x==par)
            continue;


        dfs(x,node,a);

    }
}
main()
{

    int q;
    cin>>q;
    ans[1]=0;
    int num=2;
    p[1]=0;

    while(q--){

        string s;
        cin>>s;
        if(s=="Add"){

            int  x,y;
            cin>>x>>y;

            adj[x].pb(num);
            ans[num]=ans[x]^y;
            p[num]=x;
            num++;

        }

        else{

            int x,y;
            cin>>x>>y;
            mux=-1e18;
            dfs(y,p[y],x);

            cout<<mux<<endl;
        }

        /*for(int i=1;i<num;i++){
            cout<<i<<": ";
            for(auto x:adj[i])
                cout<<x<<" ";
            cout<<endl;*/

    }
    return 0;
}

Compilation message

klasika.cpp:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 16 ms 23792 KB Output is correct
3 Correct 14 ms 23748 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 12 ms 23752 KB Output is correct
6 Correct 13 ms 23764 KB Output is correct
7 Correct 16 ms 23816 KB Output is correct
8 Correct 16 ms 23796 KB Output is correct
9 Correct 13 ms 23684 KB Output is correct
10 Correct 15 ms 23796 KB Output is correct
11 Correct 12 ms 23768 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 16 ms 23792 KB Output is correct
3 Correct 14 ms 23748 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 12 ms 23752 KB Output is correct
6 Correct 13 ms 23764 KB Output is correct
7 Correct 16 ms 23816 KB Output is correct
8 Correct 16 ms 23796 KB Output is correct
9 Correct 13 ms 23684 KB Output is correct
10 Correct 15 ms 23796 KB Output is correct
11 Correct 12 ms 23768 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 17 ms 23764 KB Output is correct
14 Correct 18 ms 23808 KB Output is correct
15 Correct 19 ms 23840 KB Output is correct
16 Correct 17 ms 23960 KB Output is correct
17 Correct 18 ms 23784 KB Output is correct
18 Correct 21 ms 23764 KB Output is correct
19 Correct 16 ms 23764 KB Output is correct
20 Correct 15 ms 23856 KB Output is correct
21 Correct 17 ms 23764 KB Output is correct
22 Correct 16 ms 23808 KB Output is correct
23 Correct 16 ms 23892 KB Output is correct
24 Correct 16 ms 23804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5042 ms 27920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 16 ms 23792 KB Output is correct
3 Correct 14 ms 23748 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 12 ms 23752 KB Output is correct
6 Correct 13 ms 23764 KB Output is correct
7 Correct 16 ms 23816 KB Output is correct
8 Correct 16 ms 23796 KB Output is correct
9 Correct 13 ms 23684 KB Output is correct
10 Correct 15 ms 23796 KB Output is correct
11 Correct 12 ms 23768 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 17 ms 23764 KB Output is correct
14 Correct 18 ms 23808 KB Output is correct
15 Correct 19 ms 23840 KB Output is correct
16 Correct 17 ms 23960 KB Output is correct
17 Correct 18 ms 23784 KB Output is correct
18 Correct 21 ms 23764 KB Output is correct
19 Correct 16 ms 23764 KB Output is correct
20 Correct 15 ms 23856 KB Output is correct
21 Correct 17 ms 23764 KB Output is correct
22 Correct 16 ms 23808 KB Output is correct
23 Correct 16 ms 23892 KB Output is correct
24 Correct 16 ms 23804 KB Output is correct
25 Execution timed out 5042 ms 27920 KB Time limit exceeded
26 Halted 0 ms 0 KB -