이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define task "test"
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define bit(s, i) (((s) >> (i)) & 1)
#define ii pair <int, int>
#define fi first
#define se second
#define ll long long
#define eb emplace_back
#define pb push_back
#define __builtin_popcount __builtin_popcountll
void solve();
int32_t main() {
if(fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
solve();
}
const int N=1e5+5;
const int B=90;
const int INF=1e9;
int n, m, q, ban[N], dp[N], res[N];
vector<int>adj[N];
vector<ii> largest[N];
void solve() {
cin>>n>>m>>q;
FOR(i,1,m){
int a,b; cin>>a>>b;
adj[b].eb(a);
}
vector<ii>tmp;
memset(res,-0x3f,sizeof(res));
FOR(i,1,n){
tmp.clear();
tmp.eb(-1, i); res[i] = -1;
for(int j:adj[i]){
for(ii k:largest[j]) {
if(k.fi>res[k.se]) tmp.eb(k);
res[k.se]=max(res[k.se], k.fi);
}
}
for(ii j:tmp){
if(res[j.se] == j.fi){
largest[i].eb(j);
res[j.se]=-INF;
}
}
sort(all(largest[i]), greater<ii>());
while(sz(largest[i]) > B) largest[i].pop_back();
for(ii &j:largest[i]) ++j.fi;
}
vector<int>c;
FOR(i,1,q){
int t,y; cin>>t>>y;
c.resize(y);
for(int &j:c) {
cin>>j;
ban[j]=true;
}
if(y<=90){
int mx=0;
for(ii j:largest[t]){
// cout<<j.fi<<" "<<j.se<<'\n';
if(!ban[j.se]){
mx=max(mx,j.fi);
}
}
cout<<mx;
}
else{
FOR(j,1,t){
if(ban[j]) dp[j]=-n;
else dp[j]=0;
for(int k:adj[j]){
dp[j]=max(dp[j],dp[k]+1);
}
}
cout<<max(dp[t],-1);
}
cout<<'\n';
for(int j:c) ban[j]=false;
}
}
컴파일 시 표준 에러 (stderr) 메시지
bitaro.cpp: In function 'int32_t main()':
bitaro.cpp:23:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:24:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |