1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【ABC409】A問題 - Conflict 考察から実装(c++)まで

Posted at

AtCoderBeginnerContest409の解説&感想です。
コンテストリンク

問題一覧

A問題 - Conflict

問題リンク

問題概要

長さ$N$で、oxのどちらかからなる文字列$S,T$が入力される。
どちらもoの箇所があればYes、なければNoを表示せよ。

制約

  • $1 \le N \le 100$

考察

$N$が小さいので言われた通りにやればよさそう。
計算量は配列を見ていくので$O(N)$。

実装

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    //入力
    ll N;
    string S,T;
    cin>>N>>S>>T;
    
    //配列を全部見て、どちらもoの場所を探す
    for(int i=0;i<N;i++){
        if(S[i] == T[i] && T[i] == 'o'){
            //どちらもoの場所を見つけた時点でYesを表示して終了
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
    //ここまで来ちゃったらNo
    cout<<"No"<<endl;
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?