QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#345978 | #6836. A Plus B Problem | jiamengtong | WA | 182ms | 12080kb | C++14 | 1.1kb | 2024-03-07 18:49:07 | 2024-03-07 18:49:08 |
Judging History
answer
#include<bits/stdc++.h>
#define M 1000005
using namespace std;
char c[M];
int a[4][M], bk[M];
int main()
{
int n, q;
scanf("%d%d", &n, &q);
scanf("%s", c + 1);
for(int i = 1; i <= n; i++) a[1][n - i + 1] = c[i] - '0';
scanf("%s", c + 1);
for(int i = 1; i <= n; i++) a[2][n - i + 1] = c[i] - '0';
for(int i = 1; i <= n; i++)
{
a[3][i] = a[1][i] + a[2][i];
// cout << i << " " << bk[4] << endl;
bk[i + 1] += ((a[3][i] + bk[i]) > 9);
// cout << i << " " << bk[4] << endl;
a[3][i] %= 10;
// cout << i << " " << bk[4] << endl;
}
for(int i = 1, r, c, d; i <= q; i++)
{
scanf("%d%d%d", &r, &c, &d);
c = n - c + 1;
a[r][c] = d;
int ans = 1;
// cout << c << " " << bk[4] << endl;
int tk = bk[c], ps = c;
bool fl;
do{
int nw = a[1][ps] + a[2][ps] + tk;
// cout << ps << " " << nw << " " << tk << endl;
int oritk = tk;
tk = (nw > 9);
// cout << ps + 1 << endl;
nw %= 10;
fl = 0;
if(nw != a[3][ps] + bk[ps]) a[3][ps] = nw - oritk, ans++, fl = 1;
bk[ps] = oritk;
ps++;
}while(ps <= n && fl);
bk[ps + 1] = tk;
printf("%d %d\n", a[3][c] + bk[c], ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 11928kb
input:
5 5 01234 56789 2 1 0 2 2 1 2 3 2 2 4 3 2 5 4
output:
0 2 3 2 5 3 7 3 8 3
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 9888kb
input:
1 1 1 1 1 1 9
output:
0 2
result:
ok single line: '0 2'
Test #3:
score: -100
Wrong Answer
time: 182ms
memory: 12080kb
input:
10 1000000 6869373857 3130626142 1 9 2 1 10 0 2 7 6 1 1 0 1 7 6 2 10 4 2 3 9 2 4 2 2 4 4 2 7 0 1 2 4 1 9 8 1 3 7 1 7 1 1 1 5 2 1 6 1 3 5 2 5 8 2 6 5 1 6 3 1 3 8 2 4 2 2 6 3 2 2 6 1 10 9 2 1 1 2 5 4 1 1 8 2 4 0 1 9 1 1 1 8 2 4 2 2 9 2 1 10 3 1 8 9 1 4 6 2 3 0 1 1 6 1 7 1 1 10 9 2 4 4 2 5 9 2 1 8 1 9 ...
output:
6 2 2 2 9 1 3 2 2 8 4 2 6 2 2 2 4 2 6 5 6 3 2 4 7 2 2 2 8 2 1 2 5 2 1 3 2 3 8 3 8 2 2 2 6 2 1 2 3 3 7 2 7 3 0 2 9 3 6 5 0 1 1 3 4 2 7 3 0 3 8 3 8 3 8 2 2 1 3 3 0 3 2 3 4 2 9 2 4 3 7 2 3 4 5 3 3 2 5 1 4 2 2 2 1 2 4 2 7 3 9 3 5 2 5 3 0 3 4 2 3 2 3 2 5 3 6 3 3 1 9 2 9 3 9 2 1 2 2 4 7 2 5 4 5 3 4 1 0 2 ...
result:
wrong answer 3rd lines differ - expected: '9 0', found: '9 1'