# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1152898 | PieArmy | Bitaro’s Party (JOI18_bitaro) | C++20 | 2029 ms | 246640 KiB |
typedef long long ll;
ll pie(ll army){return (1ll<<army);}
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define mid ((left+right)>>1)
const ll inf=2000000000000000005;
const int sonsuz=2000000005;
using namespace std;
ll fpow(ll x,ll y,ll m=0){if(y<0){cout<<"powError";return -1;}if(m)x%=m;ll res=1;while(y>0){if(y&1)res*=x;x*=x;if(m){x%=m;res%=m;}y>>=1;}return res;}
int n,m,q,s=50;
vector<int>par[100023];
set<pair<int,int>>v[100023];
int Y[100023];
void code(){
cin>>n>>m>>q;
for(int i=0;i<m;i++){
int x,y;cin>>x>>y;
par[y].pb(x);
}
for(int i=1;i<=n;i++){
map<int,int>mp;
mp[i]=0;
v[i].insert({0,i});
for(int x:par[i]){
for(auto y:v[x]){
int &z=mp[y.sc];
if(z<y.fr+1){
v[i].erase({z,y.sc});
z=y.fr+1;
v[i].insert({z,y.sc});
if(v[i].size()>s){
mp.erase(v[i].begin()->sc);
v[i].erase(v[i].begin());
}
}
}
}
}
while(q--){
int t,y;cin>>t>>y;
vector<int>busy;
for(int i=0;i<y;i++){
int x;cin>>x;
busy.pb(x);
Y[x]=-1;
}
int ans=-1;
for(auto x:v[t]){
if(Y[x.sc]==0){
ans=max(ans,x.fr);
}
}
if(ans!=-1){
cout<<ans<<endl;
for(int x:busy){
Y[x]=0;
}
continue;
}
for(int i=1;i<=t;i++){
for(int x:par[i]){
if(Y[x]!=-1&&Y[x]+1>Y[i]){
Y[i]=Y[x]+1;
}
}
}
cout<<Y[t]<<endl;
for(int i=1;i<=t;i++){
Y[i]=0;
}
for(int x:busy){
Y[x]=0;
}
}
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
int t=1;
if(!t)cin>>t;
while(t--){code();}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |