Submission #1173286
Source Code Expand
#include<iostream>
#include<string>
#include<vector>
#include<bitset>
#include<cstdlib>
#include<random>
using namespace std;
typedef bitset<900> BS;
constexpr int H=30,W=30,K=450,T=10000;
int A[K],B[K],C[K],D[K];
mt19937 engine;
int main(){
int h,w,kk,t;
cin>>h>>w>>kk>>t;
for(int i=0;i<K;i++){
cin>>A[i]>>B[i]>>C[i]>>D[i];
A[i]--;
B[i]--;
C[i]--;
D[i]--;
}
vector<string> ans;
double score=0;
for(;;){
int a[K],b[K];
copy(begin(A),end(A),begin(a));
copy(begin(B),end(B),begin(b));
BS cars;
for(int i=0;i<K;i++){
cars[a[i]*W+b[i]]=true;
}
vector<string> cans;
for(int i=0;;i++){
double cpd=20;
for(int j=0;j<K;j++){
cpd+=abs(a[j]-C[j])+abs(b[j]-D[j]);
}
double cpt=10+i*0.01;
double cscore=10000000./(cpd*cpt);
if(cscore>score){
ans=cans;
score=cscore;
}
if(i==T)break;
BS ncars,cncars=cars;
int oa[K],ob[K];
copy(begin(a),end(a),begin(oa));
copy(begin(b),end(b),begin(ob));
string moves;
for(int k=0;k<K;k++){
vector<int> cands;
const static int dy[]={-1,0,1,0,0};
const static int dx[]={0,1,0,-1,0};
for(int l=0;l<4;l++){
int ny=oa[k]+dy[l];
int nx=ob[k]+dx[l];
if(0<=ny&&ny<H&&0<=nx&&nx<W&&!cncars[ny*W+nx]){
if(abs(ny-C[k])+abs(nx-D[k])<abs(oa[k]-C[k])+abs(ob[k]-D[k])){
cands.push_back(l);
}
}
}
int m=cands.empty()?4:cands[uniform_int_distribution<>(0,cands.size()-1)(engine)];
moves+="URDL-"[m];
a[k]+=dy[m];
b[k]+=dx[m];
int y=a[k],x=b[k];
ncars[y*W+x]=true;
cncars[y*W+x]=true;
}
cars=ncars;
cans.push_back(moves);
}
break;
}
cout<<ans.size()<<endl;
for(auto e:ans){
cout<<e<<endl;
}
}
Submission Info
Submission Time |
|
Task |
B - 日本橋大渋滞 |
User |
ustimaw |
Language |
C++14 (GCC 5.4.1) |
Score |
4636 |
Code Size |
1834 Byte |
Status |
AC |
Exec Time |
128 ms |
Memory |
6396 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 |
161 / 50000 |
160 / 50000 |
161 / 50000 |
157 / 50000 |
174 / 50000 |
160 / 50000 |
161 / 50000 |
156 / 50000 |
144 / 50000 |
150 / 50000 |
159 / 50000 |
159 / 50000 |
148 / 50000 |
164 / 50000 |
148 / 50000 |
165 / 50000 |
149 / 50000 |
151 / 50000 |
151 / 50000 |
153 / 50000 |
159 / 50000 |
150 / 50000 |
151 / 50000 |
145 / 50000 |
152 / 50000 |
153 / 50000 |
152 / 50000 |
139 / 50000 |
154 / 50000 |
150 / 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 |
128 ms |
6396 KB |
subtask_01_02.txt |
AC |
121 ms |
5760 KB |
subtask_01_03.txt |
AC |
120 ms |
5760 KB |
subtask_01_04.txt |
AC |
121 ms |
5760 KB |
subtask_01_05.txt |
AC |
124 ms |
5760 KB |
subtask_01_06.txt |
AC |
119 ms |
5760 KB |
subtask_01_07.txt |
AC |
123 ms |
5760 KB |
subtask_01_08.txt |
AC |
119 ms |
5760 KB |
subtask_01_09.txt |
AC |
119 ms |
5760 KB |
subtask_01_10.txt |
AC |
118 ms |
5760 KB |
subtask_01_11.txt |
AC |
122 ms |
5760 KB |
subtask_01_12.txt |
AC |
120 ms |
5760 KB |
subtask_01_13.txt |
AC |
120 ms |
5760 KB |
subtask_01_14.txt |
AC |
121 ms |
5760 KB |
subtask_01_15.txt |
AC |
124 ms |
5760 KB |
subtask_01_16.txt |
AC |
124 ms |
5760 KB |
subtask_01_17.txt |
AC |
118 ms |
5760 KB |
subtask_01_18.txt |
AC |
118 ms |
5760 KB |
subtask_01_19.txt |
AC |
121 ms |
5760 KB |
subtask_01_20.txt |
AC |
116 ms |
5760 KB |
subtask_01_21.txt |
AC |
118 ms |
5760 KB |
subtask_01_22.txt |
AC |
121 ms |
5760 KB |
subtask_01_23.txt |
AC |
118 ms |
5760 KB |
subtask_01_24.txt |
AC |
120 ms |
5760 KB |
subtask_01_25.txt |
AC |
122 ms |
5760 KB |
subtask_01_26.txt |
AC |
117 ms |
5760 KB |
subtask_01_27.txt |
AC |
125 ms |
5760 KB |
subtask_01_28.txt |
AC |
116 ms |
5760 KB |
subtask_01_29.txt |
AC |
123 ms |
5760 KB |
subtask_01_30.txt |
AC |
117 ms |
5760 KB |