QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#793652 | #7917. Klompendans | Loxilante | AC ✓ | 47ms | 17064kb | C++20 | 1.3kb | 2024-11-29 22:06:35 | 2024-11-29 22:06:37 |
Judging History
answer
#define F_C
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#endif
const int U = 520;
const int dx[] = {1, 1, -1, -1}, dy[] = {1, -1, 1, -1};
int n, ax[2], ay[2], p;
bool vis[U][U][2];
struct Stat
{
int x, y, op;
};
signed main(void)
{
#ifdef LOCAL
// freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
// freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>ax[0]>>ay[0]>>ax[1]>>ay[1];
queue<Stat> que; que.push({1, 1, 0}); que.push({1, 1, 1});
while(que.size())
{
auto [x, y, op] = que.front(); que.pop();
if (x < 1 || x > n || y < 1 || y > n || vis[x][y][op]) continue;
vis[x][y][op] = 1;
int r = !op;
rep(d, 0, 4) que.push({x+dx[d]*ax[r], y+dy[d]*ay[r], r}),
que.push({x+dx[d]*ay[r], y+dy[d]*ax[r], r});
}
int cnt = 0;
hrp(i, 1, n) hrp(j, 1, n) cnt += vis[i][j][0]|vis[i][j][1];
cout<<cnt<<endl;
return 0;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
3 2 1 2 2
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
8 1 2 1 2
output:
64
result:
ok single line: '64'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
4 1 2 2 3
output:
13
result:
ok single line: '13'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
5 1 2 2 3
output:
25
result:
ok single line: '25'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
10 3 3 4 4
output:
50
result:
ok single line: '50'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 1 1 1 1
output:
5
result:
ok single line: '5'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
500 499 499 499 499
output:
2
result:
ok single line: '2'
Test #8:
score: 0
Accepted
time: 33ms
memory: 4860kb
input:
500 1 1 1 2
output:
250000
result:
ok single line: '250000'
Test #9:
score: 0
Accepted
time: 31ms
memory: 4344kb
input:
500 250 250 250 249
output:
250000
result:
ok single line: '250000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
293 52 290 100 225
output:
9
result:
ok single line: '9'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
81 1 67 38 10
output:
3057
result:
ok single line: '3057'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
49 44 9 11 45
output:
501
result:
ok single line: '501'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3944kb
input:
313 220 140 166 196
output:
15467
result:
ok single line: '15467'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
490 268 481 286 10
output:
9
result:
ok single line: '9'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3892kb
input:
411 156 396 38 119
output:
13
result:
ok single line: '13'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
19 11 16 6 15
output:
73
result:
ok single line: '73'
Test #17:
score: 0
Accepted
time: 5ms
memory: 4544kb
input:
472 29 175 273 321
output:
69211
result:
ok single line: '69211'
Test #18:
score: 0
Accepted
time: 3ms
memory: 4468kb
input:
271 228 10 242 201
output:
19004
result:
ok single line: '19004'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
78 75 77 35 6
output:
9
result:
ok single line: '9'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
71 69 65 3 9
output:
11
result:
ok single line: '11'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
100 98 40 9 1
output:
950
result:
ok single line: '950'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
87 10 7 3 86
output:
9
result:
ok single line: '9'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
84 83 78 10 75
output:
9
result:
ok single line: '9'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
85 81 75 3 75
output:
36
result:
ok single line: '36'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
71 53 67 70 63
output:
7
result:
ok single line: '7'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3796kb
input:
51 25 41 1 2
output:
1872
result:
ok single line: '1872'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
62 4 61 54 60
output:
7
result:
ok single line: '7'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
88 78 80 80 5
output:
352
result:
ok single line: '352'
Test #29:
score: 0
Accepted
time: 2ms
memory: 4184kb
input:
76 16 9 9 3
output:
5776
result:
ok single line: '5776'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
76 71 72 70 33
output:
9
result:
ok single line: '9'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
75 27 36 72 7
output:
9
result:
ok single line: '9'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
47 2 3 29 38
output:
716
result:
ok single line: '716'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
42 13 2 36 38
output:
13
result:
ok single line: '13'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
70 69 52 4 69
output:
23
result:
ok single line: '23'
Test #35:
score: 0
Accepted
time: 1ms
memory: 4084kb
input:
91 12 6 47 1
output:
4141
result:
ok single line: '4141'
Test #36:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
74 2 72 4 35
output:
9
result:
ok single line: '9'
Test #37:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
53 13 43 22 5
output:
2665
result:
ok single line: '2665'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
258 252 146 89 251
output:
218
result:
ok single line: '218'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
315 5 103 311 305
output:
11
result:
ok single line: '11'
Test #40:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
266 263 3 3 2
output:
4904
result:
ok single line: '4904'
Test #41:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
412 409 326 408 1
output:
80
result:
ok single line: '80'
Test #42:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
383 354 276 373 376
output:
9
result:
ok single line: '9'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
279 276 5 9 277
output:
44
result:
ok single line: '44'
Test #44:
score: 0
Accepted
time: 17ms
memory: 10496kb
input:
309 8 71 7 38
output:
95481
result:
ok single line: '95481'
Test #45:
score: 0
Accepted
time: 14ms
memory: 8636kb
input:
290 5 4 6 112
output:
84100
result:
ok single line: '84100'
Test #46:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
168 167 79 163 82
output:
7
result:
ok single line: '7'
Test #47:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
70 1 61 1 22
output:
3876
result:
ok single line: '3876'
Test #48:
score: 0
Accepted
time: 1ms
memory: 3860kb
input:
494 4 491 10 4
output:
25
result:
ok single line: '25'
Test #49:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
494 486 6 7 490
output:
28
result:
ok single line: '28'
Test #50:
score: 0
Accepted
time: 1ms
memory: 4096kb
input:
490 370 8 480 9
output:
5754
result:
ok single line: '5754'
Test #51:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
490 97 2 139 489
output:
13
result:
ok single line: '13'
Test #52:
score: 0
Accepted
time: 6ms
memory: 4476kb
input:
493 136 5 484 10
output:
38576
result:
ok single line: '38576'
Test #53:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
492 490 483 486 10
output:
7
result:
ok single line: '7'
Test #54:
score: 0
Accepted
time: 46ms
memory: 17064kb
input:
490 85 4 305 29
output:
240100
result:
ok single line: '240100'
Test #55:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
493 77 405 7 488
output:
9
result:
ok single line: '9'
Test #56:
score: 0
Accepted
time: 47ms
memory: 11832kb
input:
494 195 10 1 7
output:
244036
result:
ok single line: '244036'
Test #57:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
494 12 486 353 3
output:
2306
result:
ok single line: '2306'
Test #58:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
492 488 483 10 2
output:
13
result:
ok single line: '13'
Test #59:
score: 0
Accepted
time: 42ms
memory: 15788kb
input:
495 30 7 10 178
output:
245025
result:
ok single line: '245025'
Test #60:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
500 9 494 496 481
output:
26
result:
ok single line: '26'
Test #61:
score: 0
Accepted
time: 3ms
memory: 4404kb
input:
495 6 487 487 10
output:
15584
result:
ok single line: '15584'
Test #62:
score: 0
Accepted
time: 4ms
memory: 4340kb
input:
490 5 476 374 2
output:
25584
result:
ok single line: '25584'
Test #63:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
493 391 49 484 254
output:
9
result:
ok single line: '9'
Test #64:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
493 5 491 485 490
output:
23
result:
ok single line: '23'
Test #65:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
499 12 8 494 10
output:
26
result:
ok single line: '26'
Test #66:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
499 496 23 6 493
output:
9
result:
ok single line: '9'
Test #67:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
49 2 10 21 45
output:
764
result:
ok single line: '764'
Test #68:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
43 6 1 39 30
output:
348
result:
ok single line: '348'
Test #69:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
46 10 37 19 8
output:
1366
result:
ok single line: '1366'
Test #70:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
44 34 13 9 17
output:
1792
result:
ok single line: '1792'
Test #71:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
43 32 35 4 30
output:
501
result:
ok single line: '501'
Test #72:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
50 7 47 1 9
output:
602
result:
ok single line: '602'
Test #73:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
41 17 10 31 10
output:
1264
result:
ok single line: '1264'
Test #74:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
49 11 41 35 6
output:
643
result:
ok single line: '643'
Test #75:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
48 36 3 33 2
output:
1364
result:
ok single line: '1364'
Test #76:
score: 0
Accepted
time: 4ms
memory: 3968kb
input:
220 192 115 24 44
output:
33064
result:
ok single line: '33064'
Test #77:
score: 0
Accepted
time: 7ms
memory: 4624kb
input:
312 168 177 235 92
output:
69173
result:
ok single line: '69173'
Test #78:
score: 0
Accepted
time: 12ms
memory: 4856kb
input:
428 342 203 90 289
output:
115825
result:
ok single line: '115825'
Test #79:
score: 0
Accepted
time: 7ms
memory: 5472kb
input:
287 122 185 144 161
output:
68220
result:
ok single line: '68220'
Test #80:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
51 12 1 47 31
output:
425
result:
ok single line: '425'
Test #81:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
218 122 2 171 73
output:
6191
result:
ok single line: '6191'
Test #82:
score: 0
Accepted
time: 0ms
memory: 4192kb
input:
293 134 223 59 85
output:
5092
result:
ok single line: '5092'
Test #83:
score: 0
Accepted
time: 2ms
memory: 4016kb
input:
148 94 41 33 114
output:
12991
result:
ok single line: '12991'