QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#39057#1269. New EquipmentswyhaoCompile Error//C++2.6kb2022-07-08 12:44:502022-07-08 12:44:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-08 12:44:52]
  • 评测
  • [2022-07-08 12:44:50]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
const int N=55,N1=3005,M=20005;
typedef long long ll;
int TT,n,m,S,T,cnt,num;
ll a[N],b[N],c[N],cst[M];
int to[M],nxt[M],f[M],h[N1];
void add(int i,int x,int y,int z,ll w){
//	printf("%d %d %d %lld\n",x,y,z,w);
	to[i]=y;f[i]=z;nxt[i]=h[x];cst[i]=w;h[x]=i;
}
map<int,int>Map;
ll F(int i,int j){
	return a[i]*j*j+b[i]*j+c[i];
}
struct node{
	int val;ll key;
	bool operator<(const node a)const{
		return key>a.key;
	}
}d[N<<1],p;
int tot;
bool cmp(node x,node y){
	return x.key<y.key;
}
void get1(int i,int &l,int &r){
	if(2*a[i]>=-b[i]){
		l=1;r=n;
		return;
	}
	if(2*a[i]*m<=-b[i]){
		r=m;l=m-n+1;
		return;
	}
	tot=1;int t=-b[i]/(a[i]*2);
	d[1].val=t;d[1].key=F(i,t);
	for(int i=1;i<=n;i++){
		if(t-i>=1){
			tot++;
			d[tot].val=t-i;
			d[tot].val=F(i,t-i);
		}
		if(t+i<=m){
			tot++;
			d[tot].val=t+i;
			d[tot].val=F(i,t+i);
		}
	}
	sort(d+1,d+tot+1,cmp);
	l=m;r=1;
	for(int i=1;i<=n;i++){
		if(d[i].val<l) l=d[i].val;
		if(d[i].val>r) r=d[i].val;
	}
}
priority_queue<node>Q;
ll dis[N1];
int pre[N1];
bool vis[N1];
ll dfs(){
	memset(dis,0x3f,sizeof dis);
	memset(vis,false;sizeof vis);
	while(!Q.empty()) Q.pop();
	dis[S]=0;pre[S]=-1;
	p.val=S;p.key=0;Q.push(p);
	while(!Q.empty()){
		int x=Q.top().val;Q.pop();
		if(vis[x]) continue;
		vis[x]=true;
		if(x==T) return dis[T];
		for(int i=h[x],y;i;i=nxt[i]){
			y=to[i];
			if(vis[y]) continue;
			if(f[i] and dis[y]>dis[x]+cst[i]){
				dis[y]=dis[x]+cst[i];
				p.val=y;p.key=dis[y];
				Q.push(p);
				pre[y]=i;
			}
		}
	}
	return 0x3f3f3f3f3f3f3f3f;
}
void path(){
	for(int t=pre[T];~t;t=pre[to[t^1]]){
		f[t]--;f[t^1]++;
	}
}
int main(){
	scanf("%d",&TT);
	while(TT--){
		scanf("%d%d",&n,&m);num=n;
		for(int i=1;i<=n;i++){
			scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
		}
		Map.clear();cnt=1;
		for(int i=1,l,r,k;i<=n;i++){
			get1(i,l,r);
//			printf("%d %d\n",l,r);
			for(int j=l;j<=r;j++){
				if(!Map[j]) Map[j]=++num;
				k=Map[j];ll w=F(i,j);
				add(++cnt,i,k,1,w);
				add(++cnt,k,i,0,-w);
			}
		}
		S=num+1;T=S+1;
		for(int i=1;i<=n;i++){
			add(++cnt,S,i,1,0);
			add(++cnt,i,S,0,0);
		}
		for(int i=n+1;i<=num;i++){
			add(++cnt,i,T,1,0);
			add(++cnt,T,i,0,0);
		}
		ll ans=0;
		for(int i=1;i<=n;i++){
			ll k=dfs();
//			printf("%lld\n",k);
			if(k!=0x3f3f3f3f3f3f3f3f){
				ans+=k;path();
				printf("%lld ",ans);
			}else{
				for(;i<=n;i++) printf("%lld ",ans);
				break;
			}
		}
	}
	return 0;
}

详细

answer.code: In function ‘ll dfs()’:
answer.code:66:25: error: expected ‘)’ before ‘;’ token
   66 |         memset(vis,false;sizeof vis);
      |               ~         ^
      |                         )
answer.code:66:36: error: expected ‘;’ before ‘)’ token
   66 |         memset(vis,false;sizeof vis);
      |                                    ^
      |                                    ;
answer.code: In function ‘int main()’:
answer.code:94:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   94 |         scanf("%d",&TT);
      |         ~~~~~^~~~~~~~~~
answer.code:96:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   96 |                 scanf("%d%d",&n,&m);num=n;
      |                 ~~~~~^~~~~~~~~~~~~~
answer.code:98:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   98 |                         scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~