Submission #763602

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7636022023-06-22 13:47:30EllinorBall Machine (BOI13_ballmachine)C++14
48.05 / 100
1089 ms28448 KiB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
typedef long long ll;
// inlinevoid fastIO() { using stdio cin.tie(NULL); cout.tie(NULL); }
int N,Q;
int a;
vector<int> pars;
vector<vector<int>> kids;
vector<int> min_in_subtree;
vector<int> next_kid;
int find_min_in_subtree(int node){
//cerr<<"node: "<<node<<"\n";
int ret=node;
rep(i,0,kids[node].size()){
ret=min(ret,find_min_in_subtree(kids[node][i]));
}
min_in_subtree[node]=ret;
//cerr<<"ret: "<<ret<<"\n";
return ret;
}
// bool cmp(const Edge &x, const Edge &y) { return min_in_subtree[x]<min_in_subtree[y]; }
set<int> not_taken;
vector<int> take_order;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

ballmachine.cpp: In function 'int find_min_in_subtree(int)':
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:19:5: note: in expansion of macro 'rep'
   19 |     rep(i,0,kids[node].size()){
      |     ^~~
ballmachine.cpp:4:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                                       ~~~~^~~~~
ballmachine.cpp:19:5: note: in expansion of macro 'rep'
   19 |     rep(i,0,kids[node].size()){
      |     ^~~
ballmachine.cpp: In function 'void order_dfs(int)':
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:38:9: note: in expansion of macro 'rep'
   38 |         rep(i,0,kids[node].size()){
      |         ^~~
ballmachine.cpp:4:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                                       ~~~~^~~~~
ballmachine.cpp:38:9: note: in expansion of macro 'rep'
   38 |         rep(i,0,kids[node].size()){
      |         ^~~
ballmachine.cpp: In function 'void build_up(int)':
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:52:5: note: in expansion of macro 'rep'
   52 |     rep(i,1,up[node].size()){
      |     ^~~
ballmachine.cpp:4:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                                       ~~~~^~~~~
ballmachine.cpp:52:5: note: in expansion of macro 'rep'
   52 |     rep(i,1,up[node].size()){
      |     ^~~
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:55:5: note: in expansion of macro 'rep'
   55 |     rep(i,0,kids[node].size()){
      |     ^~~
ballmachine.cpp:4:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                                       ~~~~^~~~~
ballmachine.cpp:55:5: note: in expansion of macro 'rep'
   55 |     rep(i,0,kids[node].size()){
      |     ^~~
ballmachine.cpp: In function 'int main()':
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:66:5: note: in expansion of macro 'rep'
   66 |     rep(i,0,N){
      |     ^~~
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:98:5: note: in expansion of macro 'rep'
   98 |     rep(i,0,N){
      |     ^~~
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:101:13: note: in expansion of macro 'rep'
  101 |             rep(j,0,kids[i].size()){
      |             ^~~
ballmachine.cpp:4:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                                       ~~~~^~~~~
ballmachine.cpp:101:13: note: in expansion of macro 'rep'
  101 |             rep(j,0,kids[i].size()){
      |             ^~~
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:106:13: note: in expansion of macro 'rep'
  106 |             rep(j,0,v.size()){
      |             ^~~
ballmachine.cpp:4:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                                       ~~~~^~~~~
ballmachine.cpp:106:13: note: in expansion of macro 'rep'
  106 |             rep(j,0,v.size()){
      |             ^~~
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:122:5: note: in expansion of macro 'rep'
  122 |     rep(i,0,N){
      |     ^~~
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:141:5: note: in expansion of macro 'rep'
  141 |     rep(i,0,Q){
      |     ^~~
ballmachine.cpp:4:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
      |                            ^
ballmachine.cpp:144:13: note: in expansion of macro 'rep'
  144 |             rep(j,0,k){
      |             ^~~
ballmachine.cpp:170:42: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
  170 |                     if(!taken[up[at][0]] || at==root) break;
      |                        ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...