Submission #993523

# Submission time Handle Problem Language Result Execution time Memory
993523 2024-06-05T23:27:05 Z AMel0n September (APIO24_september) C++17
0 / 100
1 ms 348 KB
#include "september.h"

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define rep(a) for(int i=0;i<a;++i)
#define ll long long
#define vi vector<int>

//#define S[j][i]  S[0][i]

// two pointers?
int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) {
	vi CHILDREN(N);
	vector<bool> LEAVES(N);

	for(int i=1; i<N; ++i) {
		CHILDREN[P[i]]++;
	}
	rep(N){
		if (CHILDREN[i]==0) LEAVES[i] = true;
	}

	int res =INT_MAX;
	for (int j =0; j < M; ++j) {
		int tempres = 0;
		int BCNTR = 0;
		vi C = CHILDREN;
		vector<bool> L=LEAVES;
		vector<bool> B(N,false);
		rep(N-1) {
			if (L[S[j][i]]) {
				C[P[S[j][i]]]--;
				//cout << "IS LEAF "<<S[j][i] << endl;
				if (C[P[S[j][i]]] == 0 && B[P[S[j][i]]]== true) {
					B[P[S[j][i]]] = false;
					BCNTR--;
					//cout << "RMV BRANCH " << P[S[j][i]] << endl;
				}
				else if (C[P[S[j][i]]]==0 && B[P[S[j][i]]]==false) {
					L[P[S[j][i]]] = true;
					//cout << "ADD LEAF " << P[S[j][i]]<< endl;
				}
			} else {
				B[S[j][i]] = true;
				BCNTR++;
				//cout << "ADD BRANCH " << S[j][i]<<endl;
			}
			if(BCNTR==0) {
				tempres++;
				//cout << "RES++" << endl;
			}
		}
		res = min(tempres, res);
	}

	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -