QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#819283 | #9884. Grid Construction | cooluo | TL | 0ms | 3824kb | C++23 | 5.5kb | 2024-12-18 14:47:39 | 2024-12-18 14:47:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ul unsigned ll
#define LL __int128_t
#define db double
#define DB long db
#define pii pair<int, int>
#define pil pair<int, ll>
#define fi first
#define se second
#define mkpr make_pair
#define vi vector<int>
#define vii vector<pii>
#define vil vector<pil>
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define bit(x) (1 << (x))
#define bin(s, x) ((s) >> (x) & 1)
#define mem(a, x) memset(a, x, sizeof(a))
#define req(i, l, r) for (int i(l), i##End(r); i < i##End; i = -~i)
#define qer(i, r, l) for (int i(r), i##End(l); i > i##End; i = ~-i)
#define rep(i, l, r) for (int i(l), i##End(r); i <= i##End; i = -~i)
#define per(i, r, l) for (int i(r), i##End(l); i >= i##End; i = ~-i)
#ifdef JYR
#define errs(x) fputs(x "\n", stderr)
#define errm(x, ...) fprintf(stderr, x, ##__VA_ARGS__)
#else
#define errs(x) 0
#define errm(x, ...) 0
#endif
template<typename T, typename U> void chkmx(T &_a, U _b) { if (_a < _b) _a = _b; }
template<typename T, typename U> void chkmn(T &_a, U _b) { if (_a > _b) _a = _b; }
template<typename T> T sq(T x) { return x * x; }
bool Mbe;
// #define MC
#define N 1005
#define mod 998244353
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
int n, m, k;
char s[N][N];
bool TAG;
char t1[][10] = {
"<<<<<<<<<",
"v.v.v.v.v",
"v>.^.^.^.",
"v.<<<<<^>",
"v>.v.v.^.",
"v.<v>.<^>",
"v>.v.^.^.",
"v.<v>>>>>",
"v>.v.v.v.",
"v.^.^.^.^",
"v>>>>>>>>"
}, t2[][7] = {
"<<<<<<",
".v.v.v",
"^.^.^.",
">>>>>>",
"v.v.v.",
".^.<v>",
"<^>.v.",
".^.<v>",
"<^>.v.",
".^.^.^",
">>>>>>"
}, t3[][3] = {
"<^",
".^",
"<^",
".^",
"<^",
".^",
"<^",
".^",
"<^",
".^",
">>"
};
void slv(int x, int y) {
errm("slv(%d, %d)\n", x, y);
int x1 = k * 3 + 1, y1 = k * 3 + 1;
int x2 = n - x1 + 1, y2 = m - y1 + 1;
errm("(%d %d) (%d %d)\n", x1, y1, x2, y2);
auto t = [&](int i, int j) -> char& { return s[x1 + i - 1][y1 + j - 1]; };
if (x == 9) {
req(j, 0, 7) s[x1][y1 + j] = '<';
req(j, 1, 7) s[x2][y1 + j] = '>';
req(i, 0, 8) s[x1 + i + 1][y1] = 'v', s[x1 + i][y2] = '^';
s[x2][y2 - 1] = s[x2][y2] = '>';
s[x1][y2 - 1] = s[x1 + 2][y2 - 1] = s[x1 + 4][y2 - 1] = s[x1 + 6][y2 - 1] = '<';
t(3, 4) = t(3, 6) = t(4, 6) = t(5, 6) = t(8, 3) = t(8, 5) = t(8, 7) = '^';
t(3, 2) = t(4, 7) = t(5, 2) = t(6, 5) = t(6, 6) = t(6, 7) = t(7, 2) = '>';
t(2, 3) = t(2, 5) = t(2, 7) = t(5, 4) = t(6, 4) = t(7, 4) = t(7, 6) = 'v';
t(4, 3) = t(4, 4) = t(4, 5) = t(6, 3) = '<';
y1 += 7;
rep(i, 1, (y - 9) / 6) {
t(1, 1) = t(1, 2) = t(1, 3) = t(1, 4) = t(1, 5) = t(1, 6) = t(6, 4) = t(7, 1) = '<';
t(4, 1) = t(4, 2) = t(4, 3) = t(4, 4) = t(4, 5) = t(4, 6) = t(6, 6) =
t(7, 3) = t(9, 1) = t(9, 2) = t(9, 3) = t(9, 4) = t(9, 5) = t(9, 6) = '>';
t(2, 2) = t(2, 4) = t(2, 6) = t(5, 1) = t(5, 3) = t(5, 5) = t(6, 5) = t(7, 5) = 'v';
t(3, 1) = t(3, 3) = t(3, 5) = t(6, 2) = t(7, 2) = t(8, 2) = t(8, 4) = t(8, 6) = '^';
y1 += 6;
}
return;
}
if (x == 11) {
req(i, 0, 11) req(j, 0, 9) t(i + 1, j + 1) = t1[i][j];
req(i, 0, 11) req(j, 0, 2) s[x1 + i][y2 - 1 + j] = t3[i][j];
y1 += 9;
rep(_, 1, (y - 11) / 6) {
req(i, 0, 11) req(j, 0, 6) t(i + 1, j + 1) = t2[i][j];
y1 += 6;
}
return;
}
req(i, x1, x2) s[i + 1][y1] = 'v', s[i][y2] = '^';
req(j, y1, y2) s[x1][j] = '<', s[x2][j + 1] = '>';
for (int i = x1 + 2; i < x2; i += 2) s[i][y1 + 1] = '>', s[i][y2 - 1] = '<';
for (int j = y1 + 2; j < y2; j += 2) s[x1 + 1][j] = 'v', s[x2 - 1][j] = '^';
for (int i = x1 + 3; i < x2 - 1; i += 2) s[i][y1 + 2] = '<', s[i][y2 - 2] = '>';
for (int j = y1 + 3; j < y2 - 1; j += 2) s[x1 + 2][j] = '^', s[x2 - 2][j] = 'v';
k++, slv(x - 6, y - 6);
}
void mslv() {
scanf("%d%d", &n, &m);
if (n > m) swap(n, m), TAG = 1;
if (n == 2 && m == 2) {
puts("Yes\n<^\nv>");
return;
}
if (n == 3 && m == 3) {
puts("Yes\n<<^\nv.^\nv>>");
return;
}
if (n == 5 && m == 5) {
puts("Yes\n<<<<^\nv.v.^\nv>.<^\nv.^.^\nv>>>>");
return;
}
if (int x = n % 6, y = m % 6; !((x == 3 && y == 3) || (x == 5 && y == 5))) {
puts("No");
return;
}
slv(n, m), puts("Yes");
rep(i, 1, n) rep(j, 1, m) if (!s[i][j]) s[i][j] = '.';
if (TAG) {
auto trans = [](char c) {
switch (c) {
case '.': return '.';
case '<': return '^';
case '^': return '>';
case '>': return 'v';
case 'v': return '<';
}
return '\n';
};
rep(j, 1, m) {
per(i, n, 1) printf("%c", trans(s[i][j]));
puts("");
}
} else rep(i, 1, n) {
rep(j, 1, m) printf("%c", s[i][j]);
puts("");
}
}
void sprw() {}
void mprw() {}
bool Med;
int main() {
#ifdef JYR
freopen("Test.in", "r", stdin);
freopen("Test.out", "w", stdout);
#endif
mprw();
#ifdef MC
int _; scanf("%d", &_);
while (_--) sprw(), mslv();
#else
mslv();
#endif
errm("%.3lfMB %.0lfms\n", abs(&Med - &Mbe) / 1048576., clock() * 1000. / CLOCKS_PER_SEC);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
3 3
output:
Yes <<^ v.^ v>>
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
4 4
output:
No
result:
ok Correct : No
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
4 5
output:
No
result:
ok Correct : No
Test #4:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
11 17
output:
Yes <<<<<<<<<<<<<<<<^ v.v.v.v.v.v.v.v.^ v>.^.^.^.^.^.^.<^ v.<<<<<^>>>>>>>.^ v>.v.v.^.v.v.v.<^ v.<v>.<^>.^.<v>.^ v>.v.^.^.<^>.v.<^ v.<v>>>>>.^.<v>.^ v>.v.v.v.<^>.v.<^ v.^.^.^.^.^.^.^.^ v>>>>>>>>>>>>>>>>
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
1000 1000
output:
No
result:
ok Correct : No
Test #6:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
6 6
output:
No
result:
ok Correct : No
Test #7:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
7 7
output:
No
result:
ok Correct : No
Test #8:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
8 8
output:
No
result:
ok Correct : No
Test #9:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
9 9
output:
Yes <<<<<<<<^ v.v.v.v.^ v>.^.^.<^ v.<<<^>.^ v>.v.^.<^ v.<v>>>.^ v>.v.v.<^ v.^.^.^.^ v>>>>>>>>
result:
ok Correct
Test #10:
score: -100
Time Limit Exceeded
input:
3 9