이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
LANG: C++
PROBLEM:
*/#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
ll mod=1e9+7;
ll a[1000005],b[1000005],l,x,y,z,r,ans[1000005],ans1,t,n,mx,k,ind1,ind2,ind3,m,q;
vector <ll> v[1000005];
pair <ll,ll> p[1000005];
pair <ll, pair<ll,ll> > p1[1000005];
string s,s1;
bool ok;
void gvanca(ll x,ll y){
if (x<y){
for (int i=0; i<v[x].size(); i++){
if (v[x][i]>y) continue;
ans[v[x][i]]=max(ans[v[x][i]],ans[x]+1); if (v[x][i]==y) ans1=max(ans[v[x][i]],ans1); gvanca(v[x][i],y);
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>m>>q;
for (int i=1; i<=m; i++){
cin>>x>>y;
v[x].pb(y);
}
while (q--){
cin>>x>>y;
for (int i=1; i<=y; i++) {
cin>>z; b[z]=1;
} ans1=-1;
for (int i=1; i<=x; i++){
if (b[i]==1) {
b[i]=0;continue; }if (i==x) {
ans1=max(ans1,0ll); continue;
}
z=0; ans[i]=0;
// for (int j=i; j<=x; j++) ans[j]=0;
gvanca(i,x);
// cout<<ans1<<" "<<i<<endl;
}
cout<<ans1<<endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
bitaro.cpp: In function 'void gvanca(long long int, long long int)':
bitaro.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int i=0; i<v[x].size(); i++){
| ~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |