Submission #400358

#TimeUsernameProblemLanguageResultExecution timeMemory
400358nikatamlianiBitaro’s Party (JOI18_bitaro)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void maxi(int &x, int y) { if(x < y) x = y; } int main() { ios::sync_with_stdio(0); cin.tie(0); const int C = 1005 int n, m, q; cin >> n >> m >> q; vector<vector<int>> g(n+1); vector<vector<int>> r(n+1); for(int i = 1; i <= m; ++i) { int u, v; cin >> u >> v; g[u].push_back(v); r[v].push_back(u); } vector<int> dst(n+1); vector<vector<pair<int, int>>> list(n+1); for(int i = 1; i <= n; ++i) { for(int x : r[i]) { for(auto p : list[x]) maxi(dst[p.second], p.first); } for(int x : r[i]) { for(auto p : list[x]) { if(dst[p.second] == p.first) { list[i].push_back({p.first+1, p.second}); dst[p.second] = -1; } } } list[i].push_back({0, i}); sort(list[i].rbegin(), list[i].rend()); while((int)list[i].size() > C) list[i].pop_back(); for(int x : r[i]) { for(auto p : list[x]) dst[p.second] = 0; } } vector<bool> blocked(n+1); while(q--) { int t, x; cin >> t >> x; vector<int> v(x); for(int i = 0; i < x; ++i) { cin >> v[i]; blocked[v[i]] = 1; } int ans = 0; if(x < C) { for(pair<int, int> p : list[t]) { if(!blocked[p.second]) { ans = p.first; break; } } } else { vector<int> dp(n+1, -1e6); for(int i = 1; i <= t; ++i) { if(!blocked[i]) { dp[i] = 0; } for(int x : r[i]) { maxi(dp[i], dp[x]+1); } } ans = dp[t]; } cout << ans << '\n'; for(int i : v) blocked[i] = 0; } }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:9:2: error: expected ',' or ';' before 'int'
    9 |  int n, m, q;
      |  ^~~
bitaro.cpp:10:9: error: 'n' was not declared in this scope
   10 |  cin >> n >> m >> q;
      |         ^
bitaro.cpp:10:14: error: 'm' was not declared in this scope
   10 |  cin >> n >> m >> q;
      |              ^
bitaro.cpp:10:19: error: 'q' was not declared in this scope
   10 |  cin >> n >> m >> q;
      |                   ^