QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#820341#9884. Grid Constructionas_lyrCompile Error//C++143.3kb2024-12-18 21:04:022024-12-18 21:04:08

Judging History

This is the latest submission verdict.

  • [2024-12-18 21:04:08]
  • Judged
  • [2024-12-18 21:04:02]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N][N];
char c[5];
void worka(int x,int y){
	                            a[x+0][y+0]=0;
	              a[x+1][y-1]=3,a[x+1][y+0]=3,a[x+1][y+1]=0;
	a[x+2][y-2]=3,a[x+2][y-1]=2,a[x+2][y+0]=4,a[x+2][y+1]=0,a[x+2][y+2]=1;
	              a[x+3][y-1]=2,a[x+3][y+0]=1,a[x+3][y+1]=1;
	                            a[x+4][y+0]=2;
}
void workb(int x,int y){
	                            a[x+0][y+0]=0;
	              a[x+1][y-1]=3,a[x+1][y+0]=0,a[x+1][y+1]=1;
	a[x+2][y-2]=3,a[x+2][y-1]=2,a[x+2][y+0]=1;
	              a[x+3][y-1]=2;
}
void solve(int n,int m,int x,int y){
	if(n==0||m==0)
		return ;
	if(n==3&&m==3){
		a[x+0][y+0]=3,a[x+0][y+1]=3,a[x+0][y+2]=0;
		a[x+1][y+0]=2,a[x+1][y+1]=4,a[x+1][y+2]=0;
		a[x+2][y+0]=2,a[x+2][y+1]=1,a[x+2][y+2]=1;
		return ;
	}
	if(n==5&&m==5){
		a[x+0][y+0]=3,a[x+0][y+1]=3,a[x+0][y+2]=3,a[x+0][y+3]=3,a[x+0][y+4]=0;
		a[x+1][y+0]=2,a[x+1][y+1]=4,a[x+1][y+2]=2,a[x+1][y+3]=4,a[x+1][y+4]=0;
		a[x+2][y+0]=2,a[x+2][y+1]=1,a[x+2][y+2]=4,a[x+2][y+3]=3,a[x+2][y+4]=0;
		a[x+3][y+0]=2,a[x+3][y+1]=4,a[x+3][y+2]=0,a[x+3][y+3]=4,a[x+3][y+4]=0;
		a[x+4][y+0]=2,a[x+4][y+1]=1,a[x+4][y+2]=1,a[x+4][y+3]=1,a[x+4][y+4]=1;
		return ;
	}
	for(int i=0;i<m-1;i+=1) a[x][y+i]=3;
	for(int i=0;i<n-1;i+=1) a[x+i][y+m-1]=0;
	for(int i=1;i<m-0;i+=1) a[x+n-1][y+i]=1;
	for(int i=1;i<n-0;i+=1) a[x+i][y]=2;
	for(int i=2;i<m-2;i+=2) a[x+1][y+i]=2;
	for(int i=2;i<n-2;i+=2) a[x+i][y+m-2]=3;
	for(int i=2;i<m-2;i+=2) a[x+n-2][y+i]=0;
	for(int i=2;i<n-2;i+=2) a[x+i][y+1]=1;
	if(n==9){
		for(int i=3;i<m-4;i+=6) a[x+2][y+i+0]=3,a[x+2][y+i+1]=2,a[x+3][y+i+1]=2,a[x+2][y+i+2]=1;
		for(int i=3;i<m-4;i+=6) a[x+6][y+i+0]=3,a[x+6][y+i+1]=0,a[x+5][y+i+1]=0,a[x+6][y+i+2]=1;
		a[x+3][y+2]=0,a[x+4][y+2]=1,a[x+4][y+3]=1,a[x+5][y+2]=2;
		a[x+3][y+m-3]=0,a[x+4][y+m-3]=3,a[x+4][y+m-4]=3,a[x+5][y+m-3]=2;
		for(int i=7;i<m-7;i+=6)
			worka(x+2,y+i);
		return ;
	}
	if(n==11){
		for(int i=3;i<m-6;i+=6) a[x+2][y+i+0]=3,a[x+2][y+i+1]=2,a[x+3][y+i+1]=2,a[x+2][y+i+2]=1;
		for(int i=5;i<m-4;i+=6) a[x+8][y+i+0]=3,a[x+8][y+i+1]=0,a[x+7][y+i+1]=0,a[x+8][y+i+2]=1;
		a[x+3][y+2]=0,a[x+4][y+2]=1,a[x+4][y+3]=1,a[x+5][y+2]=2;
		a[x+5][y+m-3]=0,a[x+6][y+m-3]=3,a[x+6][y+m-4]=3,a[x+7][y+m-3]=2;
		for(int i=7;i<m-9;i+=6)
			worka(x+2,y+i);
		workb(x+2,y+m-4);
		for(int i=4;i<m-6;i+=6)
			workb(x+5,y+i);
		return ;
	}
	for(int i=3;i<m-3;i+=2) a[x+2][y+i]=0;
	for(int i=3;i<n-3;i+=2) a[x+i][y+m-3]=1;
	for(int i=3;i<m-3;i+=2) a[x+n-3][y+i]=2;
	for(int i=3;i<n-3;i+=2) a[x+i][y+2]=3;
	solve(n-6,m-6,x+3,y+3);
}
int main()
	int n,m;
	scanf("%d%d",&n,&m);
	if(n==2&&m==2){
		puts("Yes");
		puts("<^");
		puts("v>");
		return 0;
	}
	bool ok=0;
	if(n>m){
		swap(n,m);
		ok=1;
	}
	if((n&1)==0||(m&1)==0||n%6!=m%6||n%6==1||(n==3&&m>6)||(n==5&&m>6)){
		puts("No");
		return 0;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=4;
	solve(n,m,1,1);
	puts("Yes");
	if(ok==0){
		c[0]='^',c[1]='>',c[2]='v',c[3]='<',c[4]='.';
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)
				putchar(c[a[i][j]]);
			putchar('\n');
		}
	}
	else{
		c[0]='<',c[1]='v',c[2]='>',c[3]='^',c[4]='.';
		for(int i=1;i<=m;i++){
			for(int j=1;j<=n;j++)
				putchar(c[a[j][i]]);
			putchar('\n');
		}
	}
	return 0;
}

详细

answer.code:72:9: error: expected initializer before ‘int’
   72 |         int n,m;
      |         ^~~
answer.code:73:14: error: expected constructor, destructor, or type conversion before ‘(’ token
   73 |         scanf("%d%d",&n,&m);
      |              ^
answer.code:74:9: error: expected unqualified-id before ‘if’
   74 |         if(n==2&&m==2){
      |         ^~
answer.code:81:9: error: expected unqualified-id before ‘if’
   81 |         if(n>m){
      |         ^~
answer.code:85:9: error: expected unqualified-id before ‘if’
   85 |         if((n&1)==0||(m&1)==0||n%6!=m%6||n%6==1||(n==3&&m>6)||(n==5&&m>6)){
      |         ^~
answer.code:89:9: error: expected unqualified-id before ‘for’
   89 |         for(int i=1;i<=n;i++)
      |         ^~~
answer.code:89:21: error: ‘i’ does not name a type
   89 |         for(int i=1;i<=n;i++)
      |                     ^
answer.code:89:26: error: ‘i’ does not name a type
   89 |         for(int i=1;i<=n;i++)
      |                          ^
answer.code:90:29: error: ‘j’ does not name a type
   90 |                 for(int j=1;j<=m;j++)
      |                             ^
answer.code:90:34: error: ‘j’ does not name a type
   90 |                 for(int j=1;j<=m;j++)
      |                                  ^
answer.code:92:14: error: expected constructor, destructor, or type conversion before ‘(’ token
   92 |         solve(n,m,1,1);
      |              ^
answer.code:93:13: error: expected constructor, destructor, or type conversion before ‘(’ token
   93 |         puts("Yes");
      |             ^
answer.code:94:9: error: expected unqualified-id before ‘if’
   94 |         if(ok==0){
      |         ^~
answer.code:102:9: error: expected unqualified-id before ‘else’
  102 |         else{
      |         ^~~~
answer.code:110:9: error: expected unqualified-id before ‘return’
  110 |         return 0;
      |         ^~~~~~
answer.code:111:1: error: expected declaration before ‘}’ token
  111 | }
      | ^