# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244695 | TheLorax | Political Development (BOI17_politicaldevelopment) | C++11 | 397 ms | 524292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")
#define F first
#define S second
#define MT make_tuple
#define MP make_pair
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)
#define ALL(a) (a).begin(), (a).end()
#define END(s) {cout << s;return;}
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
int n;
std::vector<std::vector<int> > e;
void rek(int a, int f, int s){
for(auto x: e[a]){
if(x==s){
printf("3\n");
exit(0);
} if(x==f)
continue;
rek(x, a, f);
}
}
int main(){
int k;
scanf("%d %d", &n, &k);
e.resize(n);
for(int i=0; i<n; i++){
int d; scanf("%d", &d);
for(int j=0; j<d; j++){
int t;
scanf("%d", &t);
e[i].PB(t);
}
}
//k<=3
for(int i=0; i<n; i++)
rek(i, -1, -1);
//k<=2
for(int i=0; i<n; i++)
if(SZ(e[i])){
printf("2\n");
return 0;
}
//k<=1
printf("1\n");
}
Compilation message (stderr)
# | 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... |