AtCoder Regular Contest 001

Submission #6858967

Source codeソースコード

#include<cstdio>
#include<cstring>
#include<cmath>

char mmap[10][10];
int x[10],i,flag;

void dfs(int pos);
void print();
bool pd(int a,int b);

int main()
{
	for(i=1;i<=8;i++)
	{
		for(int j=1;j<=8;j++)
		{
			scanf("%c",&mmap[i][j]);
			if(mmap[i][j]=='Q')
				x[i]=j;
		}
		getchar();
	}
	dfs(1);
	if(!flag)
		printf("No Answer\n");
	return 0;
}

void dfs(int pos)
{
	if(pos==9)
	{
		print();
		flag=1;
		return;
	}
	if(x[pos])dfs(pos+1);
	else
	{
		for(int j=1;j<9;j++)
			if(!flag&&pd(j,pos))
			{
				x[pos]=j;
				dfs(pos+1);
				x[pos]=0;
			}
	}
}

bool pd(int a,int b)
{
	for(int j=1;j<9;j++)
		if(j!=b&&x[j]&&(x[j]==a||fabs(a-x[j])==fabs(b-j)))
			return 0;
	return 1;
}

void print()
{
	for(i=1;i<9;i++)
	{
		for(int j=1;j<9;j++)
			if(x[i]==j)
				printf("Q");
			else
				printf(".");
		printf("\n");
	}
}

Submission

Task問題 C - パズルのお手伝い
User nameユーザ名 luogu_bot5
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 889 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:18:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%c",&mmap[i][j]);
^

Test case

Set

Set name Score得点 / Max score Cases
All 0 / 100 00_sample1.txt,00_sample2.txt,01_rnd_00.txt,01_rnd_01.txt,01_rnd_02.txt,01_rnd_03.txt,01_rnd_04.txt,01_rnd_05.txt,01_rnd_06.txt,01_rnd_07.txt,01_rnd_08.txt,01_rnd_09.txt,01_rnd_10.txt,01_rnd_11.txt,01_rnd_12.txt,01_rnd_13.txt,01_rnd_14.txt,01_rnd_15.txt,01_rnd_16.txt,01_rnd_17.txt,01_rnd_18.txt,01_rnd_19.txt,01_rnd_20.txt,01_rnd_21.txt,01_rnd_22.txt,01_rnd_23.txt,01_rnd_24.txt,01_rnd_25.txt,01_rnd_26.txt,01_rnd_27.txt,01_rnd_28.txt,01_rnd_29.txt,01_rnd_30.txt,01_rnd_31.txt,01_rnd_32.txt,01_rnd_33.txt,01_rnd_34.txt,01_rnd_35.txt,01_rnd_36.txt,01_rnd_37.txt,01_rnd_38.txt,01_rnd_39.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample1.txt AC 1 ms 128 KB
00_sample2.txt AC 1 ms 128 KB
01_rnd_00.txt AC 1 ms 128 KB
01_rnd_01.txt AC 1 ms 128 KB
01_rnd_02.txt WA
01_rnd_03.txt AC 1 ms 128 KB
01_rnd_04.txt WA
01_rnd_05.txt AC 1 ms 128 KB
01_rnd_06.txt WA
01_rnd_07.txt WA
01_rnd_08.txt WA
01_rnd_09.txt WA
01_rnd_10.txt AC 1 ms 128 KB
01_rnd_11.txt WA
01_rnd_12.txt AC 1 ms 128 KB
01_rnd_13.txt AC 1 ms 128 KB
01_rnd_14.txt WA
01_rnd_15.txt AC 1 ms 128 KB
01_rnd_16.txt AC 1 ms 128 KB
01_rnd_17.txt WA
01_rnd_18.txt AC 1 ms 128 KB
01_rnd_19.txt AC 1 ms 128 KB
01_rnd_20.txt WA
01_rnd_21.txt WA
01_rnd_22.txt WA
01_rnd_23.txt AC 1 ms 128 KB
01_rnd_24.txt WA
01_rnd_25.txt AC 1 ms 128 KB
01_rnd_26.txt WA
01_rnd_27.txt AC 1 ms 128 KB
01_rnd_28.txt AC 1 ms 128 KB
01_rnd_29.txt AC 1 ms 128 KB
01_rnd_30.txt AC 1 ms 128 KB
01_rnd_31.txt WA
01_rnd_32.txt AC 1 ms 128 KB
01_rnd_33.txt WA
01_rnd_34.txt WA
01_rnd_35.txt WA
01_rnd_36.txt AC 1 ms 128 KB
01_rnd_37.txt WA
01_rnd_38.txt AC 1 ms 128 KB
01_rnd_39.txt AC 1 ms 128 KB