이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
}
cout << 1 << "\n";
cout << xar[0].se << " " << xar.size() << " ";
for(auto x : xar)
cout << x.fi << " ";
cout << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |