蒟蒻求问莫名其妙WA&RE
  • 板块学术版
  • 楼主TerryGong
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/11/29 13:24
  • 上次更新2023/10/27 01:01:16
查看原帖
蒟蒻求问莫名其妙WA&RE
167689
TerryGong楼主2022/11/29 13:24

RT\mathrm{RT},想了好几天了,还是不理解。

  • A

洛谷 9090,小图灵 3434。错误原因:Wrong Answer

#include <cstdio>
#define N 1010
#define P 998244353
using namespace std;
int f[N][N],g[N][N],df[N][N];
bool h[N][N];
inline bool dig(char x){return x>='0'&&x<='9';}
inline int read(){
	int x=0;char ch=getchar();
	while(!dig(ch))ch=getchar();
	while(dig(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x;
}
struct node{int x,y;};
signed main(){
	freopen("plant.in","r",stdin);
	freopen("plant.out","w",stdout);
int T=read(),id=read();while(T--){
	id++;
	int n=read(),m=read(),tc=read(),tf=read();
	long long ansc=0,ansf=0;
	char str[N];
	for(int i=1;i<=n;++i){
		scanf("%s",str+1);
		f[i][m+1]=0;
		for(int j=m;j>=1;--j){
			if(str[j]=='0')f[i][j]=1+f[i][j+1];
			else f[i][j]=0;
			h[i][j]=str[j]-'0';
		}
	}
	for(int j=1;j<=m;++j){
		g[n+1][m]=0;
		for(int i=n;i>=1;--i){
			if(h[i][j])g[i][j]=0;
			else g[i][j]=1+g[i+1][j];
			h[i][j]=(f[i][j]>=2&&g[i][j]>=3);
		}
	}
	for(int j=1;j<=m;++j)
		for(int i=1;i<=n;++i){
			f[i][j]--;g[i][j]--;
			df[i][j]=(df[i-1][j]+f[i][j]*g[i][j])%P;
			f[i][j]+=f[i-1][j];
		}
	if(tc==0&&tf==0){puts("0 0");continue;}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(h[i][j]){
				ansc=(ansc+(f[i+g[i][j]][j]-f[i+1][j])*(f[i][j]-f[i-1][j]))%P;
				ansf=tf*(ansf+(df[i+g[i][j]][j]-df[i+1][j]+P)%P*(f[i][j]-f[i-1][j]))%P;
			}
	printf("%lld %lld\n",ansc*tc,ansf*tf);
}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
  • B

错误原因:Runtime Error(Invalid memory refrences) 我不知道我的内存管理有啥问题。

#include <cstdio>
#include <vector>
#include <algorithm>
#define N 310
#define M 2000010
using namespace std;
inline bool dig(char x){return x>='0'&&x<='9';}
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!dig(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(dig(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int cnt,t[N<<1],r[N<<1];
vector<int> a[N];
struct ope{int op,o,p;}ans[M];
signed main(){
	freopen("meow.in","r",stdin);
	freopen("meow.out","w",stdout);
int T=read();while(T--){
	int n=read(),m=read(),k=read();cnt=0;
	if(n==1){
		for(int i=1;i<=m;i++)read();
		printf("%d\n",m);
		for(int i=1;i<=m;i++)puts("1 1");
		continue;
	}
	if(k&1){
		return 0;
	}
	else{
		for(int i=1;i<=n;i++)
			for(int j=0;j<=2;j++)
				a[i].push_back(0);
		for(int i=1;i<=m;i++){
			int x=read();
			if(t[x]){
				if(a[t[x]][1]==x){
					ans[++cnt]=(ope){1,t[x]};
					t[x]=0;
					a[t[x]][1]=0;
				}
				else{
					if(a[t[x]][1]==0){
						ans[++cnt]=(ope){1,t[x]};
						a[t[x]][0]=0;t[x]=0;
					}
					else{
						ans[++cnt]=(ope){1,n};
						ans[++cnt]=(ope){2,t[x],n};
						a[t[x]][0]=a[t[x]][1];
						a[t[x]][1]=0;
						t[x]=0;
					}
				}
			}
			else{
				ans[++cnt]=(ope){1,x%(n-1)+1};
				t[x]=x%(n-1)+1;
				if(a[t[x]][0]==0)a[t[x]][0]=x;
				else a[t[x]][1]=x;
			}
		}
	}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++){
		printf("%d ",ans[i].op);
		if(ans[i].op==1)printf("%d\n",ans[i].o);
		else printf("%d %d\n",ans[i].o,ans[i].p);
	}
}
	fclose(stdin);
	fclose(stdout);
	return 0;
}

2022/11/29 13:24
加载中...