Submission #704322

#TimeUsernameProblemLanguageResultExecution timeMemory
704322minhnhatnoePark (JOI17_park)C++14
47 / 100
240 ms452 KiB
#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 if (T == 3){ subtask3::solve(N); } }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...