QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#73295#4812. Counting SequenceLG_MonkeyCompile Error//C++141.1kb2023-01-23 16:16:032023-01-23 16:16:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-23 16:16:06]
  • 评测
  • [2023-01-23 16:16:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define pb push_back
#define se second
#define int long long
int n, c, f[300010][2010], g[2010][600010];
const int mod = 998244353;
signed main() {
	cin >> n >> c;
	int len = 1000;
	for (int i = 1; i <= len; i++) f[i][i] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= 2005; j++) {
			if (i <= len && i == j) continue;
			f[i][j] += f[i - j - 1][j + 1];
			if (j >= 2) (f[i][j] += f[i - j + 1][j - 1] * c % mod) %= mod;
		}
	int ans = 0;
	for (int i = 1; i <= 2005; i++) (ans += f[n][i]) %= mod;
	for (int i = 1; i <= 2005; i++)
		for (int j = 0; j <= 600000; j++) {
			int k = j - 300000;
			if (i == 0 && k == 0) {
				f[i][j] = 1; continue; 
			}
			if (j - i + 1 >= 0) f[i][j] += f[i - 1][j - i + 1];
			if (j + i - 1 <= 600000) f[i][j] += f[i - 1][j + i - 1] * c; f[i][j] %= mod;
		}
	for (int i = len + 1; i <= n; i++)
		for (int j = 1; j <= 2005; j++)
			(ans += f[j][n - i * j]) %= mod;
	cout << ans << "\n";
	return 0;
} 

Details

answer.code: In function ‘int main()’:
answer.code:30:94: warning: iteration 2010 invokes undefined behavior [-Waggressive-loop-optimizations]
   30 |                         if (j + i - 1 <= 600000) f[i][j] += f[i - 1][j + i - 1] * c; f[i][j] %= mod;
      |                                                                                      ~~~~~~~~^~~~~~
answer.code:24:35: note: within this loop
   24 |                 for (int j = 0; j <= 600000; j++) {
      |                                 ~~^~~~~~~~~
/tmp/cchBCr0D.o: in function `main':
answer.code:(.text.startup+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchBCr0D.o
answer.code:(.text.startup+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cchBCr0D.o
answer.code:(.text.startup+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/cchBCr0D.o
answer.code:(.text.startup+0xab): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchBCr0D.o
answer.code:(.text.startup+0xb2): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cchBCr0D.o
answer.code:(.text.startup+0xc2): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/cchBCr0D.o
answer.code:(.text.startup+0x195): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/cchBCr0D.o
answer.code:(.text.startup+0x338): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/cchBCr0D.o
/tmp/cchBCr0D.o: in function `_GLOBAL__sub_I_n':
answer.code:(.text.startup+0x5c8): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status