QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#21218 | #1253. Abstract Circular Cover | chestizcy | TL | 2ms | 3756kb | C++17 | 1.3kb | 2022-03-03 19:38:27 | 2022-05-08 02:35:12 |
Judging History
answer
#include<bits/stdc++.h>
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
template <typename _Tp>void read(_Tp &x){
char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar();
x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar();
if(f)x=-x;
}
template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);}
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>inline void chmin(_Tp &a,const _Tp &b){a=a<b?a:b;}
const int N=855,inf=0x3f3f3f3f;
int c[N][N],ans[N],n,f[N][N],p[N];
void solve(int k,int x){
int m=0;for(int i=x;i<=n;++i)p[++m]=i;
for(int i=1;i<x;++i)p[++m]=i;
for(int i=1;i<=n+1;++i)memset(f[i],63,(k+1)<<2);
f[1][0]=0;
for(int i=1;i<=n;++i){
int o=p[i];
for(int j=1;i+j<=n+1;++j)for(int t=0;t<k;++t){
chmin(f[i+j][t+1],f[i][t]+c[o][j]);
}
}
for(int i=1;i<=k;++i)chmin(ans[i],f[n+1][i]);
}
int main(){
read(n);for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)read(c[i][j]);
memset(ans,63,sizeof(ans));
for(int i=n;i>=1;--i){
int T=(1.0*n/i-(i==n?0:1.0*n/(i+1)))*20;
while(T--)solve(i,rnd()%n+1);
}
for(int i=1;i<=n;++i)printf("%d%c",ans[i]," \n"[i==n]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3756kb
input:
3 10 12 23 7 4 11 8 5 3
output:
3 12 25
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
1 15
output:
15
result:
ok "15"
Test #3:
score: -100
Time Limit Exceeded
input:
850 467844 492130 605609 643857 26979 997775 457911 823516 154840 985025 993710 334965 480280 45505 851380 765414 512285 661374 745909 563360 878563 887945 542943 288759 124012 159576 828454 705380 24125 806150 695873 109057 933855 632721 259819 784272 398751 935451 393059 788917 560334 786155 54986...