QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21688 | #881. Gig Combinatorics | abcde456 | WA | 3ms | 3592kb | C++ | 633b | 2022-03-08 03:26:05 | 2022-05-08 03:56:40 |
Judging History
answer
#include <bits/stdc++.h>
const long long m = 1000000007;
using namespace std;
void solve() {
long long n;
cin >> n;
vector<long long> v(n);
for(int i = 0; i < n; i++) cin >> v[i];
long long threes = 0;
for(int i = 0; i < n; i++) {
if(v[i] == 3) threes++;
}
long long result = 0, a = 0, b = 0, ones = 0;
for(int i = 0; i < n; i++) {
if(v[i] == 1) ones++;
else if (v[i] == 2) {
long long c = ((a + b) % m + ones) % m;
result += (c * threes) % m;
a = b;
b = c;
} else if(v[i] == 3) {
threes--;
}
}
cout << result;
}
int main(){
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
input:
9 1 1 1 2 2 2 3 3 3
output:
63
result:
ok answer is '63'
Test #2:
score: 0
Accepted
time: 3ms
memory: 3592kb
input:
8 1 2 1 2 3 1 2 3
output:
15
result:
ok answer is '15'
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 3520kb
input:
310 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 1 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 2 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 2 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 2 2 3 3 2 2 1 1 2 3 2 2 3 2 3 2 1 2 3 2 3 2 1 2 1 1 2 1 2 3 3 ...
output:
57887086069
result:
wrong answer expected '265702265', found '57887086069'