답안 #333700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333700 2020-12-07T14:01:49 Z doowey Praktični (COCI18_prakticni) C++14
26 / 130
84 ms 14188 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);
        }
    }
    if(xar.empty()){
        cout << 0 << "\n";
        return 0;
    }
    cout << 1 << "\n";
    cout << xar[0].se << " " << xar.size() << " ";
    for(auto x : xar)
        cout << x.fi << " ";
    cout << "\n";
    return 0;
}
# 결과 실행 시간 메모리 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 81 ms 14188 KB Output is correct
6 Correct 79 ms 13036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 4460 KB Output is correct
2 Correct 14 ms 4460 KB Output is correct
3 Correct 19 ms 5996 KB Output is correct
4 Correct 23 ms 6508 KB Output is correct
5 Correct 65 ms 12268 KB Output is correct
6 Correct 38 ms 8684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 7020 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 10104 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 8428 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 8420 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 9708 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 84 ms 11112 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 5100 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 10348 KB There is a simple cycle which is not good
2 Halted 0 ms 0 KB -