QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#278441 | #6836. A Plus B Problem | rageOfThunder# | WA | 1ms | 7540kb | C++14 | 2.0kb | 2023-12-07 16:13:22 | 2023-12-07 16:13:22 |
Judging History
answer
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T& x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T& x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
x *= f;
}
const int N = 1e6 + 10;
int n, q, a[3][N], b[N];
char gg() {
char ch = getchar();
while (!isdigit(ch)) ch = getchar();
return ch;
}
set <int> t9, tt;
signed main() {
read(n), read(q);
F(i, 1, n) {
a[1][i] = gg() - '0';
}
F(i, 1, n) {
a[2][i] = gg() - '0';
b[i] = a[1][i] + a[2][i];
if (b[i] == 9) t9.insert(i);
else tt.insert(i);
}
tt.insert(0);
tt.insert(n + 1);
while (q--) {
int r, c, d; read(r), read(c), read(d);
int old = b[c];
if (old == 9) t9.erase(c);
else tt.erase(c);
b[c] -= a[r][c];
b[c] += (a[r][c] = d);
d = b[c];
if (d == 9) t9.insert(c);
else tt.insert(c);
int pos = *tt.upper_bound(c);
// debug << c << " " << b[c] << endl;
if (b[pos] > 9) {//进位
cout << (d + 1) % 10 << ' ';
if (old == d) cout << 0;
else {
int s = 2;
if ((old >= 9 && d < 9) || (old < 9 && d >= 9)) {
// debug << "! " << c << " " << *prev(tt.lower_bound(c)) << " " << s << endl;
s += c - *prev(tt.lower_bound(c));
}
cout << s;
}
} else {
cout << b[c] % 10 << ' ';
if (old == d) cout << 0;
else {
int s = 2;
if ((old >= 10 && d < 10) || (old < 10 && d >= 10)) {
s += c - *prev(tt.lower_bound(c));
}
cout << s;
}
}
cout << '\n';
}
return 0;
}
/* why?
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7540kb
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: 7528kb
input:
1 1 1 1 1 1 9
output:
0 3
result:
wrong answer 1st lines differ - expected: '0 2', found: '0 3'