Submission #485914

# Submission time Handle Problem Language Result Execution time Memory
485914 2021-11-09T17:31:03 Z TudorIacob The grade (info1cup18_thegrade) C++14
100 / 100
33 ms 4192 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]];
        pi%=mod;
        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 Correct 3 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 20 ms 3252 KB Output is correct
3 Correct 20 ms 3508 KB Output is correct
4 Correct 19 ms 3556 KB Output is correct
5 Correct 19 ms 3276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 21 ms 3312 KB Output is correct
3 Correct 24 ms 3276 KB Output is correct
4 Correct 23 ms 3400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 20 ms 3252 KB Output is correct
7 Correct 20 ms 3508 KB Output is correct
8 Correct 19 ms 3556 KB Output is correct
9 Correct 19 ms 3276 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 21 ms 3312 KB Output is correct
12 Correct 24 ms 3276 KB Output is correct
13 Correct 23 ms 3400 KB Output is correct
14 Correct 3 ms 2692 KB Output is correct
15 Correct 20 ms 4060 KB Output is correct
16 Correct 19 ms 4056 KB Output is correct
17 Correct 20 ms 4044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 20 ms 3252 KB Output is correct
3 Correct 20 ms 3508 KB Output is correct
4 Correct 19 ms 3556 KB Output is correct
5 Correct 19 ms 3276 KB Output is correct
6 Correct 21 ms 3604 KB Output is correct
7 Correct 23 ms 3660 KB Output is correct
8 Correct 33 ms 3516 KB Output is correct
9 Correct 20 ms 3532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 21 ms 3312 KB Output is correct
3 Correct 24 ms 3276 KB Output is correct
4 Correct 23 ms 3400 KB Output is correct
5 Correct 20 ms 3768 KB Output is correct
6 Correct 25 ms 3888 KB Output is correct
7 Correct 28 ms 4132 KB Output is correct
8 Correct 21 ms 3660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 20 ms 3252 KB Output is correct
7 Correct 20 ms 3508 KB Output is correct
8 Correct 19 ms 3556 KB Output is correct
9 Correct 19 ms 3276 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 21 ms 3312 KB Output is correct
12 Correct 24 ms 3276 KB Output is correct
13 Correct 23 ms 3400 KB Output is correct
14 Correct 3 ms 2692 KB Output is correct
15 Correct 20 ms 4060 KB Output is correct
16 Correct 19 ms 4056 KB Output is correct
17 Correct 20 ms 4044 KB Output is correct
18 Correct 21 ms 3604 KB Output is correct
19 Correct 23 ms 3660 KB Output is correct
20 Correct 33 ms 3516 KB Output is correct
21 Correct 20 ms 3532 KB Output is correct
22 Correct 20 ms 3768 KB Output is correct
23 Correct 25 ms 3888 KB Output is correct
24 Correct 28 ms 4132 KB Output is correct
25 Correct 21 ms 3660 KB Output is correct
26 Correct 22 ms 4192 KB Output is correct
27 Correct 22 ms 4172 KB Output is correct
28 Correct 22 ms 4148 KB Output is correct
29 Correct 21 ms 4112 KB Output is correct
30 Correct 23 ms 4136 KB Output is correct