QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21648#2848. 城市地铁规划gsh#RE 0ms0kbC++202.2kb2022-03-07 18:03:242022-05-08 03:46:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 03:46:49]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-03-07 18:03:24]
  • 提交

answer

#include<map>
#include<set>
#include<queue>
#include<deque>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
#define mkp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define fs fflush(stdout)
#define ump unordered_map
#define pq priority_queue
#define clz __builtin_clz
#define ctz __builtin_ctz
#define space putchar(' ')
#define enter putchar('\n')
#define sz(x) (int)x.size()
#define np next_permutation
#define clzl __builtin_clzll
#define par __builtin_parity
#define ctzl __builtin_ctzll
#define ppc __builtin_popcount
#define parl __builtin_parityll
#define all(x) x.begin(),x.end()
#define ppcl __builtin_popcountll
#define ms(x,y) memset(x,y,sizeof(x))
#define debug(x) cerr<<#x<<"= "<<(x)<<'\n'
template<class T> inline T &read(T &x){
	x=0;int f=1;char ch=getchar();
	while(ch<48||ch>57){if(ch=='-') f=-f;ch=getchar();}
	while(ch>=48&&ch<=57) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*=f;
}
template<class T> inline void print(T x){
	static char buf[40];static int cnt=0;
	if(x<0) putchar(45),x=-x;
	do buf[++cnt]=x%10^48;while(x/=10);
	do putchar(buf[cnt--]);while(cnt);
}
#define mod 59393
#define inf 0x3f3f3f3f
#define fpi freopen("","r",stdin)
#define fpo freopen("","w",stdout)
int a[11],sum[11],deg[3005],dp[6005],lst[6005];
int main(){
	int n=read(n),k=read(k),i,j,now=n-2;
	for(i=0;i<=k;i++) read(a[i]);
	for(i=1;i<n;i++){int mul=1;for(j=0;j<=k;j++) (sum[i]+=a[j]*mul)%=mod,(mul*=i)%=mod;}
	print(n-1),space,dp[0]=n*sum[1];
	for(i=2;i<=n;i++) for(j=i-1;j<n-1;j++) if(dp[j-i+1]+sum[i]-sum[1]>dp[j]) dp[j]=dp[j-i+1]+sum[i]-sum[1],lst[j]=j-i+1;
	print(dp[n-2]),enter;
	for(i=1;i<=n;i++) deg[i]=now-lst[now]+1,now=lst[now];
	sort(deg+1,deg+n+1),now=n+1;
	for(i=1;i<=n;i++) if(deg[i]>1){now=i;break;}
	for(i=1;i<n-1;i++){
		print(i),space,print(now),enter;
		deg[now]--;if(deg[now]==1) now++;
	}print(n-1),space,print(n);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

63 7
4 50 14 48 33 13 44 24

output:


result: