Submission #1173930
Source Code Expand
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
#include<random>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif
int main(){
random_device rd;
mt19937 mt(rd());
int h, w, k, t;
cin >> h >> w >> k >> t;
vector<vector<int>> board(h, vector<int> (w));
vector<pair<int, int>> abs(k), cds(k);
for(int i=0;i<k;i++){
int a, b, c, d;
cin >> a >> b >> c >> d;
a--; b--; c--; d--;
abs[i] = {a, b};
cds[i] = {c, d};
board[a][b] = 1;
}
int ss = 0;
string out;
for(int i=0;i<t;i++){
vector<pair<int, int>> poss = abs;
int cnt = 0;
if(ss % 2){
for(int i=0;i<k;i++){
bool done = false;
if(mt() % 100 < 20){
int y = abs[i].first, x = abs[i].second;
vector<int> four(4);
iota(four.begin(), four.end(), 0);
shuffle(four.begin(), four.end(), mt);
for(int jj=0;jj<4;jj++){
int j = four[jj];
int ny = y + (j == 0 ? 1 : j == 1 ? -1 : 0), nx = x + (j == 2 ? 1 : j == 3 ? -1 : 0);
if(0 <= ny && ny < h && 0 <= nx && nx < w && !board[ny][nx]){
out += (j == 0 ? 'D' : j == 1 ? 'U' : j == 2 ? 'R' : 'L');
board[ny][nx] = 1;
abs[i] = {ny, nx};
done = true;
break;
}
}
}
if(!done){
out += '-';
poss[i] = {-1, -1};
}
}
ss++;
}else{
for(int i=0;i<k;i++){
int y = abs[i].first, x = abs[i].second;
if(y < cds[i].first){
int ny = y + 1, nx = x;
if(0 <= ny && ny < h && 0 <= nx && nx < w && !board[ny][nx]){
out += 'D';
board[ny][nx] = 1;
abs[i] = {ny, nx};
continue;
}
}
if(y > cds[i].first){
int ny = y - 1, nx = x;
if(0 <= ny && ny < h && 0 <= nx && nx < w && !board[ny][nx]){
out += 'U';
board[ny][nx] = 1;
abs[i] = {ny, nx};
continue;
}
}
if(x < cds[i].second){
int ny = y, nx = x + 1;
if(0 <= ny && ny < h && 0 <= nx && nx < w && !board[ny][nx]){
out += 'R';
board[ny][nx] = 1;
abs[i] = {ny, nx};
continue;
}
}
if(x > cds[i].second){
int ny = y, nx = x - 1;
if(0 <= ny && ny < h && 0 <= nx && nx < w && !board[ny][nx]){
out += 'L';
board[ny][nx] = 1;
abs[i] = {ny, nx};
continue;
}
}
out += '-';
poss[i] = {-1, -1};
cnt++;
}
}
out += '\n';
if(cnt == k){
if(i > t - 100){
cout << i + 1 << '\n';
cout << out << endl;
return 0;
}
ss++;
}
// prints(board);
for(int i=0;i<k;i++){
if(poss[i].first != -1){
board[poss[i].first][poss[i].second] = 0;
}
}
// prints(board);
// prints(abs);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - 日本橋大渋滞 |
User |
sumoooru |
Language |
C++14 (Clang 3.8.0) |
Score |
555 |
Code Size |
4441 Byte |
Status |
AC |
Exec Time |
141 ms |
Memory |
10856 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 |
20 / 50000 |
19 / 50000 |
20 / 50000 |
19 / 50000 |
22 / 50000 |
18 / 50000 |
19 / 50000 |
19 / 50000 |
17 / 50000 |
17 / 50000 |
21 / 50000 |
18 / 50000 |
18 / 50000 |
19 / 50000 |
17 / 50000 |
19 / 50000 |
18 / 50000 |
18 / 50000 |
17 / 50000 |
18 / 50000 |
19 / 50000 |
19 / 50000 |
18 / 50000 |
17 / 50000 |
18 / 50000 |
20 / 50000 |
19 / 50000 |
15 / 50000 |
19 / 50000 |
18 / 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 |
141 ms |
9576 KB |
subtask_01_02.txt |
AC |
139 ms |
9704 KB |
subtask_01_03.txt |
AC |
140 ms |
9960 KB |
subtask_01_04.txt |
AC |
140 ms |
9960 KB |
subtask_01_05.txt |
AC |
138 ms |
9320 KB |
subtask_01_06.txt |
AC |
139 ms |
10600 KB |
subtask_01_07.txt |
AC |
139 ms |
9064 KB |
subtask_01_08.txt |
AC |
139 ms |
9448 KB |
subtask_01_09.txt |
AC |
138 ms |
9960 KB |
subtask_01_10.txt |
AC |
137 ms |
9960 KB |
subtask_01_11.txt |
AC |
137 ms |
9832 KB |
subtask_01_12.txt |
AC |
138 ms |
10728 KB |
subtask_01_13.txt |
AC |
138 ms |
9704 KB |
subtask_01_14.txt |
AC |
138 ms |
9064 KB |
subtask_01_15.txt |
AC |
137 ms |
10728 KB |
subtask_01_16.txt |
AC |
137 ms |
10728 KB |
subtask_01_17.txt |
AC |
137 ms |
9320 KB |
subtask_01_18.txt |
AC |
138 ms |
10088 KB |
subtask_01_19.txt |
AC |
139 ms |
9064 KB |
subtask_01_20.txt |
AC |
138 ms |
9192 KB |
subtask_01_21.txt |
AC |
139 ms |
10088 KB |
subtask_01_22.txt |
AC |
141 ms |
10856 KB |
subtask_01_23.txt |
AC |
138 ms |
9448 KB |
subtask_01_24.txt |
AC |
139 ms |
10216 KB |
subtask_01_25.txt |
AC |
139 ms |
9704 KB |
subtask_01_26.txt |
AC |
138 ms |
10600 KB |
subtask_01_27.txt |
AC |
138 ms |
9064 KB |
subtask_01_28.txt |
AC |
138 ms |
10088 KB |
subtask_01_29.txt |
AC |
138 ms |
10856 KB |
subtask_01_30.txt |
AC |
137 ms |
9320 KB |