提出 #46115260
ソースコード 拡げる
#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
#define Z(x) (x)*(x)
#define pb push_back
//#define M
//#define mo
//#define N
int n, m, i, j, k, T;
char s[10];
struct poly {
int a[5][5];
void mem() { memset(a, 0, sizeof(a)); }
int cnt1() {
int k=0;
for(int i=0; i<4; ++i)
for(int j=0; j<4; ++j) k+=a[i][j];
return k;
}
void Read() {
for(int i=0; i<4; ++i) {
scanf("%s", s);
for(int j=0; j<4; ++j)
a[i][j]=(s[j]=='.' ? 0 : 1);
}
}
void rota() {
poly B;
for(int i=0; i<4; ++i)
for(int j=0; j<4; ++j)
B.a[j][3-i]=a[i][j];
(*this)=B;
}
poly tran(int x, int y) {
poly B; B.mem();
for(int i=x, i1=0; i1<=3; ++i1, ++i)
for(int j=y, j1=0; j1<=3; ++j1, ++j)
if(i>=0 && i<=3 && j>=0 && j<=3)
B.a[i1][j1]=a[i][j];
return B;
}
poly operator +(const poly &A) const {
poly B;
for(int i=0; i<=3; ++i)
for(int j=0; j<=3; ++j) B.a[i][j]=(a[i][j]|A.a[i][j]);
return B;
}
bool check_tran(int x, int y) {
poly B=(*this).tran(x, y);
if(B.cnt1()==(*this).cnt1()) return true;
return false;
}
bool check_add(poly A, poly B) {
poly C=A+B;
if(A.cnt1()+B.cnt1()==C.cnt1()) return true;
return false;
}
bool check() {
if(cnt1()==16) return true;
return false;
}
void print() {
for(int i=0; i<=3; ++i, printf("\n"))
for(int j=0; j<=3; ++j)
// if(a[i][j]) printf("#(%d)", a[i][j]); else printf(".");
if(a[i][j]) printf("#"); else printf(".");
printf("so 1 are : %d\n", cnt1());
}
}A[3], B[3], ans;
void dfs(int k) {
// printf("%d\n", k);
if(k>2) {
// B[0].print(); B[1].print(); B[2].print(); printf("\n");
if(ans.check_add(B[0], B[1])) {
ans=B[0]+B[1];
if(ans.check_add(ans, B[2])) {
ans=ans+B[2];
// ans.print();
if(ans.check()) printf("Yes"), exit(0);
}
}
return ;
}
for(int i=1; i<=4; ++i) {
for(int x=-4; x<=4; ++x)
for(int y=-4; y<=4; ++y)
if(A[k].check_tran(x, y)) {
B[k]=A[k].tran(x, y);
// printf("tran %d : \n", k);
// B[k].print();
dfs(k+1);
}
A[k].rota();
}
}
signed main()
{
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// srand(time(NULL));
// T=read();
// while(T--) {
//
// }
A[0].Read(); A[1].Read(); A[2].Read();
// A[0].print(); A[1].print(); A[2].print(); printf("\n");
dfs(0);
printf("No\n");
return 0;
}
提出情報
提出日時
2023-09-30 22:23:51+0900
問題
D - Polyomino
ユーザ
zhangtingxi
言語
C++ 20 (gcc 12.2)
得点
400
コード長
2683 Byte
結果
AC
実行時間
29 ms
メモリ
3848 KiB
コンパイルエラー
Main.cpp: In member function ‘void poly::Read()’:
Main.cpp:27:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ジャッジ結果
セット名
Sample
All
得点 / 配点
0 / 0
400 / 400
結果
セット名
テストケース
Sample
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt
All
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt
ケース名
結果
実行時間
メモリ
00_sample_00.txt
AC
2 ms
3776 KiB
00_sample_01.txt
AC
2 ms
3784 KiB
00_sample_02.txt
AC
2 ms
3644 KiB
00_sample_03.txt
AC
29 ms
3600 KiB
00_sample_04.txt
AC
1 ms
3832 KiB
00_sample_05.txt
AC
1 ms
3624 KiB
01_random_00.txt
AC
2 ms
3832 KiB
01_random_01.txt
AC
1 ms
3796 KiB
01_random_02.txt
AC
3 ms
3636 KiB
01_random_03.txt
AC
1 ms
3596 KiB
01_random_04.txt
AC
1 ms
3660 KiB
01_random_05.txt
AC
1 ms
3576 KiB
01_random_06.txt
AC
2 ms
3536 KiB
01_random_07.txt
AC
1 ms
3716 KiB
01_random_08.txt
AC
3 ms
3532 KiB
01_random_09.txt
AC
2 ms
3788 KiB
01_random_10.txt
AC
3 ms
3540 KiB
01_random_11.txt
AC
1 ms
3788 KiB
01_random_12.txt
AC
3 ms
3732 KiB
01_random_13.txt
AC
1 ms
3788 KiB
01_random_14.txt
AC
3 ms
3792 KiB
01_random_15.txt
AC
1 ms
3576 KiB
01_random_16.txt
AC
6 ms
3656 KiB
01_random_17.txt
AC
1 ms
3720 KiB
01_random_18.txt
AC
1 ms
3644 KiB
01_random_19.txt
AC
1 ms
3648 KiB
01_random_20.txt
AC
1 ms
3576 KiB
01_random_21.txt
AC
2 ms
3848 KiB
01_random_22.txt
AC
1 ms
3716 KiB
01_random_23.txt
AC
1 ms
3656 KiB
01_random_24.txt
AC
3 ms
3636 KiB
01_random_25.txt
AC
1 ms
3616 KiB
01_random_26.txt
AC
1 ms
3800 KiB
01_random_27.txt
AC
1 ms
3596 KiB
01_random_28.txt
AC
1 ms
3600 KiB
01_random_29.txt
AC
1 ms
3716 KiB
01_random_30.txt
AC
2 ms
3736 KiB
01_random_31.txt
AC
1 ms
3716 KiB
01_random_32.txt
AC
2 ms
3656 KiB
02_corner_00.txt
AC
1 ms
3776 KiB
02_corner_01.txt
AC
1 ms
3648 KiB
02_corner_02.txt
AC
1 ms
3788 KiB