Submission #1173560
Source Code Expand
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>
#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)
#define X(x) ((x) % W2)
#define Y(x) ((x) / W2)
#define XY(x, y) ((y) * W2 + (x))
int H, W, K, T, W2, W2W2;
std::array<int, 450> P, Q;
template<typename T>
using board_t = std::array<T, 1024>;
board_t<char> board;
void debugout(int t)
{
for (int i = 0, p = 0; i < W2; i ++) {
std::cerr << "t=" << t << ' ';
for (int j = 0; j < W2; j ++, p ++)
std::cerr << board[p];
std::cerr << std::endl;
}
}
int main(int argc, char** argv)
{
std::cin.tie(0);
std::ios_base::sync_with_stdio(0);
std::cin >> H >> W >> K >> T;
W2 = W + 2;
W2W2 = W2 * W2;
std::fill(ALL(board), '.');
for (int i = 0; i < W2; i ++)
board[XY(i, 0)] = board[XY(i, W + 1)] = board[XY(0, i)] = board[XY(W + 1, i)] = '#';
for (int i = 0; i < K; i ++) {
int a, b, c, d;
std::cin >> a >> b >> c >> d;
P[i] = XY(b, a);
Q[i] = XY(d, c);
board[P[i]] = 'X';
}
debugout(-1);
std::vector<std::string> a;
for (int t = 0; t < T; t ++) {
std::string s = std::string(K, '-');
for (int i = 0; i < K; i ++) {
int p = P[i], px = X(p), py = Y(p), pp;
int q = Q[i], qx = X(q), qy = Y(q);
int dx = qx - px, dy = qy - py;
// std::cerr << " t=" << t << " i=" << i << " p=" << px << ' ' << py << " q=" << qx << ' ' << qy << std::endl;
if (dx < 0 && board[p] == 'X' && board[pp = p - 1] == '.') {
board[p] = '!';
board[P[i] = pp] = 'X';
s[i] = 'L';
}
else if (dx > 0 && board[p] == 'X' && board[pp = p + 1] == '.') {
board[p] = '!';
board[P[i] = pp] = 'X';
s[i] = 'R';
}
if (dy < 0 && board[p] == 'X' && board[pp = p - W2] == '.') {
board[p] = '!';
board[P[i] = pp] = 'X';
s[i] = 'U';
}
else if (dy > 0 && board[p] == 'X' && board[pp = p + W2] == '.') {
if (board[pp = p + W2] == '.') {
board[p] = '!';
board[P[i] = pp] = 'X';
s[i] = 'D';
}
}
}
a.push_back(s);
#if 0
debugout(t);
#endif
for (int i = 0; i < W2W2; i ++)
if (board[i] == '!')
board[i] = '.';
}
std::cout << a.size() << std::endl;
for (const auto& s : a)
std::cout << s << std::endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
B - 日本橋大渋滞 |
User |
agw |
Language |
C++14 (GCC 5.4.1) |
Score |
446 |
Code Size |
2885 Byte |
Status |
AC |
Exec Time |
75 ms |
Memory |
10236 KB |
Judge Result
Set Name |
test_01 |
test_02 |
test_03 |
test_04 |
test_05 |
test_06 |
test_07 |
test_08 |
test_09 |
test_10 |
test_11 |
test_12 |
test_13 |
test_14 |
test_15 |
test_16 |
test_17 |
test_18 |
test_19 |
test_20 |
test_21 |
test_22 |
test_23 |
test_24 |
test_25 |
test_26 |
test_27 |
test_28 |
test_29 |
test_30 |
Score / Max Score |
15 / 50000 |
15 / 50000 |
15 / 50000 |
15 / 50000 |
17 / 50000 |
15 / 50000 |
15 / 50000 |
15 / 50000 |
14 / 50000 |
15 / 50000 |
15 / 50000 |
15 / 50000 |
14 / 50000 |
16 / 50000 |
14 / 50000 |
16 / 50000 |
15 / 50000 |
15 / 50000 |
14 / 50000 |
15 / 50000 |
16 / 50000 |
15 / 50000 |
15 / 50000 |
14 / 50000 |
14 / 50000 |
15 / 50000 |
15 / 50000 |
14 / 50000 |
14 / 50000 |
14 / 50000 |
Status |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set Name |
Test Cases |
test_01 |
subtask_01_01.txt |
test_02 |
subtask_01_02.txt |
test_03 |
subtask_01_03.txt |
test_04 |
subtask_01_04.txt |
test_05 |
subtask_01_05.txt |
test_06 |
subtask_01_06.txt |
test_07 |
subtask_01_07.txt |
test_08 |
subtask_01_08.txt |
test_09 |
subtask_01_09.txt |
test_10 |
subtask_01_10.txt |
test_11 |
subtask_01_11.txt |
test_12 |
subtask_01_12.txt |
test_13 |
subtask_01_13.txt |
test_14 |
subtask_01_14.txt |
test_15 |
subtask_01_15.txt |
test_16 |
subtask_01_16.txt |
test_17 |
subtask_01_17.txt |
test_18 |
subtask_01_18.txt |
test_19 |
subtask_01_19.txt |
test_20 |
subtask_01_20.txt |
test_21 |
subtask_01_21.txt |
test_22 |
subtask_01_22.txt |
test_23 |
subtask_01_23.txt |
test_24 |
subtask_01_24.txt |
test_25 |
subtask_01_25.txt |
test_26 |
subtask_01_26.txt |
test_27 |
subtask_01_27.txt |
test_28 |
subtask_01_28.txt |
test_29 |
subtask_01_29.txt |
test_30 |
subtask_01_30.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask_01_01.txt |
AC |
75 ms |
10236 KB |
subtask_01_02.txt |
AC |
68 ms |
9600 KB |
subtask_01_03.txt |
AC |
68 ms |
9600 KB |
subtask_01_04.txt |
AC |
69 ms |
9600 KB |
subtask_01_05.txt |
AC |
68 ms |
9600 KB |
subtask_01_06.txt |
AC |
68 ms |
9600 KB |
subtask_01_07.txt |
AC |
68 ms |
9600 KB |
subtask_01_08.txt |
AC |
68 ms |
9600 KB |
subtask_01_09.txt |
AC |
69 ms |
9600 KB |
subtask_01_10.txt |
AC |
68 ms |
9600 KB |
subtask_01_11.txt |
AC |
68 ms |
9600 KB |
subtask_01_12.txt |
AC |
68 ms |
9600 KB |
subtask_01_13.txt |
AC |
68 ms |
9600 KB |
subtask_01_14.txt |
AC |
68 ms |
9600 KB |
subtask_01_15.txt |
AC |
68 ms |
9600 KB |
subtask_01_16.txt |
AC |
68 ms |
9600 KB |
subtask_01_17.txt |
AC |
68 ms |
9600 KB |
subtask_01_18.txt |
AC |
69 ms |
9600 KB |
subtask_01_19.txt |
AC |
69 ms |
9600 KB |
subtask_01_20.txt |
AC |
68 ms |
9600 KB |
subtask_01_21.txt |
AC |
68 ms |
9600 KB |
subtask_01_22.txt |
AC |
68 ms |
9600 KB |
subtask_01_23.txt |
AC |
69 ms |
9600 KB |
subtask_01_24.txt |
AC |
69 ms |
9600 KB |
subtask_01_25.txt |
AC |
69 ms |
9600 KB |
subtask_01_26.txt |
AC |
68 ms |
9600 KB |
subtask_01_27.txt |
AC |
69 ms |
9600 KB |
subtask_01_28.txt |
AC |
69 ms |
9600 KB |
subtask_01_29.txt |
AC |
68 ms |
9600 KB |
subtask_01_30.txt |
AC |
68 ms |
9600 KB |