QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402015#2271. High-Tech Detectivedohoon#WA 27ms3948kbC++171.9kb2024-04-29 19:09:292024-04-29 19:09:30

Judging History

你现在查看的是最新测评结果

  • [2024-04-29 19:09:30]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3948kb
  • [2024-04-29 19:09:29]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> pi;
typedef long long ll;
int n;
pair <char,int> ta[10005],a[10005];
ll d[2][5005];
ll mod = 1e9+7;
int c[5005];
int s[4][5005]; // I,nI,O,nO

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1;i <= 2*n;i++) {
        cin >> ta[i].x >> ta[i].y;
        c[ta[i].y] += 1;
    }
    int m = 0;
    for(int i = 1;i <= 2*n;i++) {
        if(c[ta[i].y] == 2) continue;
        a[++m] = ta[i];
    }
    n = m/2;
    d[0][0] = 1;
    for(int i = 1;i <= n*2;i++) {
        for(int j = 0;j < 4;j++) s[j][i] = s[j][i-1];
        int op = 0;
        if(a[i].x == 'O') op += 2;
        if(!a[i].y) op += 1;
        s[op][i]++;
    }
    int nam = n-s[0][n*2]-s[2][n*2];
    for(int i = 1;i <= n*2;i++) {
        char op = a[i].x;
        int val = a[i].y,I,nI;
        //cout << op << ' ' << val << '\n';
        for(int j = 0;j <= s[1][i]-s[2][i];j++) {
            I = s[0][i-1]-s[3][i-1]+j;
            nI = s[1][i-1]-s[2][i-1]-j+1;
            
            if(op == 'I') {
                d[i%2][j] = d[(i-1)%2][j];
                if(!val) d[i%2][j] = 1LL*d[(i-1)%2][j]%mod;
            }
            else if(!val) {
                d[i%2][j] = (1LL*d[(i-1)%2][j]*I%mod + 1LL*d[(i-1)%2][j-1]*nI%mod*(nam+1-j)%mod)%mod;
            }
            else {
                d[i%2][j] = d[(i-1)%2][j]*(nI-1)%mod;
            }
            //cout << d[i%2][j] << ' ';
            //cout << I << ' ' << nI << " : " << d[i%2][j] << '\n';
        }
        //cout << '\n';
        for(int j = 0;j <= n;j++) {
            d[(i-1)%2][j] = 0;
        }
        //if(op == 'I'&&!val) nam--;
    }
    ll ans = 0;
    for(int i = 0;i <= n;i++) ans = (ans+d[0][i])%mod;
    cout << ans;
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3676kb

input:

4
I 1
I 0
O 0
I 0
O 2
I 4
O 0
O 4

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

3
I 0
I 0
I 0
O 0
O 0
O 0

output:

36

result:

ok single line: '36'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1
I 0
O 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

2
I 0
I 1
O 1
O 0

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

4
I 0
I 0
O 0
O 0
I 0
I 3
O 0
O 0

output:

24

result:

ok single line: '24'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

8
I 0
I 0
I 0
I 8
I 4
I 0
O 1
I 0
O 8
O 4
I 5
O 0
O 0
O 5
O 0
O 7

output:

576

result:

ok single line: '576'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

16
I 5
I 4
I 2
I 1
I 10
I 6
I 14
I 3
I 11
I 7
I 16
O 0
O 7
I 15
O 1
I 8
I 12
O 4
O 11
O 0
I 13
O 14
O 12
O 13
I 0
O 5
O 0
O 0
O 0
O 0
O 0
O 3

output:

2400

result:

ok single line: '2400'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

50
I 42
I 32
I 29
I 14
I 27
I 0
I 9
I 18
I 11
I 25
O 31
I 39
I 41
I 23
I 43
I 1
I 35
O 25
I 44
I 5
I 28
I 48
I 33
I 50
I 21
I 19
O 29
O 33
O 19
O 44
I 17
I 6
O 32
O 23
I 30
O 42
I 13
O 27
I 20
I 34
I 15
O 17
O 30
I 36
O 0
I 0
I 10
O 21
O 36
I 40
O 34
O 9
I 4
O 20
O 14
I 47
O 1
I 22
O 50
I 26
I 24
I ...

output:

2

result:

ok single line: '2'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

300
I 117
I 122
I 64
I 166
I 65
I 70
I 81
I 180
I 270
I 211
I 191
I 95
I 103
I 271
O 180
I 161
I 108
I 149
I 175
I 79
I 225
I 141
I 146
I 240
I 168
I 227
I 233
I 75
I 286
I 7
I 43
I 246
I 285
I 63
I 73
I 282
I 269
I 36
I 291
I 2
I 55
I 41
O 73
I 170
I 25
I 196
I 220
I 33
I 165
I 203
O 70
I 153
I 289...

output:

12

result:

ok single line: '12'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

300
I 235
I 3
I 248
I 144
I 232
I 60
I 80
I 52
I 141
I 297
I 84
I 48
I 264
I 217
I 118
I 260
I 151
I 206
I 288
I 268
I 191
I 159
I 107
I 261
I 293
I 188
I 114
I 145
I 55
I 239
I 49
I 2
I 64
I 243
I 75
I 189
I 146
I 255
I 121
I 17
I 179
I 32
I 286
I 53
I 37
I 46
I 276
I 278
I 51
I 106
I 197
O 17
I 19...

output:

18

result:

ok single line: '18'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

100
I 8
I 51
I 60
I 48
I 79
I 90
I 42
I 15
I 29
I 21
I 33
I 68
I 91
I 73
I 30
I 12
I 96
I 74
I 95
I 54
I 40
I 7
I 45
I 44
I 28
I 2
I 22
I 23
I 20
I 72
I 63
I 67
I 13
O 22
I 88
I 32
I 24
I 17
I 70
I 16
O 16
I 56
I 97
I 86
I 89
O 0
I 61
I 3
I 19
O 0
O 0
I 11
O 0
O 0
I 47
I 100
I 64
I 92
I 82
O 97
O 0
...

output:

930138667

result:

ok single line: '930138667'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3732kb

input:

100
I 0
I 0
I 0
I 0
I 0
I 99
I 0
I 0
O 0
I 0
I 84
I 0
I 29
I 0
I 0
I 0
I 0
I 22
O 0
I 4
O 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
O 0
O 0
I 95
I 0
O 38
I 0
I 0
I 0
I 31
I 0
I 0
I 0
O 0
I 0
I 32
O 0
I 0
I 65
O 0
I 0
I 0
I 0
I 0
O 0
I 28
O 0
I 0
I 0
I 0
I 0
O 0
I 0
I 47
O 0
I 17
O 0
I 0
I 39
I 0
I 0
I 42
I ...

output:

506186867

result:

ok single line: '506186867'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

100
I 19
I 10
I 0
I 0
I 45
I 34
I 0
I 4
I 26
I 62
I 0
I 0
I 73
I 0
I 0
O 92
I 0
I 0
I 78
I 0
I 31
I 9
I 98
I 95
I 20
I 49
I 0
I 32
I 0
O 10
O 0
I 0
I 11
I 16
I 0
I 58
I 0
I 0
I 0
I 46
O 0
I 35
I 18
I 0
I 43
I 97
I 0
I 3
I 0
O 0
I 38
I 100
I 37
O 0
I 0
I 0
O 0
I 50
I 29
I 0
I 48
O 29
O 64
I 0
O 3
O 0...

output:

640219459

result:

ok single line: '640219459'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

100
I 31
I 4
I 78
I 9
I 5
I 63
I 66
I 0
O 66
I 0
I 70
I 88
I 64
I 28
I 74
I 0
I 79
I 94
I 75
O 88
I 0
O 0
I 40
I 97
I 83
I 0
I 25
I 44
I 29
I 2
I 80
I 67
I 0
O 67
I 7
O 41
I 62
I 20
I 90
I 19
O 75
I 0
I 0
I 17
I 16
I 0
O 99
I 91
I 61
I 95
O 16
I 92
O 31
I 55
I 85
O 9
I 81
I 0
I 0
I 98
O 63
O 98
I 0
...

output:

720956479

result:

ok single line: '720956479'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

200
I 154
I 187
I 164
I 0
I 0
I 0
I 168
I 116
I 162
I 142
I 0
I 0
I 41
I 48
I 68
O 0
I 16
I 0
I 0
I 30
I 90
O 162
I 96
I 151
I 121
I 0
I 177
I 0
I 0
I 130
O 193
I 0
I 10
I 15
I 0
I 31
O 41
I 190
I 0
I 0
I 81
I 128
I 33
I 166
I 0
I 28
I 0
I 118
I 100
I 199
I 0
I 0
I 14
I 105
I 119
O 0
I 73
I 0
I 26
I...

output:

125161791

result:

ok single line: '125161791'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

200
I 187
I 131
I 111
I 107
I 35
I 12
I 175
I 197
I 82
I 143
I 42
I 17
I 8
I 141
I 139
I 50
I 122
I 36
I 66
I 96
I 182
I 101
O 0
I 126
I 118
O 0
I 147
I 93
I 116
I 191
I 100
I 156
I 58
I 95
I 165
I 30
I 6
I 7
I 49
I 186
I 198
I 26
I 77
I 16
I 150
I 123
I 10
I 176
I 14
I 83
I 81
I 138
I 39
I 61
I 5
I...

output:

76110076

result:

ok single line: '76110076'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

200
I 0
I 0
I 33
I 13
I 0
I 0
I 0
I 141
I 132
I 0
I 0
I 171
I 0
I 0
I 0
I 22
I 0
I 0
I 0
I 0
I 104
I 90
I 74
I 0
I 0
I 0
I 180
I 0
O 0
I 15
I 0
I 26
I 0
I 0
I 70
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 67
I 0
I 199
I 0
I 94
I 0
O 0
I 0
O 0
I 0
I 101
I 0
I 0
I 0
I 0
I 136
I 96
I 178
I 9
I 78
I 0
O 0
I 36
I 0
O...

output:

816352373

result:

ok single line: '816352373'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

300
I 142
I 117
I 3
I 101
I 201
I 0
I 104
I 251
I 230
I 198
I 0
I 83
I 203
I 0
I 255
I 102
I 0
I 11
I 0
I 0
I 157
I 0
I 0
I 211
I 109
I 0
I 279
I 204
I 124
O 104
I 0
I 0
I 0
I 18
I 44
I 0
I 33
I 268
I 0
I 36
I 60
I 207
I 224
I 70
I 223
I 75
I 0
I 103
I 195
I 0
I 0
I 122
I 96
I 111
I 0
I 138
I 0
I 7
...

output:

181020105

result:

ok single line: '181020105'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

300
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
O 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
O 0
I 0
I 0
I 0
I 0
I 0
I 281
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 32
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
O 0
I 0
I 0
I 0
I 0
I 0
I...

output:

14169673

result:

ok single line: '14169673'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

300
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
O 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
O 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
I 0
O 0
I 0
I 0
O 0
I 0
I 0
I 0
I 0
I 0
...

output:

999057162

result:

ok single line: '999057162'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

1000
I 0
I 446
I 327
I 910
I 547
I 0
I 0
I 933
I 28
I 119
I 0
I 0
I 0
I 559
I 0
I 30
I 0
I 63
I 776
I 838
I 260
I 0
I 0
I 433
I 14
I 78
I 0
I 0
I 89
O 596
I 566
I 594
I 68
I 0
I 615
I 634
I 616
I 0
I 47
I 0
I 0
I 493
I 524
I 708
I 832
I 940
I 858
I 759
I 276
I 309
I 440
I 918
I 0
I 188
I 945
I 0
I 0...

output:

891071351

result:

ok single line: '891071351'

Test #22:

score: 0
Accepted
time: 3ms
memory: 3692kb

input:

2000
I 0
I 1229
I 0
I 250
I 729
I 422
I 0
I 67
I 1260
I 0
I 1562
I 121
I 0
I 702
I 175
I 581
I 16
I 0
I 1646
I 816
I 0
I 0
I 1694
I 979
I 0
I 1405
I 307
I 1459
I 402
I 1809
I 1069
I 0
I 447
I 0
I 618
I 855
I 280
I 73
I 668
I 0
I 452
O 816
I 0
I 312
I 1365
I 819
I 248
I 546
I 460
I 1390
I 0
I 1164
I ...

output:

982485283

result:

ok single line: '982485283'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

3000
I 2124
I 211
I 2096
I 2695
I 0
I 68
I 129
I 2199
I 1900
I 0
I 0
I 2754
I 981
I 483
I 1618
I 1196
I 1568
I 1363
I 0
I 1313
I 0
I 188
I 186
I 946
I 2664
I 427
I 1512
I 1147
I 2132
I 2068
I 1815
I 1166
I 2012
I 1907
O 483
I 901
I 125
I 1806
I 2609
I 1736
I 1346
I 0
I 1886
I 1054
I 304
I 2908
I 54
...

output:

328232312

result:

ok single line: '328232312'

Test #24:

score: 0
Accepted
time: 14ms
memory: 3948kb

input:

4000
I 0
I 0
I 0
I 0
I 1795
I 1917
I 0
I 2995
I 2273
I 650
I 0
I 0
I 0
I 2599
I 2471
I 2804
I 0
I 0
I 0
I 0
I 0
I 2077
I 0
I 0
I 1705
I 0
I 898
I 0
I 327
I 0
I 0
I 0
I 1968
I 0
I 0
I 3951
I 2009
I 0
I 0
I 0
I 0
I 0
I 3647
I 0
I 1239
I 1722
I 3396
I 2936
I 2847
I 842
I 0
I 379
I 0
I 1469
I 0
I 3251
I...

output:

865132421

result:

ok single line: '865132421'

Test #25:

score: -100
Wrong Answer
time: 27ms
memory: 3868kb

input:

5000
I 2314
I 4430
I 2571
I 4546
I 637
I 4407
I 2219
I 3825
I 4463
I 0
I 273
I 3676
I 1175
I 4150
I 4135
I 143
I 4223
I 4899
I 4710
I 0
I 1706
I 0
I 4299
I 4083
I 3968
I 1030
I 0
I 1576
I 715
I 0
I 2909
I 0
I 1705
I 0
I 0
I 1211
I 4152
I 1609
I 1600
I 4516
I 1927
I 0
I 4551
I 782
I 2009
I 2707
I 0
I...

output:

70044680

result:

wrong answer 1st lines differ - expected: '815479637', found: '70044680'