제출 #62550

#제출 시각아이디문제언어결과실행 시간메모리
62550gusfringBitaro’s Party (JOI18_bitaro)C++14
14 / 100
1967 ms110968 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define fi first #define se second const int mxN=1e5, bs=80; int n, m, q, dp2[mxN], c[mxN]; vector<int> adj[mxN]; vector<pii> dp1[mxN]; priority_queue<pii, vector<pii>, greater<pii>> pq; bool a[mxN]; int main() { scanf("%d %d %d", &n, &m, &q); while(m--) { int u, v; scanf("%d %d", &u, &v); --u, --v; adj[v].push_back(u); } for(int i=0; i<n; ++i) { pq.push({0, i}); for(int v : adj[i]) { for(pii p : dp1[v]) { pq.push({p.fi+1, p.se}); if(pq.size()>bs) pq.pop(); } } while(!pq.empty()) { dp1[i].push_back(pq.top()); pq.pop(); } } while(q--) { int t, y, ans=-1; scanf("%d %d", &t, &y); --t; for(int i=0; i<y; ++i) { scanf("%d", &c[i]); --c[i]; a[c[i]]=1; } if(y>bs) { memset(dp2, -1, 4*(t+1)); for(int i=0; i<=t; ++i) { dp2[i]=a[i]?-n:0; for(int v : adj[i]) dp2[i]=max(dp2[v]+1, dp2[i]); } ans=max(dp2[t], ans); } else { for(int i=dp1[t].size()-1; i>=0; --i) { if(a[dp1[t][i].se]) continue; ans=dp1[t][i].fi; break; } } for(int i=0; i<y; ++i) a[c[i]]=0; printf("%d\n", ans); } return 0; }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:16:7: 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:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &u, &v);
   ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &t, &y);
   ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:42:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &c[i]);
    ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...