제출 #983972

#제출 시각아이디문제언어결과실행 시간메모리
983972AmaarsaaBitaro’s Party (JOI18_bitaro)C++14
0 / 100
2 ms8796 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; using pll = pair < ll, ll >; ll used[100004], cant[100004]; vector < ll > adj[100004], radj[100004]; vector < pll > good[100003]; int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll n, m, q, i, ans, x, y, I, I1, i1, t; cin >> n >> m >> q; for (i = 1; i <= m; i ++) { cin >> x >> y; adj[x].push_back(y); radj[y].push_back(x); } for (i = 1; i <= m; i ++) { vector < pll > v; good[i].push_back({0ll, i}); used[0] = 1; for ( ll I : radj[i]) { i1 = I1 = 0; if ( used[0] == 0) { good[i].push_back({0ll, i}); used[0] = 1; } while ( i1 < good[i].size() || I1 < good[I].size()) { if (I1 == good[I].size() || (i1 != good[i].size() && good[i][i1].first > good[I][I1].first + 1)) { v.push_back(good[i][i1]); i1 ++; used[v.back().second] = 1; } else { v.push_back(good[I][I1]); v.back().first ++; I1 ++; used[v.back().second] = 1; } while (i1 < good[i].size() && used[good[i][i1].second]) i1 ++; while (I1 < good[I].size() && used[good[I][I1].second]) I1 ++; } swap(good[i], v); v.clear(); for ( pll &A : good[i]) used[A.second] = 0; } } while ( q --) { cin >> t >> m; ll c[m + 2]; for ( i = 1; i <= m; i ++) { cin >> c[i]; cant[c[i]] = 1; } ans = -1; if ( m <= 100) { for ( pll &A : good[t]) { if (!cant[A.second]) { ans = A.first; break; } } } else { ll dp[n + 2]; for (i = 1; i <= n; i ++) dp[i] = -1; for (i = 1; i <= n; i ++) { if ( cant[i] == 1 && dp[i] == -1) continue; dp[i] = max(0ll, dp[i]); for ( int I : adj[i]) { dp[I] = max(dp[I], dp[i] + 1); } } ans = dp[t]; } for (i =1 ; i <= m; i ++) cant[c[i]] = 0; cout << ans << endl; } /* for (i = 1; i <= n; i ++) { cout << i << " " << good[i].size() << endl; for (pll X : good[i]) { cout << X.first << " " << X.second << endl; } cout << endl; } */ }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:33:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    while ( i1 < good[i].size() || I1 < good[I].size()) {
      |            ~~~^~~~~~~~~~~~~~~~
bitaro.cpp:33:38: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    while ( i1 < good[i].size() || I1 < good[I].size()) {
      |                                   ~~~^~~~~~~~~~~~~~~~
bitaro.cpp:34:12: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if (I1 == good[I].size() || (i1 != good[i].size() && good[i][i1].first > good[I][I1].first + 1)) {
      |         ~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:34:37: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if (I1 == good[I].size() || (i1 != good[i].size() && good[i][i1].first > good[I][I1].first + 1)) {
      |                                  ~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:45:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     while (i1 < good[i].size() && used[good[i][i1].second]) i1 ++;
      |            ~~~^~~~~~~~~~~~~~~~
bitaro.cpp:46:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     while (I1 < good[I].size() && used[good[I][I1].second]) I1 ++;
      |            ~~~^~~~~~~~~~~~~~~~
bitaro.cpp:14:28: warning: unused variable 'I' [-Wunused-variable]
   14 |  ll n, m, q, i, ans, x, y, I, I1, i1, t;
      |                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...