QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524172#5532. KangarooRong7100 ✓27ms35336kbC++141.8kb2024-08-19 11:31:322024-08-19 11:31:34

Judging History

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

  • [2024-08-19 11:31:34]
  • 评测
  • 测评结果:100
  • 用时:27ms
  • 内存:35336kb
  • [2024-08-19 11:31:32]
  • 提交

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 = 1e9 + 7;
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: 1ms
memory: 4072kb

input:

7 3 6

output:

14

result:

ok 1 number(s): "14"

Subtask #2:

score: 30
Accepted

Dependency #1:

100%
Accepted

Test #2:

score: 30
Accepted
time: 1ms
memory: 4152kb

input:

39 36 32

output:

964903316

result:

ok 1 number(s): "964903316"

Test #3:

score: 30
Accepted
time: 0ms
memory: 4152kb

input:

26 1 26

output:

955348527

result:

ok 1 number(s): "955348527"

Test #4:

score: 30
Accepted
time: 0ms
memory: 4164kb

input:

40 11 33

output:

695661890

result:

ok 1 number(s): "695661890"

Test #5:

score: 30
Accepted
time: 0ms
memory: 4216kb

input:

39 39 38

output:

717149364

result:

ok 1 number(s): "717149364"

Test #6:

score: 30
Accepted
time: 0ms
memory: 4112kb

input:

40 10 25

output:

912929610

result:

ok 1 number(s): "912929610"

Test #7:

score: 30
Accepted
time: 0ms
memory: 4156kb

input:

37 25 23

output:

250748685

result:

ok 1 number(s): "250748685"

Test #8:

score: 30
Accepted
time: 0ms
memory: 4152kb

input:

39 2 38

output:

624060592

result:

ok 1 number(s): "624060592"

Test #9:

score: 30
Accepted
time: 0ms
memory: 4088kb

input:

40 18 22

output:

739993796

result:

ok 1 number(s): "739993796"

Test #10:

score: 30
Accepted
time: 0ms
memory: 4228kb

input:

40 11 35


output:

135213497

result:

ok 1 number(s): "135213497"

Subtask #3:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #11:

score: 15
Accepted
time: 1ms
memory: 5092kb

input:

199 100 70

output:

914653136

result:

ok 1 number(s): "914653136"

Test #12:

score: 15
Accepted
time: 0ms
memory: 4880kb

input:

187 3 40

output:

928785584

result:

ok 1 number(s): "928785584"

Test #13:

score: 15
Accepted
time: 1ms
memory: 5080kb

input:

199 198 197

output:

38412688

result:

ok 1 number(s): "38412688"

Test #14:

score: 15
Accepted
time: 0ms
memory: 4992kb

input:

200 40 140

output:

367088143

result:

ok 1 number(s): "367088143"

Test #15:

score: 15
Accepted
time: 1ms
memory: 5152kb

input:

199 111 3

output:

870834793

result:

ok 1 number(s): "870834793"

Test #16:

score: 15
Accepted
time: 1ms
memory: 5084kb

input:

200 133 73

output:

343127012

result:

ok 1 number(s): "343127012"

Test #17:

score: 15
Accepted
time: 1ms
memory: 5008kb

input:

178 15 163

output:

160852284

result:

ok 1 number(s): "160852284"

Test #18:

score: 15
Accepted
time: 1ms
memory: 6356kb

input:

197 43 79

output:

332057544

result:

ok 1 number(s): "332057544"

Test #19:

score: 15
Accepted
time: 1ms
memory: 5108kb

input:

200 33 79

output:

742545318

result:

ok 1 number(s): "742545318"

Subtask #4:

score: 49
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #20:

score: 49
Accepted
time: 6ms
memory: 9960kb

input:

658 169 438

output:

206087110

result:

ok 1 number(s): "206087110"

Test #21:

score: 49
Accepted
time: 6ms
memory: 10616kb

input:

700 207 509

output:

478311263

result:

ok 1 number(s): "478311263"

Test #22:

score: 49
Accepted
time: 0ms
memory: 11472kb

input:

755 139 507

output:

103783948

result:

ok 1 number(s): "103783948"

Test #23:

score: 49
Accepted
time: 15ms
memory: 35336kb

input:

2000 500 1500

output:

123410309

result:

ok 1 number(s): "123410309"

Test #24:

score: 49
Accepted
time: 19ms
memory: 35212kb

input:

2000 1000 1001

output:

956197482

result:

ok 1 number(s): "956197482"

Test #25:

score: 49
Accepted
time: 19ms
memory: 35332kb

input:

2000 666 1333

output:

993781645

result:

ok 1 number(s): "993781645"

Test #26:

score: 49
Accepted
time: 27ms
memory: 35168kb

input:

1991 198 677

output:

155058730

result:

ok 1 number(s): "155058730"

Test #27:

score: 49
Accepted
time: 8ms
memory: 27472kb

input:

1498 299 659

output:

665757882

result:

ok 1 number(s): "665757882"