QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#346048#6836. A Plus B ProblemjiamengtongWA 1ms9896kbC++141.7kb2024-03-07 20:00:372024-03-07 20:00:38

Judging History

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

  • [2024-03-07 20:00:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9896kb
  • [2024-03-07 20:00:37]
  • 提交

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;
	}
	int t = a[1][n - 1];
	for(int i = 1, r, c, d; i <= q; i++)
	{
		scanf("%d%d%d", &r, &c, &d);
		c = n - c + 1;
		if(a[r][c] == d) 
		{
			printf("%d 0\n", (a[3][c] + bk[c]) % 10);
			continue;
		}
//		cout << "LOOK AT HERE:" << i << " " << bk[10] << endl;
		int ans = 1; 
		a[r][c] = d;
//		cout << c << " " << bk[4] << endl;
		int tk = bk[c], ps = c;
//		for(int j = 1; j <= n; j++) cout << a[1][j];
//		cout << endl; 
//		for(int j = 1; j <= n; j++) cout << a[2][j];
//		cout << endl;
		bool fl;
		do{
			int nw = a[1][ps] + a[2][ps] + tk;
			if(n == 1000000 && t == 1 && i == 2) cout << "Case:" << i << " " << c << " " << d << " " << ps << " " << nw << " " << tk << endl;
			int oritk = tk;
			tk = (nw > 9);
//			cout << ps + 1 << endl;
			nw %= 10;
			fl = 0;
			cout << a[3][ps] << " " << bk[ps] << endl;
			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] = tk;
		printf("%d %d\n", a[3][c] + bk[c], ans);
	}
//	for(int i = 1; i <= n; i++) cout << a[1][n - i + 1];
//	cout << endl; 
//	for(int i = 1; i <= n; i++) cout << a[2][n - i + 1];
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 9896kb

input:

5 5
01234
56789
2 1 0
2 2 1
2 3 2
2 4 3
2 5 4

output:

5 0
0 2
7 1
0 0
3 2
9 1
2 1
0 0
5 3
1 1
4 1
2 0
7 3
3 0
6 1
4 0
8 3

result:

wrong answer 1st lines differ - expected: '0 2', found: '5 0'