結果

問題 No.2692 How Many Times Reached?
コンテスト
ユーザー kotatsugame
提出日時 2024-03-22 21:24:29
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 243µs
コード長 793 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 306 ms
コンパイル使用メモリ 75,228 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-09-06 16:35:49
合計ジャッジ時間 2,251 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<cassert>
using namespace std;
int N;
string S[100];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N;
	for(int i=0;i<N;i++)cin>>S[i];
	int ans=0;
	for(int i=0;i<N;i++)
	{
		{
			int cnt=0;
			for(int j=0;j<N;j++)
			{
				if(S[i][j]=='A')cnt++;
				else if(S[i][j]=='B')cnt=-1e9;
			}
			if(cnt==N-1)ans++;
		}
		{
			int cnt=0;
			for(int j=0;j<N;j++)
			{
				if(S[j][i]=='A')cnt++;
				else if(S[j][i]=='B')cnt=-1e9;
			}
			if(cnt==N-1)ans++;
		}
	}
	{
		int cnt=0;
		for(int j=0;j<N;j++)
		{
			if(S[j][j]=='A')cnt++;
			else if(S[j][j]=='B')cnt=-1e9;
		}
		if(cnt==N-1)ans++;
	}
	{
		int cnt=0;
		for(int j=0;j<N;j++)
		{
			if(S[N-1-j][j]=='A')cnt++;
			else if(S[N-1-j][j]=='B')cnt=-1e9;
		}
		if(cnt==N-1)ans++;
	}
	cout<<ans<<endl;
}
0