| Task: | Laskutoimitus |
| Sender: | Kuha |
| Submission time: | 2025-12-20 17:46:36 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 15 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 5 |
| #2 | WRONG ANSWER | 0 |
| #3 | ACCEPTED | 10 |
| #4 | WRONG ANSWER | 0 |
| #5 | WRONG ANSWER | 0 |
| #6 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 1, 2, 6 | details |
| #2 | ACCEPTED | 0.00 s | 1, 2, 6 | details |
| #3 | ACCEPTED | 0.01 s | 1, 2, 3, 4, 5, 6 | details |
| #4 | WRONG ANSWER | 0.00 s | 2, 6 | details |
| #5 | WRONG ANSWER | 0.00 s | 2, 6 | details |
| #6 | ACCEPTED | 0.00 s | 2, 3, 4, 5, 6 | details |
| #7 | WRONG ANSWER | 0.06 s | 6 | details |
| #8 | WRONG ANSWER | 0.06 s | 6 | details |
| #9 | ACCEPTED | 0.06 s | 3, 4, 5, 6 | details |
| #10 | WRONG ANSWER | 0.06 s | 4, 6 | details |
| #11 | WRONG ANSWER | 0.06 s | 4, 6 | details |
| #12 | WRONG ANSWER | 0.06 s | 5, 6 | details |
| #13 | WRONG ANSWER | 0.06 s | 5, 6 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:83:20: warning: unused variable 'dl' [-Wunused-variable]
83 | ll dl = i - pl[i];
| ^~Code
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
using namespace std;
ll pot[1111111];
ll pots[1111111];
ll vl[1111111];
ll vr[1111111];
ll pl[1111111];
ll pr[1111111];
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
string s;
cin>>s;
s = "+" + s + "+";
int n = s.length();
pot[0] = 1;
for (int i = 1; i <= n; i++) {
pot[i] = (10 * pot[i - 1]) % M;
}
pots[0] = pot[0];
for (int i = 1; i <= n; i++) {
pots[i] = pots[i - 1] + pot[i];
pots[i] %= M;
}
if (n <= 5000) {
ll ans = 0;
for (int i = 0; i < n; i++) {
ll val = 0;
ll prod = 1;
ll sum = 0;
if (s[i] == '+' || s[i] == '*') continue;
for (int j = i; j < n; j++) {
if (s[j] == '+') {
prod *= val;
val = 0;
sum += prod;
sum %= M;
prod = 1;
} else if (s[j] == '*') {
prod *= val;
prod %= M;
val = 0;
} else {
val = 10 * val + (s[j] - '0');
val %= M;
ans += sum + prod * val;
ans %= M;
}
}
}
cout<<ans<<endl;
} else {
int p = 0;
vl[0] = 0;
vr[0] = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '+') p = i;
pl[i] = p;
}
p = n - 1;
for (int i = 0; i < n; i++) {
if (s[n - i - 1] == '+') p = n - i - 1;
pr[n - i - 1] = p;
}
for (int i = 1; i < n; i++) {
vl[i] = vl[i - 1] + 1;
if (s[i] == '+') vl[i]--;
vr[n - i - 1] = vr[n - i] + 1;
if (s[n - i - 1] == '+') vr[n - i - 1]--;
}
ll ans = 0;
for (int i = 0; i < n; i++) {
if (s[i] != '+') {
ll dr = pr[i] - i;
ll dl = i - pl[i];
ll sy = (s[i] - '0');
ans += vl[i] * sy * pots[dr - 1];
ans += vl[i] * sy * pot[dr - 1] * (vr[i] - dr);
ans %= M;
}
}
cout<<ans<<endl;
}
}Test details
Test 1
Group: 1, 2, 6
Verdict: ACCEPTED
| input |
|---|
| *3*7*5+67*2*7*12+38*4+9+2+1+45... |
| correct output |
|---|
| 665527462 |
| user output |
|---|
| 665527462 |
Test 2
Group: 1, 2, 6
Verdict: ACCEPTED
| input |
|---|
| 84149523195388144+1*8*5*1722+5... |
| correct output |
|---|
| 572374284 |
| user output |
|---|
| 572374284 |
Test 3
Group: 1, 2, 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 347358248955243114242997746491... |
| correct output |
|---|
| 823495931 |
| user output |
|---|
| 823495931 |
Test 4
Group: 2, 6
Verdict: WRONG ANSWER
| input |
|---|
| +4976829*6+5+9*21+4*889+6*7+4*... |
| correct output |
|---|
| 503712700 |
| user output |
|---|
| 663890620 |
Feedback: Incorrect character on line 1 col 1: expected "503712700", got "663890620"
Test 5
Group: 2, 6
Verdict: WRONG ANSWER
| input |
|---|
| 862+83782+493135426+3152859674... |
| correct output |
|---|
| 624304680 |
| user output |
|---|
| 528205676 |
Feedback: Incorrect character on line 1 col 1: expected "624304680", got "528205676"
Test 6
Group: 2, 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 297736662651354417265929591745... |
| correct output |
|---|
| 625284593 |
| user output |
|---|
| 625284593 |
Test 7
Group: 6
Verdict: WRONG ANSWER
| input |
|---|
| +9+1+8+92*761+68*983*1+7*1+1*2... |
| correct output |
|---|
| 947469815 |
| user output |
|---|
| 817335533 |
Feedback: Incorrect character on line 1 col 1: expected "947469815", got "817335533"
Test 8
Group: 6
Verdict: WRONG ANSWER
| input |
|---|
| 97831833*7+4229897789494398634... |
| correct output |
|---|
| 173934151 |
| user output |
|---|
| 212318777 |
Feedback: Incorrect character on line 1 col 1: expected "173934151", got "212318777"
Test 9
Group: 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 777551563653223263644973172313... |
| correct output |
|---|
| 278364064 |
| user output |
|---|
| 278364064 |
Test 10
Group: 4, 6
Verdict: WRONG ANSWER
| input |
|---|
| +481+4+66+2+26+7+5+97+6+4+3+14... |
| correct output |
|---|
| 244847224 |
| user output |
|---|
| 743611560 |
Feedback: Incorrect character on line 1 col 1: expected "244847224", got "743611560"
Test 11
Group: 4, 6
Verdict: WRONG ANSWER
| input |
|---|
| +8858717+53+6927+314+742552843... |
| correct output |
|---|
| 928369840 |
| user output |
|---|
| 783804852 |
Feedback: Incorrect character on line 1 col 1: expected "928369840", got "783804852"
Test 12
Group: 5, 6
Verdict: WRONG ANSWER
| input |
|---|
| *7*75*59*7*9*74*4*18211*31*1*7... |
| correct output |
|---|
| 219382651 |
| user output |
|---|
| 360149878 |
Feedback: Incorrect character on line 1 col 1: expected "219382651", got "360149878"
Test 13
Group: 5, 6
Verdict: WRONG ANSWER
| input |
|---|
| 73171*3438*9*34165158853*375*7... |
| correct output |
|---|
| 451362612 |
| user output |
|---|
| 782242479 |
Feedback: Incorrect character on line 1 col 1: expected "451362612", got "782242479"
