公式
B - Train Reservation 解説
by
B - Train Reservation 解説
by
KumaTachiRen
印刷ページ
それぞれの列車に対して席 \(X\) が空いているか確認すればよいです。
席 \(X\) が文字列の何文字目に対応するかを計算する際は、 \(X\) の文字コードから A の文字コードを引くと簡潔に書くことができます。
N, X = input().split()
N = int(N)
X = ord(X) - ord('A')
S = [input() for _ in range(N)]
ans = False
for s in S:
ans |= s[X] == "o"
if ans:
print("Yes")
else:
print("No")
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
char X;
cin >> N >> X;
vector<string> S(N);
for (int i = 0; i < N; i++) cin >> S[i];
bool ans = false;
for (int i = 0; i < N; i++) ans |= S[i][X - 'A'] == 'o';
if (ans) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
投稿日時:
最終更新:
