Submission #1173941
Source Code Expand
#include<iostream> #include<sstream> #include<fstream> #include<string> #include<vector> #include<deque> #include<queue> #include<stack> #include<set> #include<map> #include<algorithm> #include<functional> #include<utility> #include<bitset> #include<cmath> #include<cstdlib> #include<ctime> #include<cstdio> using namespace std; #define REP(i,n) for(int i=0;i<int(n);i++) #define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++) typedef long long ll; typedef pair<int,int> P; int m[35][35]; int a[460],b[460],c[460],d[460]; char mv[460][10010]; int main(void){ int i,j; int H,W,K,T; cin >> H >> W >> K >> T; for(i=1;i<=K;i++){ cin >> a[i] >> b[i] >> c[i] >> d[i]; m[a[i]][b[i]]=1; } for(i=1;i<=K;i++){ for(j=1;j<=T;j++){ mv[i][j]='-'; } } int LL=0; bool f=true; while(LL<T){ if(!f) break; for(i=1;i<=K;i++){ if(a[i]>=c[i]){ if(d[i]>=b[i]){ int rr=d[i]-b[i]; int uu=a[i]-c[i]; while(1){ if(m[a[i]][b[i]+1]==0 && b[i]+1<=W && rr>0){ LL++; mv[i][LL]='R'; m[a[i]][b[i]]=0; b[i]++; m[a[i]][b[i]]=1; rr--; } else if(m[a[i]-1][b[i]]==0 && a[i]-1>=1 && uu>0){ LL++; mv[i][LL]='U'; m[a[i]][b[i]]=0; a[i]--; m[a[i]][b[i]]=1; uu--; }else{ f=false; break; } } }else{ int ll=b[i]-d[i]; int uu=a[i]-c[i]; while(1){ if(m[a[i]][b[i]-1]==0 && b[i]-1>=1 && ll>0){ LL++; mv[i][LL]='L'; m[a[i]][b[i]-1]=0; b[i]--; m[a[i]][b[i]]=1; ll--; } else if(m[a[i]-1][b[i]]==0 && a[i]-1>=1 && uu>0){ LL++; mv[i][LL]='U'; m[a[i]][b[i]]=0; a[i]--; m[a[i]][b[i]]=1; uu--; }else{ f=false; break; } } } }else{ if(d[i]>=b[i]){ int rr=d[i]-b[i]; int dd=c[i]-a[i]; while(1){ if(m[a[i]][b[i]+1]==0 && b[i]+1<=W && rr>0){ LL++; mv[i][LL]='R'; m[a[i]][b[i]]=0; b[i]++; m[a[i]][b[i]]=1; rr--; } else if(m[a[i]+1][b[i]]==0 && a[i]+1<=H && dd>0){ LL++; mv[i][LL]='D'; m[a[i]][b[i]]=0; a[i]++; m[a[i]][b[i]]=1; dd--; }else{ f=false; break; } } }else{ int ll=b[i]-d[i]; int dd=c[i]-a[i]; while(1){ if(m[a[i]][b[i]-1]==0 && b[i]-1>=1 && ll>0){ LL++; mv[i][LL]='L'; m[a[i]][b[i]]=0; b[i]--; m[a[i]][b[i]]=1; ll--; } else if(m[a[i]+1][b[i]]==0 && a[i]+1<=H && dd>0){ LL++; mv[i][LL]='D'; m[a[i]][b[i]]=0; a[i]++; m[a[i]][b[i]]=1; dd--; }else{ f=false; break; } } } } } } cout << LL << endl; for(j=1;j<=LL;j++){ for(i=1;i<=K;i++){ cout << mv[i][j]; } cout << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - 日本橋大渋滞 |
User | daiota |
Language | C++14 (GCC 5.4.1) |
Score | 1908 |
Code Size | 4450 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 5120 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 | 66 / 50000 | 63 / 50000 | 69 / 50000 | 68 / 50000 | 66 / 50000 | 62 / 50000 | 64 / 50000 | 71 / 50000 | 60 / 50000 | 60 / 50000 | 69 / 50000 | 60 / 50000 | 64 / 50000 | 63 / 50000 | 59 / 50000 | 65 / 50000 | 60 / 50000 | 62 / 50000 | 63 / 50000 | 63 / 50000 | 68 / 50000 | 65 / 50000 | 60 / 50000 | 66 / 50000 | 62 / 50000 | 65 / 50000 | 61 / 50000 | 61 / 50000 | 60 / 50000 | 63 / 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 | 18 ms | 5120 KB |
subtask_01_02.txt | AC | 19 ms | 5120 KB |
subtask_01_03.txt | AC | 17 ms | 4992 KB |
subtask_01_04.txt | AC | 19 ms | 5120 KB |
subtask_01_05.txt | AC | 21 ms | 5120 KB |
subtask_01_06.txt | AC | 20 ms | 5120 KB |
subtask_01_07.txt | AC | 19 ms | 5120 KB |
subtask_01_08.txt | AC | 17 ms | 4992 KB |
subtask_01_09.txt | AC | 18 ms | 5120 KB |
subtask_01_10.txt | AC | 20 ms | 5120 KB |
subtask_01_11.txt | AC | 18 ms | 5120 KB |
subtask_01_12.txt | AC | 20 ms | 5120 KB |
subtask_01_13.txt | AC | 18 ms | 5120 KB |
subtask_01_14.txt | AC | 19 ms | 5120 KB |
subtask_01_15.txt | AC | 20 ms | 5120 KB |
subtask_01_16.txt | AC | 20 ms | 5120 KB |
subtask_01_17.txt | AC | 20 ms | 5120 KB |
subtask_01_18.txt | AC | 19 ms | 5120 KB |
subtask_01_19.txt | AC | 19 ms | 5120 KB |
subtask_01_20.txt | AC | 19 ms | 5120 KB |
subtask_01_21.txt | AC | 18 ms | 4992 KB |
subtask_01_22.txt | AC | 18 ms | 4992 KB |
subtask_01_23.txt | AC | 20 ms | 5120 KB |
subtask_01_24.txt | AC | 16 ms | 4992 KB |
subtask_01_25.txt | AC | 18 ms | 5120 KB |
subtask_01_26.txt | AC | 18 ms | 5120 KB |
subtask_01_27.txt | AC | 20 ms | 5120 KB |
subtask_01_28.txt | AC | 18 ms | 4992 KB |
subtask_01_29.txt | AC | 20 ms | 5120 KB |
subtask_01_30.txt | AC | 19 ms | 5120 KB |