Submission #981045

# Submission time Handle Problem Language Result Execution time Memory
981045 2024-05-12T18:18:21 Z vjudge1 Beech Tree (IOI23_beechtree) C++17
5 / 100
50 ms 6740 KB
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repr(a,b,c) for(int a=b-1; a>c-1; a--)
#define repa(a,b) for(auto a:b)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define pb push_back

using namespace std;

vector<int> beechtree(int N, int M, vector<int> P, vector<int> C){
	vector<int> ans(N);
	if(N){
		int c;
		repr(i,N,0){
			if(i==N-1) ans[i]=1;
			else{
				if(i+2==N) c=C[i+1];
				if(C[i+1]!=c) break;
				ans[i]=1;
			}
		}
		return ans;
	}
	vector<int> subt[N];
	rep(i,0,N) subt[i].pb(i);
	repr(i,N,1) repa(e,subt[i]) subt[P[i]].pb(e);
	rep(i,0,N){
		sort(subt[i].begin(),subt[i].end());
		ans[i]=subt[i].size()==1;
		do{
			int e, cont;
			vector<int> s;
			rep(j,1,subt[i].size()){
				cont=0;
				e=subt[i][j];
				repa(f,s) if(f==C[e]) cont++; 
				if(e==i || P[e]!=subt[i][cont]) break;
				if(j==subt[i].size()-1) ans[i]=1;
				else s.pb(C[e]);
			}
			if(ans[i]) break;
		}while(next_permutation(subt[i].begin(),subt[i].end()));
	}
	return ans;
}

Compilation message

beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:2:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define rep(a,b,c) for(int a=b; a<c; a++)
......
   37 |    rep(j,1,subt[i].size()){
      |        ~~~~~~~~~~~~~~~~~~         
beechtree.cpp:37:4: note: in expansion of macro 'rep'
   37 |    rep(j,1,subt[i].size()){
      |    ^~~
beechtree.cpp:42:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if(j==subt[i].size()-1) ans[i]=1;
      |        ~^~~~~~~~~~~~~~~~~~
beechtree.cpp:22:5: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |     if(C[i+1]!=c) break;
      |     ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 46 ms 4188 KB Output is correct
8 Correct 47 ms 6740 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 444 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 45 ms 6580 KB Output is correct
18 Correct 46 ms 6740 KB Output is correct
19 Correct 47 ms 6740 KB Output is correct
20 Correct 50 ms 6692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -