提出 #65431202
ソースコード 拡げる
#include <bits/stdc++.h>
#define _F(x,y,z) for(int x=y;x<=z;x++)
#define F_(x,z,y) for(int x=z;x>=y;x--)
#define TF(x,y,z) for(int x=head[y],z;x;x=nex[x])
#define GF(x,y,z) for(int x:z[y])
using namespace std;
typedef long long ll;
typedef double dou;
typedef const int ci;
typedef pair<int,int> pii;
ci maxn=2e3+10;
int n,ans=0x3f3f3f3f;
char s[maxn][maxn],t[maxn][maxn],x[maxn][maxn];
void rotate()
{
_F(i,1,n)
{
_F(j,1,n)
{
x[j][n-i+1]=s[i][j];
}
}
_F(i,1,n)
{
_F(j,1,n)
{
s[i][j]=x[i][j];
}
}
}
int check()
{
int cnt=0;
_F(i,1,n)
{
_F(j,1,n)
{
cnt+=(s[i][j]!=t[i][j]);
}
}
return cnt;
}
int main()
{
scanf("%d",&n);
_F(i,1,n)
{
scanf("%s",s[i]+1);
}
_F(i,1,n)
scanf("%s",t[i]+1);
ans=min(ans,check());
rotate();
ans=min(ans,check()+1);
rotate();
ans=min(ans,check()+2);
rotate();
ans=min(ans,check()+3);
printf("%d",ans);
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
B - Grid Rotation |
| ユーザ |
adolphshi |
| 言語 |
C++ 20 (gcc 12.2) |
| 得点 |
250 |
| コード長 |
961 Byte |
| 結果 |
AC |
| 実行時間 |
1 ms |
| メモリ |
4448 KiB |
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:49:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
Main.cpp:52:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
52 | scanf("%s",s[i]+1);
| ~~~~~^~~~~~~~~~~~~
Main.cpp:55:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
55 | scanf("%s",t[i]+1);
| ~~~~~^~~~~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
250 / 250 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt |
| All |
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| random_01.txt |
AC |
1 ms |
4024 KiB |
| random_02.txt |
AC |
1 ms |
3860 KiB |
| random_03.txt |
AC |
1 ms |
3700 KiB |
| random_04.txt |
AC |
1 ms |
4240 KiB |
| random_05.txt |
AC |
1 ms |
3856 KiB |
| random_06.txt |
AC |
1 ms |
3936 KiB |
| random_07.txt |
AC |
1 ms |
3932 KiB |
| random_08.txt |
AC |
1 ms |
4048 KiB |
| random_09.txt |
AC |
1 ms |
4300 KiB |
| random_10.txt |
AC |
1 ms |
4292 KiB |
| random_11.txt |
AC |
1 ms |
4436 KiB |
| random_12.txt |
AC |
1 ms |
4168 KiB |
| random_13.txt |
AC |
1 ms |
4372 KiB |
| random_14.txt |
AC |
1 ms |
4256 KiB |
| random_15.txt |
AC |
1 ms |
4448 KiB |
| random_16.txt |
AC |
1 ms |
4244 KiB |
| random_17.txt |
AC |
1 ms |
3936 KiB |
| random_18.txt |
AC |
1 ms |
3732 KiB |
| random_19.txt |
AC |
1 ms |
3688 KiB |
| sample_01.txt |
AC |
1 ms |
3872 KiB |
| sample_02.txt |
AC |
1 ms |
3804 KiB |