Submission #485913

# Submission time Handle Problem Language Result Execution time Memory
485913 2021-11-09T17:30:00 Z TudorIacob The grade (info1cup18_thegrade) C++14
50 / 100
25 ms 4912 KB
/**
 ____ ____ ____ ____ ____
||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 time Memory Grader output
1 Incorrect 3 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2656 KB Output is correct
2 Correct 21 ms 3712 KB Output is correct
3 Correct 21 ms 4160 KB Output is correct
4 Correct 20 ms 4044 KB Output is correct
5 Correct 21 ms 3788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 22 ms 4104 KB Output is correct
3 Correct 22 ms 4048 KB Output is correct
4 Correct 22 ms 4044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2656 KB Output is correct
2 Correct 21 ms 3712 KB Output is correct
3 Correct 21 ms 4160 KB Output is correct
4 Correct 20 ms 4044 KB Output is correct
5 Correct 21 ms 3788 KB Output is correct
6 Correct 22 ms 4108 KB Output is correct
7 Correct 21 ms 4172 KB Output is correct
8 Correct 21 ms 4204 KB Output is correct
9 Correct 21 ms 4092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2636 KB Output is correct
2 Correct 22 ms 4104 KB Output is correct
3 Correct 22 ms 4048 KB Output is correct
4 Correct 22 ms 4044 KB Output is correct
5 Correct 21 ms 4684 KB Output is correct
6 Correct 23 ms 4684 KB Output is correct
7 Correct 25 ms 4912 KB Output is correct
8 Correct 21 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -