QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124827#21608. 行列式NOI_AK_ME#Compile Error//C++231.4kb2023-07-15 16:17:122023-07-15 16:17:14

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 16:17:14]
  • Judged
  • [2023-07-15 16:17:12]
  • Submitted

answer


#include <bits/stdc++.h>

using namespace std; const int maxn = 6e2 + 5; typedef long long ll; typedef __uint128_t ulll;

char I[12000038],*J=I;
inline unsigned read()
{
	unsigned x=0;
	while(*J<48||57<*J)J++;
	while(47<*J&&*J<58)x=(x<<1)+(x<<3)+(*J++^48);
	return x;
}

int n, p, a[maxn][maxn];
const int p = 998244353;
int main()
{
	fread(I,1,12000038,stdin);
	n = read();
	ulll iv = (((ulll)1) << 63) / p + bool(p & (p - 1));
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) a[i][j] = read();
	int ans = 1;
	for (int j = 1; j <= n; j++)
	{
		for (int i = j; i <= n; i++) if (a[i][j]) { if (i != j) ans = -ans, swap(a[i], a[j]); break; }
		for (int i = j + 1; i <= n; i++) while (a[i][j] % p)
		{
			int v = (a[j][j] / a[i][j]) % p;
			for (int k = j; k <= n; k++)
			{
//				assert(a[i][k] >= 0);
//				assert(a[j][k] >= 0);
				ll t = a[j][k] + (ll)a[i][k] * (p - v);
				a[j][k] = t - ((t * iv >> 63) * p);
				if (a[j][k] < 0) a[j][k] += p;
//				assert(a[j][k] >= 0);
			}
			swap(a[i], a[j]);
			ans = -ans;
//			cerr << a[i][j] << ' ' << a[j][j] << endl;
//			for (int k = j; k <= n; k++) cerr << a[i][k] << ' '; cerr << endl;
//			for (int k = j; k <= n; k++) cerr << a[j][k] << ' '; cerr << endl;
//			cerr << endl;
		}
		ans = (ll)ans * a[j][j] % p;
		if (ans == 0) break;
	}
	return 0 * printf("%d\n", (ans + p) % p);
}

Details

answer.code:16:11: error: conflicting declaration ‘const int p’
   16 | const int p = 998244353;
      |           ^
answer.code:15:8: note: previous declaration as ‘int p’
   15 | int n, p, a[maxn][maxn];
      |        ^
answer.code: In function ‘int main()’:
answer.code:19:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         fread(I,1,12000038,stdin);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~