QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#511340 | #6836. A Plus B Problem | ucup-team3474 | WA | 0ms | 3820kb | C++23 | 2.2kb | 2024-08-09 19:16:23 | 2024-08-09 19:16:24 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>=(k);--i)
#define mem(a, b) memset(a,b,sizeof(a))
#define endl '\n'
#define pii pair<int,int>
#define int long long
#define lson (p<<1)
#define rson (p<<1|1)
const int mod=998244353, NMAX=1e6+5, INF=0x3f3f3f3f3f3f3f3f;
using namespace std;
void solve()
{
int n, q;
cin >> n >> q;
vector <int> a(n+1), b(n+1), c(n+1), jw(n+2);
per(i, n, 1) {
char x;
cin >> x;
a[i] = x-'0';
}
per(i, n, 1) {
char x;
cin >> x;
b[i] = x-'0';
}
rep(i, 1, n) {
c[i] = (jw[i]+a[i]+b[i])%10;
jw[i+1] = (jw[i]+a[i]+b[i])/10;
}
// per(i, n, 1) cout << jw[i]; cout << endl;
rep(k, 1, q) {
int r, i, d, cnt = 0;
cin >> r >> i >> d;
i = n-i+1;
int cc = i;
if(r == 1) {
if(a[i] != d)
cnt ++;
a[i] = d;
if((d + b[i] + jw[i])%10 != c[i])
cnt ++, c[i] = (d + b[i] + jw[i])%10;
if((d + b[i] + jw[i])/10 != jw[i+1]) {
while(i <= n && (d + b[i] + jw[i])/10 != jw[i+1]) {
jw[i+1] ^= 1;
i ++, cnt ++;
c[i] = (c[i] + 9)%10;
}
}
}
else {
if(b[i] != d)
cnt ++;
b[i] = d;
if((d + a[i] + jw[i])%10 != c[i])
cnt ++, c[i] = (d + a[i] + jw[i])%10;
if((d + a[i] + jw[i])/10 != jw[i+1]) {
while(i <= n && (d + a[i] + jw[i])/10 != jw[i+1]) {
jw[i+1] ^= 1;
i ++, cnt ++;
c[i] = (c[i] + 9)%10;
}
}
}
// cout << "a: ";per(i, n, 1) cout << a[i]; cout << endl;
// cout << "b: ";per(i, n, 1) cout << b[i]; cout << endl;
// cout << "c: ";per(i, n, 1) cout << c[i]; cout << endl;
cout << c[cc] << " " << cnt << endl;
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int _ = 1;
while(_ --)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
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: -100
Wrong Answer
time: 0ms
memory: 3480kb
input:
1 1 1 1 1 1 9
output:
0 3
result:
wrong answer 1st lines differ - expected: '0 2', found: '0 3'