제출 #340605

#제출 시각아이디문제언어결과실행 시간메모리
340605A_DKlasika (COCI20_klasika)C++14
33 / 110
5074 ms26484 KiB
/* ID: antwand1 TASK: barn1 LANG: C++ */ #include <bits/stdc++.h> #define ll long long #define du long double #define F first #define S second using namespace std; const int N=1e6+100; vector<pair<int,int>> g[N]; int sz=1,mx=0; bool ok[N]; void dfs(int u,int p,int we) { if(ok[u])mx=max(mx,we); for(auto x:g[u]){ if(x.F!=p){ dfs(x.F,u,we^x.S); } } } void dfs2(int u,int p,int tar) { // cout<<u<<" "<<tar<<endl; if(tar==u)tar=0; if(tar==0)ok[u]=1; for(auto x:g[u]){ if(x.F!=p){ dfs2(x.F,u,tar); } } } main() { //freopen("barn1.in","r",stdin);freopen("barn1.out","w",stdout); int n; cin>>n; while(n--){ string s; cin>>s; if(s=="Add"){ sz++; int a,b; cin>>a>>b; g[sz].push_back({a,b}); g[a].push_back({sz,b}); } else{ for(int i=1;i<=sz;i++){ // cout<<i<<" :"; // for(auto x:g[i])cout<<x.F<<" ";cout<<endl; } int a,b; cin>>a>>b; for(int i=1;i<=sz;i++)ok[i]=0; dfs2(1,1,b); // for(int i=1;i<=sz;i++)cout<<ok[i]<<" ";cout<<endl; mx=0; dfs(a,a,0); cout<<mx<<endl; } } }

컴파일 시 표준 에러 (stderr) 메시지

klasika.cpp:37:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main()
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...