QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203921 | #87. Devil's Share | Ahmed57# | 13 | 1265ms | 3716kb | C++23 | 1.2kb | 2023-10-06 22:13:13 | 2024-07-04 02:17:03 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int arr[5];string s;
string maa;string w;int k,x;
string lol[4*4*4*4][13];
void rec(){
bool ss = 0;
for(int i = 1;i<=4;i++){
if(arr[i]){
ss = 1;
arr[i]--;s+=char(i+'0');
rec();
arr[i]++;
s.pop_back();
}
}
if(ss==0){
string ma;
for(int j = 0;j<s.size()-k+1;j++){
string se;
for(int e = j;e<j+k;e++)se+=s[e];
if(ma.empty())ma = se;
ma = max(ma,se);
}
if(maa.empty()||ma<maa){
maa = ma;
w = s;
}
}
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int t;cin>>t;
while(t--){
cin>>k;
int de = 0;
for(int i = 1;i<=4;i++){
de*=4;
cin>>arr[i];de+=arr[i];
}
if(lol[de][k].empty()){
for(int i = 5;i<10;i++){
cin>>x;
}
maa = "";
rec();
cout<<w<<endl;
lol[de][k] = w;
}else cout<<lol[de][k]<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 13
Accepted
Test #1:
score: 13
Accepted
time: 1265ms
memory: 3716kb
input:
1536 4 2 1 2 2 0 0 0 0 0 2 3 2 3 3 0 0 0 0 0 3 1 2 0 3 0 0 0 0 0 4 2 2 3 2 0 0 0 0 0 1 3 3 2 2 0 0 0 0 0 3 1 2 2 0 0 0 0 0 0 3 2 1 2 3 0 0 0 0 0 6 1 3 3 0 0 0 0 0 0 4 1 0 1 2 0 0 0 0 0 4 2 1 2 3 0 0 0 0 0 4 2 3 0 2 0 0 0 0 0 5 3 2 3 3 0 0 0 0 0 3 2 2 1 1 0 0 0 0 0 3 2 3 2 0 0 0 0 0 0 8 1 3 1 3 0 0 0...
output:
3112344 12233341414 241244 312312344 1112223344 22133 23341144 2122333 1344 31312444 2121244 31131223444 212134 2122133 12223444 13444 12223334 13341144 2313132244 12342424 122233 211444 11223 11223344 11222334 13 223131314 323244 2323234 11334 3123123444 114 122233414 11333 12234 222334 3111444 144...
result:
ok Correct!
Subtask #2:
score: 0
Runtime Error
Test #2:
score: 0
Runtime Error
input:
35960 2 0 0 5 2 0 0 17 0 7 2 0 6 0 15 0 0 0 4 5 2 3 0 0 1 20 0 0 0 8 2 0 5 0 0 15 0 5 7 0 2 0 0 2 11 0 0 4 0 10 2 0 14 0 0 11 0 0 6 1 2 0 0 10 3 0 0 8 0 1 2 0 1 9 0 2 0 0 6 0 2 0 0 0 0 5 0 12 7 3 2 0 0 5 0 0 2 0 8 9 2 7 2 0 0 0 0 0 6 8 2 0 0 0 4 1 0 3 18 0 2 0 0 14 4 8 0 0 0 1 2 0 2 0 0 0 13 3 9 0 2...
output:
3333434 222222444444444444444 1114 22222 3344444444444 22222222222222 3333333343434 2333333333
result:
Subtask #3:
score: 0
Runtime Error
Test #11:
score: 0
Runtime Error
input:
26488 21 7 19 0 0 0 0 0 0 0 3 15 21 0 0 0 0 0 0 0 7 4 35 0 0 0 0 0 0 0 5 28 12 0 0 0 0 0 0 0 22 40 3 0 0 0 0 0 0 0 1 7 6 0 0 0 0 0 0 0 5 12 21 0 0 0 0 0 0 0 18 27 13 0 0 0 0 0 0 0 2 36 6 0 0 0 0 0 0 0 15 19 14 0 0 0 0 0 0 0 34 17 20 0 0 0 0 0 0 0 11 17 5 0 0 0 0 0 0 0 19 10 12 0 0 0 0 0 0 0 28 29 9 ...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%