Submission #646501

#TimeUsernameProblemLanguageResultExecution timeMemory
646501tvladm2009Bitaro’s Party (JOI18_bitaro)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using ll = long long; int const nmax = 100000; int dp[1 + nmax], c[1 + nmax]; std::vector<int> g[1 + nmax]; std::vector<std::pair<int, int>> sol[1 + nmax]; bool viz[1 + nmax], b[1 + nmax]; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n, m, q; std::cin >> n >> m >> q; for(int i = 1;i <= m; i++) { int u, v; std::cin >> u >> v; g[u].push_back(v); } for(int i = 1;i <= n; i++) sol[i].push_back({0, i}); for(int u = 1;u <= n; u++) { std::sort(sol[u].rbegin(), sol[u].rend()); for(auto p : sol[u]) viz[p.second] = false; std::vector<std::pair<int, int>> aux; for(auto v : sol[u]) { if(aux.size() >= 120) break; if(!viz[v.second]) { aux.push_back(v); viz[v.second] = 1; } } std::swap(sol[u], aux); for(int v : g[u]) { for(auto p : sol[u]) sol[v].push_back({p.first + 1, p.second}); } } while(q--) { int to, y; std::cin >> to >> y; for(int i = 1;i <= y; i++) { int v; std::cin >> v; c[i] = v; b[v] = true; } if(y >= 120) { for(int i = 1;i <= n; i++) { if(b[i]) dp[i] = -1; else dp[i] = 0; } for(int i = 1;i <= n; i++) { if(dp[i] == -1) { continue; } for(int u : g[i]) dp[u] = std::max(dp[u], dp[i] + 1); } std::cout << dp[to] << "\n"; } else { int ans = -1; for(auto p : sol[to]) { if(!b[p.second]) ans = std::max(ans, p.first); } std::cout << ans << "\n"; } for(int i = 1; i <= y; i++) b[c[i]] = false; } return 0; } #include <bits/stdc++.h> using ll = long long; int const nmax = 100000; int dp[1 + nmax], c[1 + nmax]; std::vector<int> g[1 + nmax]; std::vector<std::pair<int, int>> sol[1 + nmax]; bool viz[1 + nmax], b[1 + nmax]; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n, m, q; std::cin >> n >> m >> q; for(int i = 1;i <= m; i++) { int u, v; std::cin >> u >> v; g[u].push_back(v); } for(int i = 1;i <= n; i++) sol[i].push_back({0, i}); for(int u = 1;u <= n; u++) { std::sort(sol[u].rbegin(), sol[u].rend()); for(auto p : sol[u]) viz[p.second] = false; std::vector<std::pair<int, int>> aux; for(auto v : sol[u]) { if(aux.size() >= 120) break; if(!viz[v.second]) { aux.push_back(v); viz[v.second] = 1; } } std::swap(sol[u], aux); for(int v : g[u]) { for(auto p : sol[u]) sol[v].push_back({p.first + 1, p.second}); } } while(q--) { int to, y; std::cin >> to >> y; for(int i = 1;i <= y; i++) { int v; std::cin >> v; c[i] = v; b[v] = true; } if(y >= 120) { for(int i = 1;i <= n; i++) { if(b[i]) dp[i] = -1; else dp[i] = 0; } for(int i = 1;i <= n; i++) { if(dp[i] == -1) { continue; } for(int u : g[i]) dp[u] = std::max(dp[u], dp[i] + 1); } std::cout << dp[to] << "\n"; } else { int ans = -1; for(auto p : sol[to]) { if(!b[p.second]) ans = std::max(ans, p.first); } std::cout << ans << "\n"; } for(int i = 1; i <= y; i++) b[c[i]] = false; } return 0; }

Compilation message (stderr)

bitaro.cpp:90:11: error: redefinition of 'const int nmax'
   90 | int const nmax = 100000;
      |           ^~~~
bitaro.cpp:5:11: note: 'const int nmax' previously defined here
    5 | int const nmax = 100000;
      |           ^~~~
bitaro.cpp:92:5: error: redefinition of 'int dp [100001]'
   92 | int dp[1 + nmax], c[1 + nmax];
      |     ^~
bitaro.cpp:7:5: note: 'int dp [100001]' previously declared here
    7 | int dp[1 + nmax], c[1 + nmax];
      |     ^~
bitaro.cpp:92:19: error: redefinition of 'int c [100001]'
   92 | int dp[1 + nmax], c[1 + nmax];
      |                   ^
bitaro.cpp:7:19: note: 'int c [100001]' previously declared here
    7 | int dp[1 + nmax], c[1 + nmax];
      |                   ^
bitaro.cpp:93:18: error: redefinition of 'std::vector<int> g [100001]'
   93 | std::vector<int> g[1 + nmax];
      |                  ^
bitaro.cpp:8:18: note: 'std::vector<int> g [100001]' previously declared here
    8 | std::vector<int> g[1 + nmax];
      |                  ^
bitaro.cpp:94:34: error: redefinition of 'std::vector<std::pair<int, int> > sol [100001]'
   94 | std::vector<std::pair<int, int>> sol[1 + nmax];
      |                                  ^~~
bitaro.cpp:9:34: note: 'std::vector<std::pair<int, int> > sol [100001]' previously declared here
    9 | std::vector<std::pair<int, int>> sol[1 + nmax];
      |                                  ^~~
bitaro.cpp:95:6: error: redefinition of 'bool viz [100001]'
   95 | bool viz[1 + nmax], b[1 + nmax];
      |      ^~~
bitaro.cpp:10:6: note: 'bool viz [100001]' previously declared here
   10 | bool viz[1 + nmax], b[1 + nmax];
      |      ^~~
bitaro.cpp:95:21: error: redefinition of 'bool b [100001]'
   95 | bool viz[1 + nmax], b[1 + nmax];
      |                     ^
bitaro.cpp:10:21: note: 'bool b [100001]' previously declared here
   10 | bool viz[1 + nmax], b[1 + nmax];
      |                     ^
bitaro.cpp:97:5: error: redefinition of 'int main()'
   97 | int main() {
      |     ^~~~
bitaro.cpp:12:5: note: 'int main()' previously defined here
   12 | int main() {
      |     ^~~~