結果
| 問題 | 
                            No.923 オセロきりきざむたん
                             | 
                    
| コンテスト | |
| ユーザー | 
                             noisy_noimin
                         | 
                    
| 提出日時 | 2019-11-13 16:29:50 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 14 ms / 2,000 ms | 
| コード長 | 1,679 bytes | 
| コンパイル時間 | 1,151 ms | 
| コンパイル使用メモリ | 101,660 KB | 
| 実行使用メモリ | 10,496 KB | 
| 最終ジャッジ日時 | 2024-09-21 21:09:26 | 
| 合計ジャッジ時間 | 2,776 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 84 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>
using namespace std;
using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> has_in_row(h, vector<bool>(2, false)), has_in_column(w, vector<bool>(2, false));
    string s;
    bool has[2] = {false, false};
    for(int i=0;i<h;++i){
        cin >> s;
        for(int j=0;j<w;++j) {
            has_in_row[i][s[j]-'0'] = true;
            has_in_column[j][s[j]-'0'] = true;
            has[s[j]-'0'] = true;
        }
    }
    if(!has[0] || !has[1]) {
        cout << "NO" << endl;
        return 0;
    }
    bool is_ok_row = true, is_ok_column = true;
    if(w != 1) {
        for(int i=0;i<h;++i){
            if(!has_in_row[i][0] || !has_in_row[i][1]) {
                is_ok_row = false;
                break;
            }
        }
    }
    if(h != 1) {
        for(int i=0;i<w;++i){
            if(!has_in_column[i][0] || !has_in_column[i][1]) {
                is_ok_column = false;
                break;
            }
        }
    }
    if(is_ok_column || is_ok_row) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}
            
            
            
        
            
noisy_noimin