QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203919 | #87. Devil's Share | Ahmed57# | 0 | 0ms | 0kb | C++23 | 1.2kb | 2023-10-06 22:10:32 | 2024-07-04 02:17:02 |
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];
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].empty()){
for(int i = 5;i<10;i++){
cin>>x;
}
maa = "";
rec();
cout<<w<<endl;
lol[de] = w;
}else cout<<lol[de]<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Judgement Failed
Test #1:
score: 0
Judgement Failed
input:
output:
result:
Subtask #2:
score: 0
Judgement Failed
Test #2:
score: 0
Judgement Failed
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:
result:
Subtask #3:
score: 0
Judgement Failed
Test #11:
score: 0
Judgement Failed
input:
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%