QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#346061#6836. A Plus B ProblemjiamengtongWA 0ms3620kbC++142.1kb2024-03-07 20:04:282024-03-07 20:04:28

Judging History

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

  • [2024-03-07 20:04:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-03-07 20:04:28]
  • 提交

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];
//	if(n == 1000000 && t == 1)
//	{
//		for(int i = 996454; i <= 996459; i++) cout << a[1][i];
//		cout << endl;
//		for(int i = 996454; i <= 996459; i++) cout << a[2][i];
//		cout << endl;
//		for(int i = 996454; i <= 996459; i++) cout << a[3][i] << " ";
//		cout << endl;
//		for(int i = 996454; i <= 996459; i++) cout << a[3][i] + bk[i] << " ";
//		cout << endl;
//	}
	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;
//			if(n == 1000000 && t == 1 && i == 2) cout << a[3][ps] << " " << bk[ps] << endl;
			if(nw != (a[3][ps] + bk[ps]) % 10) a[3][ps] = nw - oritk, ans++, fl = 1;
			bk[ps] = oritk;
			ps++;
		}while(ps <= n && fl);
		bk[ps] = tk;
		if(i >= 500000) 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: 0ms
memory: 3620kb

input:

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

output:


result:

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