# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1070339 |
2024-08-22T13:24:49 Z |
AdamGS |
Tug of War (BOI15_tug) |
C++17 |
|
6 ms |
3000 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=3e4+7;
vector<pair<int,int>>V[2*LIM];
int F[2*LIM], ile[2*LIM], n;
int fnd(int x) {
if(F[x]==x) return x;
return F[x]=fnd(F[x]);
}
void uni(int a, int b) {
a=fnd(a); b=fnd(b);
if(a!=b) {
ile[a]+=ile[b];
F[b]=a;
}
--ile[a];
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int k;
cin >> n >> k;
rep(i, 2*n) {
F[i]=i;
ile[i]=1;
}
rep(i, 2*n) {
int a, b, c;
cin >> a >> b >> c; --a; --b; b+=n;
V[a].pb({b, c});
V[b].pb({a, c});
}
rep(i, 2*n) if(ile[fnd(i)]<0) {
cout << "NO\n";
return 0;
}
cout << "YES\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2652 KB |
Output is correct |
2 |
Incorrect |
6 ms |
3000 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |