Submission #881273

#TimeUsernameProblemLanguageResultExecution timeMemory
881273bobbilykingBitaro’s Party (JOI18_bitaro)C++17
Compilation error
0 ms0 KiB
#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> #include<math.h> using namespace std; typedef int ll; typedef long double ld; typedef pair<ll, ll> pl; typedef vector<ll> vl; #define FD(i, r, l) for(ll i = r; i > (l); --i) #define K first #define V second #define G(x) ll x; cin >> x; #define GD(x) ld x; cin >> x; #define GS(s) string s; cin >> s; #define EX(x) { cout << x << '\n'; exit(0); } #define A(a) (a).begin(), (a).end() #define F(i, l, r) for (ll i = l; i < (r); ++i) #define NN 100010 #define M 1000000007 // 998244353 vector<ll> adj[NN]; ll n; vector<ll> topo; bool bad[NN]; ll dp[NN]; constexpr ll SN = 200; vector<pl> dp[NN]; // only keep up to sqrt(N) things in here int main(){ // freopen("a.in", "r", stdin); // freopen("a.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); cin >> n; G(m) G(q) while (m--) { G(s) G(e) adj[e].push_back(s); } { bool vis[NN] = {}; vector<ll> temp; auto dfs = [&](auto&& self, ll i) -> void { if (vis[i]) return; vis[i] = 1; for (auto y: adj[i]) self(self, y); temp.push_back(i); }; F(i, 1, n+1) if (!vis[i]) { temp.clear(); dfs(dfs, i); topo.insert(topo.end(), temp.rbegin(), temp.rend()); } } for (auto x: topo) { dp[x].emplace_back(0, x); for (auto y: adj[x]) { for (auto z: dp[y]) dp[x].emplace_back(z.K+1, z.V); } sort(A(dp[x]), greater()); while (dp[x].size() > SN) dp[x].pop_back(); } while (q--) { G(t) G(m) vector<ll> v(m); for (auto &x: v) { cin >> x; bad[x]=1; } if (m >= SN) { memset(dp, 0, sizeof dp); for (auto x: v) dp[x] = -1e9; for (auto x: topo) { for (auto y: adj[x]) dp[x] = max(dp[x], 1 + dp[y]); } cout << (dp[t] < 0 ? -1: dp[t]) << '\n'; } else { ll ans = -1; for (auto [dist, node]: dp[t]) if (!bad[node]) ans = max(ans, dist); cout << ans << '\n'; } for (auto x: v) bad[x] = 0; } }

Compilation message (stderr)

bitaro.cpp:35:12: error: conflicting declaration 'std::vector<std::pair<int, int> > dp [100010]'
   35 | vector<pl> dp[NN]; // only keep up to sqrt(N) things in here
      |            ^~
bitaro.cpp:32:4: note: previous declaration as 'll dp [100010]'
   32 | ll dp[NN];
      |    ^~
bitaro.cpp: In function 'int main()':
bitaro.cpp:65:15: error: request for member 'emplace_back' in 'dp[x]', which is of non-class type 'll' {aka 'int'}
   65 |         dp[x].emplace_back(0, x);
      |               ^~~~~~~~~~~~
bitaro.cpp:67:30: error: 'begin' was not declared in this scope
   67 |             for (auto z: dp[y]) dp[x].emplace_back(z.K+1, z.V);
      |                              ^
bitaro.cpp:67:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bitaro.cpp:5:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from bitaro.cpp:5:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
bitaro.cpp:67:30: error: 'end' was not declared in this scope
   67 |             for (auto z: dp[y]) dp[x].emplace_back(z.K+1, z.V);
      |                              ^
bitaro.cpp:67:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bitaro.cpp:5:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from bitaro.cpp:5:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
bitaro.cpp:67:39: error: request for member 'emplace_back' in 'dp[x]', which is of non-class type 'll' {aka 'int'}
   67 |             for (auto z: dp[y]) dp[x].emplace_back(z.K+1, z.V);
      |                                       ^~~~~~~~~~~~
bitaro.cpp:21:18: error: request for member 'begin' in 'dp[x]', which is of non-class type 'll' {aka 'int'}
   21 | #define A(a) (a).begin(), (a).end()
      |                  ^~~~~
bitaro.cpp:69:14: note: in expansion of macro 'A'
   69 |         sort(A(dp[x]), greater());
      |              ^
bitaro.cpp:21:31: error: request for member 'end' in 'dp[x]', which is of non-class type 'll' {aka 'int'}
   21 | #define A(a) (a).begin(), (a).end()
      |                               ^~~
bitaro.cpp:69:14: note: in expansion of macro 'A'
   69 |         sort(A(dp[x]), greater());
      |              ^
bitaro.cpp:70:22: error: request for member 'size' in 'dp[x]', which is of non-class type 'll' {aka 'int'}
   70 |         while (dp[x].size() > SN) dp[x].pop_back();
      |                      ^~~~
bitaro.cpp:70:41: error: request for member 'pop_back' in 'dp[x]', which is of non-class type 'll' {aka 'int'}
   70 |         while (dp[x].size() > SN) dp[x].pop_back();
      |                                         ^~~~~~~~
bitaro.cpp:89:41: error: 'begin' was not declared in this scope
   89 |             for (auto [dist, node]: dp[t]) if (!bad[node]) ans = max(ans, dist);
      |                                         ^
bitaro.cpp:89:41: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bitaro.cpp:5:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from bitaro.cpp:5:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
bitaro.cpp:89:41: error: 'end' was not declared in this scope
   89 |             for (auto [dist, node]: dp[t]) if (!bad[node]) ans = max(ans, dist);
      |                                         ^
bitaro.cpp:89:41: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bitaro.cpp:5:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from bitaro.cpp:5:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~