QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#346028#6836. A Plus B ProblemjiamengtongCompile Error//C++141.9kb2024-03-07 19:51:232024-03-07 19:51:24

Judging History

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

  • [2024-03-07 19:51:24]
  • 评测
  • [2024-03-07 19:51:23]
  • 提交

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

answer.code: In function ‘int main()’:
answer.code:52:140: error: expected primary-expression before ‘<<’ token
   52 |                         if(n == 1000000 && t == 1) cout << "Case:" << i << " " << c << " " << d << " " << ps << " " << nw << " " << tk <<  << endl;
      |                                                                                                                                            ^~
answer.code:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d%d", &n, &q);
      |         ~~~~~^~~~~~~~~~~~~~~~
answer.code:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%s", c + 1);
      |         ~~~~~^~~~~~~~~~~~~
answer.code:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%s", c + 1);
      |         ~~~~~^~~~~~~~~~~~~
answer.code:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |                 scanf("%d%d%d", &r, &c, &d);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~