QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#278446#6836. A Plus B ProblemrageOfThunder#WA 184ms7836kbC++142.1kb2023-12-07 16:15:192023-12-07 16:15:19

Judging History

你现在查看的是最新测评结果

  • [2023-12-07 16:15:19]
  • 评测
  • 测评结果:WA
  • 用时:184ms
  • 内存:7836kb
  • [2023-12-07 16:15:19]
  • 提交

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> tt;//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
		if (b[i] != 9) 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);
		if (old != 9) tt.erase(c);
		b[c] -= a[r][c];
		b[c] += (a[r][c] = d);
		d = b[c];
		if (d != 9) tt.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 - max(1, *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 - max(1, *prev(tt.lower_bound(c)));
				}
				cout << s;
			}
		}
		cout << '\n';
	}
	return 0;
}
/* why?
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 7836kb

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: 7756kb

input:

1 1
1
1
1 1 9

output:

0 2

result:

ok single line: '0 2'

Test #3:

score: -100
Wrong Answer
time: 184ms
memory: 7776kb

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 0
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 3
3 3
7 2
7 3
0 2
9 3
6 4
0 0
1 3
4 2
7 3
0 3
8 3
8 3
8 2
2 0
3 3
0 3
2 3
5 2
9 2
4 2
8 2
3 3
5 3
3 2
5 0
4 2
3 2
1 2
4 2
7 3
0 2
5 2
6 2
0 3
4 2
4 2
3 2
5 3
6 3
3 0
8 2
9 3
9 3
1 2
1 3
7 2
5 2
5 2
4 0
0 2
...

result:

wrong answer 70th lines differ - expected: '1 4', found: '1 3'