Submission #1173258
Source Code Expand
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
struct State {
// (h, w)
vector<pair<int,int>> locs;
vector<pair<int,int>> goals;
};
State s;
string move_to_string(const pair<int,int>& p) {
if (p == mp(0, 0)) return "-";
else if (p == mp(1, 0)) return "D";
else if (p == mp(-1, 0)) return "U";
else if (p == mp(0, 1)) return "R";
else if (p == mp(0, -1)) return "L";
return "?";
}
int count_move_num(string s) {
int num = 0;
for(auto ch: s) num += ch != '-';
return num;
}
int main(void)
{
cin.sync_with_stdio(false);
int H, W, K, T;
cin >> H >> W >> K >> T;
s.locs.resize(K);
s.goals.resize(K);
vector<tuple<int,int,int,int>> ABCDs(K);
REP(k, K) {
int a, b, c, d;
cin >> a >> b >> c >> d;
ABCDs[k] = mt(a, b, c, d);
s.locs[k] = mp(a, b);
s.goals[k] = mp(c, d);
}
vector<string> anses;
// REP(t, T) {
REP(t, 5000) {
set<pair<int,int>> occupied;
REP(k, K) {
occupied.insert(s.locs[k]);
}
string ans;
REP(k, K) {
if (s.locs[k] == s.goals[k]) {
ans += '-';
}
else {
vector<pair<int,int>> poss_move;
if (s.locs[k].first < s.goals[k].first) poss_move.pb(mp(1,0));
if (s.locs[k].first > s.goals[k].first) poss_move.pb(mp(-1,0));
if (s.locs[k].second < s.goals[k].second) poss_move.pb(mp(0,1));
if (s.locs[k].second > s.goals[k].second) poss_move.pb(mp(0,-1));
random_shuffle(ALL(poss_move));
bool found = false;
for (auto m : poss_move) {
auto new_loc = s.locs[k];
new_loc.first += m.first;
new_loc.second += m.second;
if (!occupied.count(new_loc)) {
occupied.insert(new_loc);
ans += move_to_string(m);
found = true;
s.locs[k] = new_loc;
break;
}
}
if (!found) ans += '-';
}
}
auto move_num = count_move_num(ans);
if (move_num < 10) {
break;
}
anses.pb(ans);
}
cout << SIZE(anses) << endl;
for(auto ans: anses) {
cout << ans << endl;
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - 日本橋大渋滞 |
User |
minus9d |
Language |
C++14 (GCC 5.4.1) |
Score |
4621 |
Code Size |
3208 Byte |
Status |
AC |
Exec Time |
69 ms |
Memory |
384 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 |
160 / 50000 |
163 / 50000 |
155 / 50000 |
160 / 50000 |
171 / 50000 |
158 / 50000 |
155 / 50000 |
158 / 50000 |
147 / 50000 |
153 / 50000 |
161 / 50000 |
152 / 50000 |
148 / 50000 |
163 / 50000 |
148 / 50000 |
165 / 50000 |
152 / 50000 |
146 / 50000 |
151 / 50000 |
149 / 50000 |
160 / 50000 |
150 / 50000 |
150 / 50000 |
144 / 50000 |
147 / 50000 |
155 / 50000 |
159 / 50000 |
141 / 50000 |
152 / 50000 |
148 / 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 |
6 ms |
384 KB |
subtask_01_02.txt |
AC |
7 ms |
384 KB |
subtask_01_03.txt |
AC |
6 ms |
384 KB |
subtask_01_04.txt |
AC |
6 ms |
384 KB |
subtask_01_05.txt |
AC |
69 ms |
384 KB |
subtask_01_06.txt |
AC |
6 ms |
384 KB |
subtask_01_07.txt |
AC |
6 ms |
384 KB |
subtask_01_08.txt |
AC |
5 ms |
384 KB |
subtask_01_09.txt |
AC |
6 ms |
384 KB |
subtask_01_10.txt |
AC |
6 ms |
384 KB |
subtask_01_11.txt |
AC |
5 ms |
384 KB |
subtask_01_12.txt |
AC |
6 ms |
384 KB |
subtask_01_13.txt |
AC |
6 ms |
384 KB |
subtask_01_14.txt |
AC |
6 ms |
384 KB |
subtask_01_15.txt |
AC |
5 ms |
384 KB |
subtask_01_16.txt |
AC |
6 ms |
384 KB |
subtask_01_17.txt |
AC |
6 ms |
384 KB |
subtask_01_18.txt |
AC |
6 ms |
384 KB |
subtask_01_19.txt |
AC |
6 ms |
384 KB |
subtask_01_20.txt |
AC |
6 ms |
384 KB |
subtask_01_21.txt |
AC |
6 ms |
384 KB |
subtask_01_22.txt |
AC |
6 ms |
384 KB |
subtask_01_23.txt |
AC |
5 ms |
384 KB |
subtask_01_24.txt |
AC |
6 ms |
384 KB |
subtask_01_25.txt |
AC |
6 ms |
384 KB |
subtask_01_26.txt |
AC |
6 ms |
384 KB |
subtask_01_27.txt |
AC |
6 ms |
384 KB |
subtask_01_28.txt |
AC |
6 ms |
384 KB |
subtask_01_29.txt |
AC |
6 ms |
384 KB |
subtask_01_30.txt |
AC |
6 ms |
384 KB |