제출 #984061

#제출 시각아이디문제언어결과실행 시간메모리
984061AmaarsaaBitaro’s Party (JOI18_bitaro)C++14
7 / 100
2072 ms123632 KiB
#include<bits/stdc++.h> using namespace std; using ll = int ; using pll = pair < ll, ll >; ll used[100001], cant[100001], c[100001], dp[100001]; vector < ll > adj[100001], radj[100001]; vector < pll > good[100001]; 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 <= n; i ++) { vector < pll > v; for ( ll I : radj[i]) { i1 = I1 = 0; good[I].push_back({0, I}); while ( good[i].size() < 350 && (i1 < good[i].size() || I1 < good[I].size())) { if (i1 == good[i].size() || (I1 != good[I].size() && good[I][I1].first + 1 >= good[i][i1].first )) { good[I][I1].first ++; v.push_back(good[I][I1]); used[good[I][I1].second] = 1; good[I][I1].first --; I1 ++; } else { v.push_back(good[i][i1]); used[good[i][i1].second] = 1; i1 ++; } while (i1 < good[i].size() && used[good[i][i1].second]) i1 ++; while (I1 < good[I].size() && used[good[I][I1].second]) I1 ++; } good[I].pop_back(); for ( pll A : v) used[A.second] = 0; swap(good[i], v); } } while ( q --) { cin >> t >> m; for ( i = 1; i <= m; i ++) { cin >> c[i]; cant[c[i]] = 1; } ans = -1; if ( m <= 350) { for ( pll &A : good[t]) { if (!cant[A.second]) { ans = A.first; break; } } if (!cant[t]) ans = max(ans, int(0)); } else { for (i = 1; i <= n; i ++) dp[i] = -1; dp[t]= 0; if (!cant[t]) ans = 0; for (i = t; i >= 1; i --) { for ( int X : adj[i]) { if ( dp[X] != -1) dp[i] = max(dp[i], dp[X] + 1); } if ( !cant[i]) ans =max(ans, dp[i]); } } 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:28:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    while ( good[i].size() < 350 && (i1 < good[i].size() || I1 < good[I].size())) {
      |                                     ~~~^~~~~~~~~~~~~~~~
bitaro.cpp:28:63: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    while ( good[i].size() < 350 && (i1 < good[i].size() || I1 < good[I].size())) {
      |                                                            ~~~^~~~~~~~~~~~~~~~
bitaro.cpp:29:12: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     if (i1 == good[i].size() || (I1 != good[I].size() && good[I][I1].first + 1 >= good[i][i1].first )) {
      |         ~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:29:37: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     if (i1 == good[i].size() || (I1 != good[I].size() && good[I][I1].first + 1 >= good[i][i1].first )) {
      |                                  ~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:41:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     while (i1 < good[i].size() && used[good[i][i1].second]) i1 ++;
      |            ~~~^~~~~~~~~~~~~~~~
bitaro.cpp:42:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     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...