QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524170#5532. KangarooRong76 1ms4100kbC++141.8kb2024-08-19 11:30:572024-08-19 11:30:57

Judging History

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

  • [2024-08-19 11:30:57]
  • 评测
  • 测评结果:6
  • 用时:1ms
  • 内存:4100kb
  • [2024-08-19 11:30:57]
  • 提交

answer

// Go in my style.
// Not afraid to dark.

#include <bits/stdc++.h>
using namespace std;

clock_t start_time, end_time;
#define GET_START start_time = clock ();
#define GET_END end_time = clock (); fprintf (stderr, "TIME COSSEMED : %0.3lf\n", 1.0 * (end_time - start_time) / CLOCKS_PER_SEC);
#define inline __inline__ __attribute__ ((always_inline))

#define int long long

namespace io {
    int read_pos, read_dt; char read_char;
    inline int read (int &p = read_pos){
        p = 0, read_dt = 1; read_char = getchar ();
        while (! isdigit (read_char)){
            if (read_char == '-')
                read_dt = - 1;
            read_char = getchar ();
        }
        while (isdigit (read_char)){
            p = (p << 1) + (p << 3) + read_char - 48;
            read_char = getchar ();
        }
        return p = p * read_dt;
    }
    int write_sta[65], write_top;
    inline void write (int x){
        if (x < 0)
            putchar ('-'), x = - x;
        write_top = 0;
        do
            write_sta[write_top ++] = x % 10, x /= 10;
        while (x);
        while (write_top)
            putchar (write_sta[-- write_top] + 48);
    }
}

const int N = 2e3, mod = 998244353;
int n, s, t, f[N + 5][N + 5];

signed main (){
	GET_START
	
//	freopen ("kangaroo.in", "r", stdin);
//	freopen ("kangaroo.out", "w", stdout);
	
	
	io::read (n), io::read (s), io::read (t);
	
	f[0][0] = 1;
	for (int i = 1;i <= n;++ i)
		for (int j = 0;j <= n;++ j)
			if (i == s || i == t)
				f[i][j] = (f[i - 1][j] + (j > 0 ? f[i - 1][j - 1] : 0)) % mod;
			else {
				f[i][j] = (f[i][j] + f[i - 1][j + 1] * j % mod) % mod;
				if (j > 0)
					f[i][j] = (f[i][j] + f[i - 1][j - 1] * (j - (i > s) - (i > t)) % mod) % mod;
			}
	io::write (f[n][1]), putchar ('\n');
	
	GET_END
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 0ms
memory: 4048kb

input:

7 3 6

output:

14

result:

ok 1 number(s): "14"

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #2:

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

input:

39 36 32

output:

969994766

result:

wrong answer 1st numbers differ - expected: '964903316', found: '969994766'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%