Submission #1127830

#TimeUsernameProblemLanguageResultExecution timeMemory
1127830AndrijaMBitaro’s Party (JOI18_bitaro)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' const int maxn=2e5+10; const int mod=1e9+7; vector<int>g[maxn]; vector<int>G[maxn]; int dp[maxn]; int c[maxn]; vector<int>v[maxn]; int pdp[maxn]; bool used[maxn]; vector<pair<int,int>>bst[maxn]; void dfs(int node,int par) { for(auto ax:g[node]) { if(ax==par)continue; dfs(ax,node); dp[node]=max(dp[node],dp[ax]+1); } } signed main() { ios::sync_with_stdio(false); int n,m,q; cin>>n>>m>>q; for(int i=0;i<m;i++) { int a,b; cin>>a>>b; a--;b--; g[b].push_back(a); G[a].push_back(b); } for(int i=0;i<n;i++) { bst[i].push_back({0,i}); } for(int i=0;i<n;i++) { for(auto &[d,x]:bst) { d++; } for(auto ax:G[i]) { vector<pair<int,int>>c; auto add = [&](pair<int,int> &a) { if (!used[a.second]) { c.push_back(a); used[a.second] = 1; } }; int l=0; int r=0; while(c.size()<350) { if(l==bst[i].size() && r==bst[ax].size()) { break; } if (r==bst[ax].size() || (l<bst[i].size() && bst[i][l].first>bst[ax][r].first)) add(bst[i][l++]); else add(bst[ax][r++]); } for(&[d,x]:c) { used[x]=0; } bst[ax]=c; } for(auto &[d,x]:bst[i]) { d--; } } while(q--) { int st; int kol; cin>>st>>kol; st--; memset(dp,0,sizeof dp); for(int i=0;i<kol;i++) { cin>>c[i]; used[c[i]]=1; c[i]--; dp[c[i]]=-1e9; } if(kol>=350) { ///memset(dp,0,sizeof dp); dfs(st,-1); cout<<dp[st]<<endl; continue; } else { int ans=-1; for(auto ax:bst[st]) { if(!used[ax.second]) { ans=ax.first; break; } } cout<<ans<<endl; } for(int i=0;i<kol;i++) { used[c[i]]=0; } } return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:50:19: error: 2 names provided for structured binding
   50 |         for(auto &[d,x]:bst)
      |                   ^~~~~
bitaro.cpp:50:19: note: while 'std::vector<std::pair<long long int, long long int> >' decomposes into 1 element
bitaro.cpp:76:19: error: 'd' was not declared in this scope
   76 |             for(&[d,x]:c)
      |                   ^
bitaro.cpp:76:21: error: 'x' was not declared in this scope
   76 |             for(&[d,x]:c)
      |                     ^
bitaro.cpp: In lambda function:
bitaro.cpp:76:23: error: expected '{' before ':' token
   76 |             for(&[d,x]:c)
      |                       ^
bitaro.cpp: In function 'int main()':
bitaro.cpp:76:23: error: taking address of rvalue [-fpermissive]
bitaro.cpp:76:23: error: expected ';' before ':' token
   76 |             for(&[d,x]:c)
      |                       ^
      |                       ;
bitaro.cpp:80:20: error: could not convert 'bst[ax].std::vector<std::pair<long long int, long long int> >::operator=(c)' from 'std::vector<std::pair<long long int, long long int> >' to 'bool'
   80 |             bst[ax]=c;
      |             ~~~~~~~^~
      |                    |
      |                    std::vector<std::pair<long long int, long long int> >
bitaro.cpp:81:9: error: expected primary-expression before '}' token
   81 |         }
      |         ^
bitaro.cpp:80:23: error: expected ')' before '}' token
   80 |             bst[ax]=c;
      |                       ^
      |                       )
   81 |         }
      |         ~              
bitaro.cpp:76:16: note: to match this '('
   76 |             for(&[d,x]:c)
      |                ^
bitaro.cpp:81:9: error: expected primary-expression before '}' token
   81 |         }
      |         ^