QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#258775#1253. Abstract Circular Coverchenxinyang2006WA 4968ms12392kbC++142.1kb2023-11-20 09:38:162023-11-20 09:38:17

Judging History

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

  • [2023-11-20 09:38:17]
  • 评测
  • 测评结果:WA
  • 用时:4968ms
  • 内存:12392kb
  • [2023-11-20 09:38:16]
  • 提交

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];
			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];
			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(){
	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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 7900kb

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

input:

1
15

output:

15 

result:

ok "15"

Test #3:

score: -100
Wrong Answer
time: 4968ms
memory: 12392kb

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:

3 57 196 1175 1221 2931 4246 6963 10672 11804 14953 23690 27908 31490 35528 41224 46183 52680 65726 70188 80699 90424 104948 114365 130029 143857 158136 171183 182385 198739 216093 230310 246542 265050 281404 298758 312975 329207 349772 373043 398718 414950 435515 469288 484668 518441 539763 573536 ...

result:

wrong answer 1st words differ - expected: '260', found: '3'