제출 #133451

#제출 시각아이디문제언어결과실행 시간메모리
133451dualityBitaro’s Party (JOI18_bitaro)C++11
100 / 100
1854 ms241872 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef long long int LLI; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vpii; vi adjList[100000],C; vpii best[100000]; int del[100000]; int dp[100000]; int main() { int i,j,k; int N,M,Q; int S,E,T,Y; scanf("%d %d %d",&N,&M,&Q); for (i = 0; i < M; i++) scanf("%d %d",&S,&E),adjList[E-1].pb(S-1); for (i = 0; i < N; i++) { best[i].pb(mp(0,i)); for (j = 0; j < adjList[i].size(); j++) { int v = adjList[i][j]; for (k = 0; k < best[v].size(); k++) best[i].pb(mp(best[v][k].first+1,best[v][k].second)); } int c = 0; sort(best[i].begin(),best[i].end(),greater<pii>()); for (j = 0; j < best[i].size(); j++) { if (!del[best[i][j].second]) best[i][c++] = best[i][j],del[best[i][j].second] = 1; } for (j = 0; j < c; j++) del[best[i][j].second] = 0; best[i].resize(min(100,c)); } for (i = 0; i < Q; i++) { scanf("%d %d",&T,&Y),T--; C.resize(Y); for (j = 0; j < Y; j++) scanf("%d",&C[j]),C[j]--,del[C[j]] = 1; for (j = 0; j < best[T].size(); j++) { if (!del[best[T][j].second]) break; } if (j < best[T].size()) printf("%d\n",best[T][j].first); else { for (j = 0; j <= T; j++) { dp[j] = del[j] ? -1e9:0; for (k = 0; k < adjList[j].size(); k++) dp[j] = max(dp[j],dp[adjList[j][k]]+1); } printf("%d\n",(dp[T] < 0) ? -1:dp[T]); } for (j = 0; j < Y; j++) del[C[j]] = 0; } return 0; }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:22:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < adjList[i].size(); j++) {
                     ~~^~~~~~~~~~~~~~~~~~~
bitaro.cpp:24:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (k = 0; k < best[v].size(); k++) best[i].pb(mp(best[v][k].first+1,best[v][k].second));
                         ~~^~~~~~~~~~~~~~~~
bitaro.cpp:28:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < best[i].size(); j++) {
                     ~~^~~~~~~~~~~~~~~~
bitaro.cpp:38:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < best[T].size(); j++) {
                     ~~^~~~~~~~~~~~~~~~
bitaro.cpp:41:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (j < best[T].size()) printf("%d\n",best[T][j].first);
             ~~^~~~~~~~~~~~~~~~
bitaro.cpp:45:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (k = 0; k < adjList[j].size(); k++) dp[j] = max(dp[j],dp[adjList[j][k]]+1);
                             ~~^~~~~~~~~~~~~~~~~~~
bitaro.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&N,&M,&Q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:19:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < M; i++) scanf("%d %d",&S,&E),adjList[E-1].pb(S-1);
                             ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:35:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&T,&Y),T--;
         ~~~~~~~~~~~~~~~~~~~~^~~~
bitaro.cpp:37:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for (j = 0; j < Y; j++) scanf("%d",&C[j]),C[j]--,del[C[j]] = 1;
                                 ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...