Submission #704326

# Submission time Handle Problem Language Result Execution time Memory
704326 2023-03-02T03:40:40 Z vjudge1 Park (JOI17_park) C++17
47 / 100
820 ms 524 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(min(a, c), max(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{
		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 1 ms 212 KB Output is correct
2 Correct 5 ms 324 KB Output is correct
3 Correct 5 ms 212 KB Output is correct
4 Correct 8 ms 320 KB Output is correct
5 Correct 6 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 229 ms 448 KB Output is correct
2 Correct 121 ms 444 KB Output is correct
3 Correct 117 ms 440 KB Output is correct
4 Correct 238 ms 448 KB Output is correct
5 Correct 262 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 404 KB Output is correct
2 Correct 211 ms 396 KB Output is correct
3 Correct 155 ms 396 KB Output is correct
4 Correct 196 ms 524 KB Output is correct
5 Correct 130 ms 340 KB Output is correct
6 Correct 168 ms 400 KB Output is correct
7 Correct 188 ms 400 KB Output is correct
8 Correct 160 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 408 KB Output is correct
2 Incorrect 820 ms 524 KB Wrong Answer[5]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 400 KB Wrong Answer[2]
2 Halted 0 ms 0 KB -