# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
223299 | 2020-04-15T06:58:26 Z | oolimry | Klasika (COCI20_klasika) | C++14 | 15 ms | 10112 KB |
#include <bits/stdc++.h> using namespace std; int n = 1; int cnt = 0; vector<int> adj[200005]; int low[200005]; int high[200005]; int XOR[200005]; void dfs(int u){ low[u] = cnt; high[u] = cnt; cnt++; for(int v : adj[u]){ dfs(v); high[u] = max(high[u], high[v]); } } typedef pair<int,int> ii; vector<ii> queries; map<int, set<int> > m[33]; int main(){ freopen("i.txt","r",stdin); ios_base::sync_with_stdio(false); cin.tie(0); int Q; cin >> Q; queries.push_back(ii(-1,0)); while(Q--){ string s; int a, b; cin >> s >> a >> b; if(s[0] == 'A' || s[0] == 'a'){ a--; assert(a < n); adj[a].push_back(n); XOR[n] = XOR[a] ^ b; queries.push_back(ii(-1,n)); n++; } else{ assert(a-1 < n); assert(b-1 < n); queries.push_back(ii(a-1,b-1)); } } dfs(0); //for(int i = 0;i < n;i++) cout << low[i] << " " << high[i] << "\n"; for(ii q : queries){ //cout << q.first << " " << q.second << "\n"; if(q.first == -1){ int pos = low[q.second]; int x = XOR[q.second]; for(int b = 0;b <= 32;b++){ m[b][x].insert(pos); x ^= ((x & (1<<b))); } continue; } int other = XOR[q.first]; int L = low[q.second], R = high[q.second]; int cur = 0; for(int b = 32;b >= 0;b--){ if((other & (1<<b)) == 0) cur ^= (1 << b); set<int> s = m[b][cur]; auto it = s.lower_bound(L); if(it == s.end() || *it > R) cur ^= (1 << b); } cout << (cur ^ other) << "\n"; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 15 ms | 10112 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 15 ms | 10112 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 15 ms | 10112 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 15 ms | 10112 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |