QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#771391 | #5369. 时间旅行 | dongyc666 | 0 | 0ms | 3848kb | C++17 | 1.3kb | 2024-11-22 12:24:44 | 2024-11-22 12:24:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int NR=310;
int n,k,cnt[NR],v[NR],vis[NR],len;
mt19937 rnd(time(0));
int Rand(int l,int r){return rnd()%(r-l+1)+l;}
struct task{
int val,x,y;
bool operator <(const task &T)const{
return val<T.val;
}
}t[NR<<3],p[NR<<3];
vector<int>a[NR];
bool check(int x){
int tar=(n-k+1),tot=0;
memset(vis,0,sizeof(vis));
for(int i=1;i<=len;i++)
if(!vis[p[i].x]){
if(tot<tar/2)v[++tot]=p[i].val,vis[p[i].x]=1;
else if(p[i].val-v[tot-tar/2+1]>=x)v[++tot]=p[i].val,vis[p[i].x]=1;
}
return tot>=tar;
}
bool Check(int x){
for(int T=1;T<=100;T++){
for(int i=1;i<=len;i++)p[i]=t[i];
int now=0;
while(now<=len){
int k=Rand(1,min(10ll,len-now));
if(Rand(1,10)==1)shuffle(p+now+1,p+now+k+1,rnd);
now+=k;
}
if(check(x))return 1;
}
return 0;
}
signed main(){
cin>>n>>k;
if((n+k)&1){
puts("Impossible");
return 0;
}
for(int i=1;i<=n;i++){
cin>>cnt[i];a[i].resize(cnt[i]);
for(int j=0;j<cnt[i];j++)cin>>a[i][j],t[++len]=task{a[i][j],i,j};
sort(a[i].begin(),a[i].end());
}
sort(t+1,t+1+len);
int l=0,r=1e18,res=0;
while(l<=r){
int mid=(l+r)>>1;
if(check(mid))res=mid,l=mid+1;
else r=mid-1;
}
cout<<res<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3848kb
input:
13 1 1 13 1 2 1 9 1 11 1 8 1 5 1 6 1 4 1 10 1 7 1 12 1 1 1 3
output:
0
result:
wrong answer 1st lines differ - expected: '6', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 3688kb
input:
14 2 2 844974872 196961856 2 282529753 793092789 1 450615292 2 894675938 183278191 2 134804124 988858141 1 440476238 2 892091463 453193625 2 918614039 267044448 1 91126449 2 699070127 177282394 2 365458732 596469725 2 789994620 379428523 2 758349986 369167103 2 227448762 297426831
output:
0
result:
wrong answer 1st lines differ - expected: '392388416', found: '0'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%