QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#462476 | #1253. Abstract Circular Cover | ZSH_ZSH | RE | 1ms | 3884kb | C++14 | 1.5kb | 2024-07-03 20:02:13 | 2024-07-03 20:02:14 |
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);
auto solve=[&](int st)
{
vector<vector<int> > f(n,vector<int>(n+1,inf));
vector<vector<int> > pre(n,vector<int>(n,-1));
rep(i,0,n-1)
{
f[i][1]=a[norm(st)][i];
pre[i][1]=-1;
rep(j,2,n)
{
rep(k,0,i-1)
{
if (chkmin(f[i][j],f[k][j-1]+a[norm(st+k+1)][i-k-1]))
{
pre[i][j]=k;
}
}
}
debug printf("i %d\n",i);
}
debug printf("here\n");
rep(i,1,n)
{
int now=n-1;
drep(j,i,1)
{
assert(now!=-1);
freq[norm(now+1)]++;
now=pre[now][j];
}
assert(now==-1);
chkmin(ans[i],f[n-1][i]);
}
};
mt19937 rng(3068863558);
int T=10;
rep(i,1,T)
{
int x=rng()%n;
debug printf("x %d\n",x);
solve(x);
debug return 0;
}
debug printf("here ok\n");
debug return 0;
vector<int> ord(n);
rep(i,0,n-1) ord[i]=i;
sort(ord.begin(),ord.end(),[&](auto x,auto y){return freq[x]>freq[y];});
rep(i,0,min(T,n)-1)
{
solve(ord[i]);
}
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: 1ms
memory: 3884kb
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: 1ms
memory: 3684kb
input:
1 15
output:
15
result:
ok "15"
Test #3:
score: -100
Runtime Error
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...
output:
x 688 i 0 i 1 i 2 i 3 i 4 i 5 i 6 i 7 i 8 i 9 i 10 i 11 i 12 i 13 i 14 i 15 i 16 i 17 i 18 i 19 i 20 i 21 i 22 i 23 i 24 i 25 i 26 i 27 i 28 i 29 i 30 i 31 i 32 i 33 i 34 i 35 i 36 i 37 i 38 i 39 i 40 i 41 i 42 i 43 i 44 i 45 i 46 i 47 i 48 i 49 i 50 i 51 i 52 i 53 i 54 i 55 i 56 i 57 i 58 i 59 i 60...