# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
333675 | 2020-12-07T13:32:21 Z | doowey | Praktični (COCI18_prakticni) | C++14 | 116 ms | 16488 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; 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){ xar.push_back(mp(x.se, (xr[u]^xr[x.fi]^vl[x.se]))); } } else{ dep[x.fi] = dep[u]+1; xr[x.fi] = xr[u]^vl[x.se]; dfs(x.fi, u); } } } int main(){ fastIO; 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); } } int idx; vector<vector<int>> soln; vector<int> ss; for(int b = 0; b < LOG; b ++ ){ idx = -1; for(int i = 0 ; i < xar.size(); i ++ ){ if((xar[i].se & (1 << b))){ idx = i; } } if(idx != -1){ ss.push_back(xar[idx].se); soln.push_back({}); for(auto &q : xar){ if((q.se & (1 << b))){ q.se ^= xar[idx].se; soln.back().push_back(xar[idx].fi); } } } } cout << soln.size() << "\n"; for(int i = 0 ; i < ss.size(); i ++ ){ cout << ss[i] << " "; cout << soln[i].size() << " "; for(auto x : soln[i]) cout << x << " "; cout << "\n"; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 33 ms | 7788 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 4972 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 45 ms | 8812 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 72 ms | 12012 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 51 ms | 10008 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 79 ms | 12440 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 88 ms | 12396 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 116 ms | 16488 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 ms | 5996 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 92 ms | 13420 KB | There is a simple cycle which is not good |
2 | Halted | 0 ms | 0 KB | - |