QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#462489 | #1253. Abstract Circular Cover | ZSH_ZSH | TL | 0ms | 4072kb | C++14 | 1.6kb | 2024-07-03 20:16:10 | 2024-07-03 20:16:10 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define drep(i,a,b) for (int i=(a);i>=(b);i--)
using namespace std;
typedef long long ll;
const int inf=1e9;
inline bool chkmin(int &x,int y)
{
return (x>y?x=y,1:0);
}
#define debug if (n==850)
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
int n; cin>>n;
vector<vector<int> > a(n,vector<int>(n));
rep(i,0,n-1) rep(j,0,n-1) cin>>a[i][j];
auto norm=[&](int x){return (x+100*n)%n;};
vector<int> freq(n);
vector<int> ans(n+1,inf);
vector<int> mx(n);
auto solve=[&](int st,int top)
{
if (mx[st]>top) return;
mx[st]=top;
vector<vector<int> > f(n,vector<int>(top+1,inf));
vector<vector<int> > pre(n,vector<int>(top+1,-1));
rep(i,0,n-1)
{
f[i][1]=a[norm(st)][i];
pre[i][1]=-1;
if (i!=n-1)
{
rep(j,1,top-1) if (f[i][j]<inf)
{
rep(k,i+1,n-1)
{
if (chkmin(f[k][j+1],f[i][j]+a[norm(st+i+1)][k-(i+1)]))
{
pre[k][j+1]=i;
}
}
}
}
}
rep(i,1,top)
{
int now=n-1;
drep(j,i,1)
{
freq[norm(now+1)]++;
now=pre[now][j];
}
chkmin(ans[i],f[n-1][i]);
}
};
vector<int> ord(n);
rep(i,0,n-1) ord[i]=i;
mt19937 rng(3068863558);
drep(k,n,1)
{
rep(i,0,n-1) freq[i]=0;
shuffle(ord.begin(),ord.end(),rng);
int t=min(n,n/k/10+3);
rep(i,0,t-1) solve(ord[i],k);
sort(ord.begin(),ord.end(),[&](auto x,auto y){return freq[x]>freq[y];});
rep(i,0,t-1) solve(ord[i],k);
}
rep(i,1,n) printf("%d ",ans[i]);
printf("\n");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
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: 0ms
memory: 4072kb
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...