Submission #485913

#TimeUsernameProblemLanguageResultExecution timeMemory
485913TudorIacobThe grade (info1cup18_thegrade)C++14
50 / 100
25 ms4912 KiB
/** ____ ____ ____ ____ ____ ||O |||M |||E |||G |||A || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| Se spune ca sunt vise Si ca nu pot fi atinse Sunt primele ce le vezi cand becurile-s stinse Dar si cand is aprinse Cand te trezesti cu ele-n gand Si le vizualizezi din nou rand pe rand Se spune ca visezi daca stai si-ti imaginezi Ca esti altfel decat ceilalti, dar nu tre sa crezi Continua sa lupti altfel imi vei da dreptate Vei bea pe spate cu gandul la vise spulberate - "Vise" - Nane - **/ #include<bits/stdc++.h> using namespace std; ifstream fin("window.in"); ofstream fout("window.out"); long long q,p,s,nr,f[100005],inv[100005],invf[100005],pi(1),fr[1000005]; const long long mod=1e9+7; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); f[0]=f[1]=inv[0]=inv[1]=invf[0]=invf[1]=1; for(long long i=2;i<=100001;i++){ f[i]=(i*f[i-1])%mod; inv[i]=(inv[mod%i]*(mod-mod/i))%mod; invf[i]=(inv[i]*invf[i-1])%mod; } cin>>q>>p; for(long long i=1;i<=q;i++){ long long o,x; cin>>o>>x; s+=((o)?-x:x); nr+=((o)?-1:1); pi*=f[fr[x]]; pi%=mod; fr[x]+=((o)?-1:1); pi*=invf[fr[x]]; if(s>p)cout<<"-1\n"; else{ cout<<(((f[p-s+nr]*invf[p-s])%mod)*pi)%mod<<"\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...