Submission #704320

# Submission time Handle Problem Language Result Execution time Memory
704320 2023-03-02T03:32:10 Z minhnhatnoe Park (JOI17_park) C++14
20 / 100
210 ms 448 KB
#include <bits/stdc++.h>
#include "park.h"
using namespace std;
typedef long long ll;
void answer(int a, int b){
	Answer(min(a, b), max(a, b));
}
namespace subtask1{
	void solve(int n){
		for (int i=0; i<n; i++){
			for (int j=i+1; j<n; j++){
				vector<int> a(n, 0);
				a[i] = a[j] = 1;
				if (Ask(i, j, a.data())){
					answer(i, j);
				}
			}
		}
	}
};
bool in_middle(int n, int a, int b, int c){
	vector<int> place(n, 1);
	place[b] = 0;
	return Ask(a, c, place.data()) == 0;
}
namespace subtask2{
	void solve(int n){
		int idx1 = 0, idx2 = 1;
		for (int i=2; i<n; i++){
			if (in_middle(n, idx1, i, idx2)) continue;
			if (in_middle(n, idx1, idx2, i)){
				idx2 = i;
			}
			else{
				idx1 = i;
			}
		}
		vector<int> a;
		for (int i=0; i<n; i++){
			if (i != idx1) a.push_back(i);
		}
		sort(a.begin(), a.end(), [&](int x, int y){
			if (x == y) return false;
			return in_middle(n, idx1, x, y);
		});
		answer(idx1, a[0]);
		for (int i=1; i<a.size(); i++){
			answer(a[i-1], a[i]);
		}
	}
};
namespace subtask3{
	int find_root(int n, vector<int> &subtree){
		int root = subtree[0];
		for (int i=1; i<subtree.size(); i++){
			if (in_middle(n, root, subtree[i], 0)){
				root = subtree[i];
			}
		}
		return root;
	}
	void solve(int n, vector<int> &subtree, int root, bool is_troot){
		int mxsize = 6 + is_troot;
		vector<vector<int>> a;
		for (int u: subtree){
			if (u == root) continue;
			bool found = false;
			for (int i=0; i<a.size() && !found; i++){
				if (i == mxsize - 1 || !in_middle(n, u, root, a[i][0])){
					a[i].push_back(u);
					found = true;
				}
			}
			if (!found){
				a.push_back(vector<int>({u}));
			}
		}
		for (int i=0; i<a.size(); i++){
			int subroot = find_root(n, a[i]);
			answer(root, subroot);
			solve(n, a[i], subroot, false);
		}
	}
	void solve(int n){
		vector<int> tree(n); iota(tree.begin(), tree.end(), 0);
		solve(n, tree, 0, true);
	}
};
void Detect(int T, int N){
	if (T == 1){
		subtask1::solve(N);
	}
	else if (T == 2){
		subtask2::solve(N);
	}
	else if (T == 3){
		subtask3::solve(N);
	}
}

Compilation message

park.cpp: In function 'void subtask2::solve(int)':
park.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for (int i=1; i<a.size(); i++){
      |                 ~^~~~~~~~~
park.cpp: In function 'int subtask3::find_root(int, std::vector<int>&)':
park.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for (int i=1; i<subtree.size(); i++){
      |                 ~^~~~~~~~~~~~~~~
park.cpp: In function 'void subtask3::solve(int, std::vector<int>&, int, bool)':
park.cpp:68:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |    for (int i=0; i<a.size() && !found; i++){
      |                  ~^~~~~~~~~
park.cpp:78:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |   for (int i=0; i<a.size(); i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 212 KB Output is correct
3 Correct 6 ms 324 KB Output is correct
4 Correct 6 ms 212 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 206 ms 448 KB Output is correct
2 Correct 98 ms 444 KB Output is correct
3 Correct 119 ms 436 KB Output is correct
4 Correct 210 ms 444 KB Output is correct
5 Correct 210 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong Answer[4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -