Submission #1071463

#TimeUsernameProblemLanguageResultExecution timeMemory
1071463Sir_Ahmed_ImranBeech Tree (IOI23_beechtree)C++17
14 / 100
81 ms11192 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define append push_back #define add insert #define nl '\n' #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define terminator main #define MAXN 200000 int n; int per[8]; int c[MAXN]; int par[MAXN]; vector<int> s[MAXN]; vector<int> BF(){ per[1]=1; for(int i=2;i<8;i++) per[i]=per[i-1]*i; vector<int> ans; for(int i=0;i<n;i++){ s[i].append(i); ans.append(0); } for(int i=n-1;i>=0;i--){ for(int j=0;j<per[s[i].size()-1];j++){ next_permutation(s[i].begin()+1,s[i].end()); map<int,int> x; for(int k=1;k<s[i].size();k++){ if(s[i][x[c[s[i][k]]]]!=par[s[i][k]]) break; x[c[s[i][k]]]++; if(k+1==s[i].size()) ans[i]=1; } } if(s[i].size()==1) ans[i]=1; if(!i) break; for(auto& j:s[i]) s[par[i]].append(j); } return ans; } vector<int> beechtree(int N,int M,vector<int> P,vector<int> C){ n=N; for(int i=0;i<n;i++){ par[i]=P[i]; c[i]=C[i]; } if(n<9) return BF(); int m=c[n-1]; vector<int> ans; for(int i=0;i<n;i++) ans.append(0); ans[n-1]=1; for(int i=n-1;i>0;i--){ if(c[i]!=m) break; ans[i-1]=1; } return ans; }

Compilation message (stderr)

beechtree.cpp: In function 'std::vector<int> BF()':
beechtree.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for(int k=1;k<s[i].size();k++){
      |                         ~^~~~~~~~~~~~
beechtree.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |                 if(k+1==s[i].size()) ans[i]=1;
      |                    ~~~^~~~~~~~~~~~~
#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...
#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...