QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#258778#1253. Abstract Circular Coverchenxinyang2006WA 4963ms12372kbC++142.2kb2023-11-20 09:48:362023-11-20 09:48:37

Judging History

你现在查看的是最新测评结果

  • [2023-11-20 09:48:37]
  • 评测
  • 测评结果:WA
  • 用时:4963ms
  • 内存:12372kb
  • [2023-11-20 09:48:36]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}


/*ll power(ll p,int k = mod - 2){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = ans * p % mod;
		p = p * p % mod;
		k /= 2;	
	}
	return ans;
}*/
int n;
int c[855][855],ord[855];
mt19937 rnd(0);

int a[855][855],dp[855][855],ans[855];
void solve(int p){//强制以 p 位置作为开始
	int cur = p,K = 0;
	while(1){
		rep(i,1,n) a[K][i] = c[cur][i];
		cur++;K++;
		cur %= n;
		if(cur == p) break;
	}
	rep(i,0,n - 1){
		fill(dp[i],dp[i] + n + 1,inf);
		rep(j,0,i){
			int delta = a[j][i - j + 1];
			if(!j) chkmin(dp[i][1],delta);
			rep(k,2,j + 1) chkmin(dp[i][k],dp[j - 1][k - 1] + delta);
		}
	}
	rep(k,1,n) chkmin(ans[k],dp[n - 1][k]);
}

const int lim = 50;
void solve2(int p){
	int cur = p,K = 0;
	while(1){
		rep(i,1,n) a[K][i] = c[cur][i];
		cur++;K++;
		cur %= n;
		if(cur == p) break;
	}
	rep(i,0,n - 1){
		fill(dp[i],dp[i] + lim + 1,inf);
		rep(j,0,i){
			int delta = a[j][i - j + 1];
			if(!j) chkmin(dp[i][1],delta);
			rep(k,2,min(j + 1,lim)) chkmin(dp[i][k],dp[j - 1][k - 1] + delta);
		}
	}
	rep(k,1,lim) chkmin(ans[k],dp[n - 1][k]);		
}

int main(){
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%d",&n);
	rep(i,0,n - 1){
		rep(j,1,n) scanf("%d",&c[i][j]);
	}
	rep(i,0,n - 1) ord[i] = i;
	rep(i,0,n - 1) swap(ord[i],ord[rnd() % (i + 1)]);
	fill(ans,ans + n + 1,inf);

	rep(i,0,lim) solve(ord[i]);
	rep(i,0,n - 1) solve2(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: 7724kb

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: 7600kb

input:

1
15

output:

15 

result:

ok "15"

Test #3:

score: 0
Accepted
time: 4963ms
memory: 12120kb

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:

260 583 4456 6370 5867 10516 8445 11322 22257 25758 29686 36603 43777 37503 42305 54915 55969 74889 75170 96572 108980 118941 131680 143190 159544 172374 192023 199700 216054 236664 249640 263857 282365 298719 319329 332305 346522 367087 401391 418048 432265 452830 486603 507925 541698 567714 601189...

result:

ok 850 tokens

Test #4:

score: -100
Wrong Answer
time: 4547ms
memory: 12372kb

input:

850
1 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 ...

output:

151599 151600 151601 151602 151603 151604 151605 151606 151607 151608 151609 151610 151611 151612 151613 151614 151615 151616 151617 151618 151619 151620 151621 151622 151623 151624 151625 151626 151627 151628 151629 151630 151631 151632 151633 151634 151635 151636 151637 151638 151639 151640 151641...

result:

wrong answer 54th words differ - expected: '151652', found: '303250'