QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#471335#5416. Fabulous Fungus FrenzyzyxawaCompile Error//C++231.9kb2024-07-10 20:37:242024-07-10 20:37:25

Judging History

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

  • [2024-07-10 20:37:25]
  • 评测
  • [2024-07-10 20:37:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define trans(c) (isdigit(c)?c-48:(islower(c)?c-87:c-29))
char ch[21];
vector <tuple<int,int,int>> ans;
int n,m,k,a[21][21],c[21][21][21],h[21],w[21],cnt[63],v[21][21];
int check(int k){
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cnt[a[i][j]]++;
	int res=0;
	for(int i=1;i<=h[k];i++){
		for(int j=1;j<=w[k];j++){
			if(cnt[c[k][i][j]]) cnt[c[k][i][j]]--,res++;
			else if(cnt[0]) cnt[0]--;
			else return -1;
		}
	}
	return res;
}
void solve(int k){
	memset(v,0,sizeof(v));
	for(int i=1;i<=h[k];i++){
		for(int j=1;j<=w[k];j++){
			int x=0,y=0;
			for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&a[l][r]==c[k][i][j]) x=l,y=r;
			if(!x) for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&!a[l][r]) x=l,y=r;
			while(x<i) swap(a[x][y],a[x+1][y]),ans.push_back({-3,x++,y});
			while(y<j) swap(a[x][y],a[x][y+1]),ans.push_back({-1,x,y++});
			while(y>j) swap(a[x][y],a[x][y-1]),ans.push_back({-2,x,y--});
			while(x>i) swap(a[x][y],a[x-1][y]),ans.push_back({-4,x--,y});
			v[i][j]=1;
		}
	}
	for(int i=1;i<=h[k];i++) for(int j=1;j<=w[k];j++) a[i][j]=0;
	if(k) ans.push_back({k,1,1});
}
int main(){
	scanf("%d%d%d",&n,&m,&k),h[0]=n,w[0]=m;
	for(int i=1;i<=n;i++){
		scanf("%s",ch+1);
		for(int j=1;j<=m;j++) c[0][i][j]=trans(ch[j]);
	}
	for(int i=1;i<=n;i++){
		scanf("%s",ch+1);
		for(int j=1;j<=m;j++) a[i][j]=trans(ch[j]);
	}
	for(int i=1;i<=k;i++){
		scanf("%d%d",&h[i],&w[i]);
		for(int j=1;j<=h[i];j++){
			scanf("%s",ch+1);
			for(int l=1;l<=w[i];l++) c[i][j][l]=trans(ch[l]);
		}
	}
	while(1){
		if(check(0)>=0) break;
		int f=0;
		for(int i=1;i<=k;i++) if(check(i)>0) f=1,solve(i);
		if(!f) return printf("-1"),0;
	}
	solve(0);
	reverse(begin(ans),end(ans));
	printf("%d\n",ans.size());
	for(auto [a,b,c]:ans) printf("%d %d %d\n",a,b,c);
	return 0;
}

详细

answer.code: In function ‘void solve(int)’:
answer.code:25:40: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 |                         for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&a[l][r]==c[k][i][j]) x=l,y=r;
      |                                     ~~~^~~
answer.code:25:64: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 |                         for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&a[l][r]==c[k][i][j]) x=l,y=r;
      |                                                             ~~~^~~
answer.code:26:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |                         if(!x) for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&!a[l][r]) x=l,y=r;
      |                                            ~~~^~~
answer.code:26:71: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |                         if(!x) for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&!a[l][r]) x=l,y=r;
      |                                                                    ~~~^~~
answer.code:25:39: error: label ‘l’ used but not defined
   25 |                         for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&a[l][r]==c[k][i][j]) x=l,y=r;
      |                                       ^
answer.code:25:63: error: label ‘r’ used but not defined
   25 |                         for(int l=1;&&l<=n;l++) for(int r=1;&&r<=m;r++) if(!v[l][r]&&a[l][r]==c[k][i][j]) x=l,y=r;
      |                                                               ^
answer.code: In function ‘int main()’:
answer.code:62:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<std::tuple<int, int, int> >::size_type’ {aka ‘long unsigned int’} [-Wformat=]
   62 |         printf("%d\n",ans.size());
      |                 ~^    ~~~~~~~~~~
      |                  |            |
      |                  int          std::vector<std::tuple<int, int, int> >::size_type {aka long unsigned int}
      |                 %ld
answer.code:38:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |         scanf("%d%d%d",&n,&m,&k),h[0]=n,w[0]=m;
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:40:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |                 scanf("%s",ch+1);
      |                 ~~~~~^~~~~~~~~~~
answer.code:44:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |                 scanf("%s",ch+1);
      |                 ~~~~~^~~~~~~~~~~
answer.code:48:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |                 scanf("%d%d",&h[i],&w[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~
answer.code:50:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |                         scanf("%s",ch+1);
      |                         ~~~~~^~~~~~~~~~~