Submission #1173245
Source Code Expand
#include<bitset>
#include<set>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
putchar('\n');
}
typedef bitset<960> Bits;
const int dy[4] = { 0, 1, 0, -1};
const int dx[4] = { 1, 0, -1, 0};
const char DIRE[] = "RDLU";
int H, W, K, T;
int A[455], B[455], C[455], D[455];
int nA[455], nB[455];
vector<string> ans;
Bits in[2];
int main() {
scanf("%d%d%d%d", &H, &W, &K, &T);
REP (i, K) {
scanf("%d%d%d%d", A+i, B+i, C+i, D+i);
A[i]--;
B[i]--;
C[i]--;
D[i]--;
in[0].set(A[i] * 30 + B[i]);
}
string g(K, '-');
REP (t, T) {
int cur = t & 1, nxt = 1 - cur;
in[nxt].reset();
bool update = false;
REP (i, K) {
VI ds;
if (A[i] < C[i]) ds.push_back(1);
if (A[i] > C[i]) ds.push_back(3);
if (B[i] < D[i]) ds.push_back(0);
if (B[i] > D[i]) ds.push_back(2);
if (ds.empty()) {
g[i] = '-';
nA[i] = A[i];
nB[i] = B[i];
in[nxt].set(A[i] * 30 + B[i]);
continue;
}
int k = rand() % ds.size();
int yy = A[i] + dy[ds[k]];
int xx = B[i] + dx[ds[k]];
int key = yy * 30 + xx;
if (!in[cur][key] && !in[nxt][key]) {
g[i] = DIRE[ds[k]];
in[nxt].set(key);
nA[i] = yy;
nB[i] = xx;
update = true;
} else {
g[i] = '-';
nA[i] = A[i];
nB[i] = B[i];
in[nxt].set(A[i] * 30 + B[i]);
}
}
REP (i, K) {
A[i] = nA[i];
B[i] = nB[i];
}
if (!update) {
break;
}
ans.push_back(g);
}
printf("%d\n", (int)ans.size());
REP (i, ans.size()) puts(ans[i].c_str());
return 0;
}
Submission Info
Submission Time |
|
Task |
B - 日本橋大渋滞 |
User |
natsugiri |
Language |
C++14 (GCC 5.4.1) |
Score |
4447 |
Code Size |
2277 Byte |
Status |
AC |
Exec Time |
4 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:41:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d", &H, &W, &K, &T);
^
./Main.cpp:43:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d", A+i, B+i, C+i, D+i);
^
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 |
154 / 50000 |
153 / 50000 |
149 / 50000 |
155 / 50000 |
164 / 50000 |
151 / 50000 |
151 / 50000 |
151 / 50000 |
143 / 50000 |
144 / 50000 |
152 / 50000 |
150 / 50000 |
145 / 50000 |
149 / 50000 |
144 / 50000 |
157 / 50000 |
145 / 50000 |
146 / 50000 |
145 / 50000 |
142 / 50000 |
157 / 50000 |
146 / 50000 |
147 / 50000 |
138 / 50000 |
143 / 50000 |
150 / 50000 |
147 / 50000 |
138 / 50000 |
146 / 50000 |
145 / 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 |
4 ms |
256 KB |
subtask_01_02.txt |
AC |
4 ms |
256 KB |
subtask_01_03.txt |
AC |
4 ms |
256 KB |
subtask_01_04.txt |
AC |
4 ms |
256 KB |
subtask_01_05.txt |
AC |
3 ms |
256 KB |
subtask_01_06.txt |
AC |
4 ms |
256 KB |
subtask_01_07.txt |
AC |
4 ms |
256 KB |
subtask_01_08.txt |
AC |
4 ms |
256 KB |
subtask_01_09.txt |
AC |
4 ms |
256 KB |
subtask_01_10.txt |
AC |
4 ms |
256 KB |
subtask_01_11.txt |
AC |
4 ms |
256 KB |
subtask_01_12.txt |
AC |
4 ms |
256 KB |
subtask_01_13.txt |
AC |
4 ms |
256 KB |
subtask_01_14.txt |
AC |
4 ms |
256 KB |
subtask_01_15.txt |
AC |
4 ms |
256 KB |
subtask_01_16.txt |
AC |
3 ms |
256 KB |
subtask_01_17.txt |
AC |
4 ms |
256 KB |
subtask_01_18.txt |
AC |
4 ms |
256 KB |
subtask_01_19.txt |
AC |
4 ms |
256 KB |
subtask_01_20.txt |
AC |
4 ms |
256 KB |
subtask_01_21.txt |
AC |
4 ms |
256 KB |
subtask_01_22.txt |
AC |
4 ms |
256 KB |
subtask_01_23.txt |
AC |
4 ms |
256 KB |
subtask_01_24.txt |
AC |
3 ms |
256 KB |
subtask_01_25.txt |
AC |
4 ms |
256 KB |
subtask_01_26.txt |
AC |
3 ms |
256 KB |
subtask_01_27.txt |
AC |
4 ms |
256 KB |
subtask_01_28.txt |
AC |
4 ms |
256 KB |
subtask_01_29.txt |
AC |
4 ms |
256 KB |
subtask_01_30.txt |
AC |
3 ms |
256 KB |