Submission #208272

#TimeUsernameProblemLanguageResultExecution timeMemory
208272rzbtZagrade (COI17_zagrade)C++14
0 / 100
10 ms5880 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() #define F first #define S second #define MAXN 100005 using namespace std; int n; char s[MAXN]; int zagrada[MAXN]; vector<int> niz[MAXN]; int obradjen[MAXN]; int podst[MAXN]; int cale[MAXN]; int dfsV(int t,int o){ podst[t]=1; cale[t]=o; for(auto x:niz[t]) if(x!=o && !obradjen[x]) podst[t]+=dfsV(x,t); return podst[t]; } void centroidna(int c){ dfsV(c,0); int vel=podst[c]; if(vel==1){ printf(" jedan %d\n",c); obradjen[c]=true; return; } while(22){ bool naso=false; for(auto x:niz[c]){ if(obradjen[x] || x==cale[c])continue; if(podst[x]>(vel>>1)){ c=x; naso=true; break; } } if(!naso)break; } /// OVDE IDE OBRADA ///OVDE JE KRAJ OVRADE printf(" vise %d\n",c); obradjen[c]=true; for(auto x:niz[c]){ if(!obradjen[x])centroidna(x); } } int main() { scanf("%d", &n); scanf("%s",s); for(int i=1;i<=n;i++) zagrada[i]=(s[i-1]=='('?1:-1); for(int i=1;i<n;i++){ int t1,t2; scanf("%d %d", &t1, &t2); niz[t1].pb(t2); niz[t2].pb(t1); } centroidna(1); return 0; }

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:63:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
zagrade.cpp:64:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",s);
     ~~~~~^~~~~~~~
zagrade.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &t1, &t2);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...