QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#346029#6836. A Plus B ProblemjiamengtongWA 1ms10020kbC++141.9kb2024-03-07 19:52:032024-03-07 19:52:04

Judging History

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

  • [2024-03-07 19:52:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10020kb
  • [2024-03-07 19:52:03]
  • 提交

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(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 = 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) 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

000000
000000
0 2
3 2
5 3
7 3
8 3

result:

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