# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333707 | 2020-12-07T14:10:19 Z | doowey | Praktični (COCI18_prakticni) | C++14 | 136 ms | 18284 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int N = (int)1e5 + 10; const int LOG = 31; ll vl[N]; vector<pii> T[N]; ll xr[N]; bool vis[N]; int dep[N]; vector<pii> xar; int xorval; void dfs(int u, int pp){ vis[u]=true; for(auto x : T[u]){ if(vis[x.fi]){ if(dep[u] - dep[x.fi] >= 2){ xorval = (xr[u]^xr[x.fi]^vl[x.se]); if(xorval != 0) xar.push_back(mp(x.se, xorval)); } } else{ dep[x.fi] = dep[u]+1; xr[x.fi] = xr[u]^vl[x.se]; dfs(x.fi, u); } } } int main(){ fastIO; //freopen("in.txt", "r", stdin); int n, m; cin >> n >> m; int u, v; for(int i = 1; i <= m ; i ++ ){ cin >> u >> v >> vl[i]; T[u].push_back(mp(v,i)); T[v].push_back(mp(u,i)); } for(int i = 1; i <= n; i ++ ){ if(!vis[i]){ dfs(i,-1); } } vector<int> nums; vector<vector<int>> sol; int idx = -1; int cur; for(int i = 0 ; i < LOG; i ++ ){ idx = -1; for(int j = 0 ; j < xar.size(); j ++ ){ if((xar[j].se & (1 << i))) idx = j; } if(idx == -1) continue; cur = xar[idx].se; nums.push_back(cur); sol.push_back({}); for(int j = 0 ; j < xar.size(); j ++ ){ if((xar[j].se & (1 << i))){ xar[j].se ^= cur; sol.back().push_back(xar[j].fi); } } } cout << nums.size() << "\n"; for(int i = 0 ;i < nums.size(); i ++ ){ cout << nums[i] << " "; cout << sol[i].size() << " "; for(auto x : sol[i]) cout << x << " "; cout << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 6764 KB | Output is correct |
2 | Correct | 33 ms | 7148 KB | Output is correct |
3 | Correct | 8 ms | 3564 KB | Output is correct |
4 | Correct | 8 ms | 3820 KB | Output is correct |
5 | Correct | 77 ms | 12140 KB | Output is correct |
6 | Correct | 79 ms | 10988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 4460 KB | Output is correct |
2 | Correct | 14 ms | 4460 KB | Output is correct |
3 | Correct | 18 ms | 5356 KB | Output is correct |
4 | Correct | 21 ms | 5868 KB | Output is correct |
5 | Correct | 61 ms | 10348 KB | Output is correct |
6 | Correct | 42 ms | 7404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 7916 KB | Output is correct |
2 | Correct | 72 ms | 10604 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 10396 KB | Output is correct |
2 | Correct | 109 ms | 16228 KB | Output is correct |
3 | Correct | 3 ms | 2796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 49 ms | 8684 KB | Output is correct |
2 | Correct | 66 ms | 10604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 10980 KB | Output is correct |
2 | Correct | 39 ms | 7916 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 76 ms | 10384 KB | Output is correct |
2 | Correct | 90 ms | 13676 KB | Output is correct |
3 | Correct | 65 ms | 10860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 110 ms | 14312 KB | Output is correct |
2 | Correct | 136 ms | 18284 KB | Output is correct |
3 | Correct | 118 ms | 17644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 5100 KB | Output is correct |
2 | Correct | 28 ms | 6892 KB | Output is correct |
3 | Correct | 81 ms | 13164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 11372 KB | Output is correct |
2 | Correct | 58 ms | 8940 KB | Output is correct |
3 | Correct | 110 ms | 16740 KB | Output is correct |