結果

問題 No.923 オセロきりきざむたん
ユーザー LayCurseLayCurse
提出日時 2019-11-08 21:42:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 2,514 bytes
コンパイル時間 2,525 ms
コンパイル使用メモリ 208,476 KB
実行使用メモリ 7,788 KB
最終ジャッジ日時 2023-10-13 05:30:08
合計ジャッジ時間 5,437 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,496 KB
testcase_01 AC 4 ms
7,488 KB
testcase_02 AC 4 ms
7,488 KB
testcase_03 AC 4 ms
7,504 KB
testcase_04 AC 3 ms
7,480 KB
testcase_05 AC 4 ms
7,492 KB
testcase_06 AC 4 ms
7,444 KB
testcase_07 AC 4 ms
7,444 KB
testcase_08 AC 4 ms
7,480 KB
testcase_09 AC 4 ms
7,440 KB
testcase_10 AC 4 ms
7,432 KB
testcase_11 AC 4 ms
7,444 KB
testcase_12 AC 4 ms
7,568 KB
testcase_13 AC 4 ms
7,484 KB
testcase_14 AC 4 ms
7,504 KB
testcase_15 AC 4 ms
7,500 KB
testcase_16 AC 4 ms
7,476 KB
testcase_17 AC 4 ms
7,616 KB
testcase_18 AC 4 ms
7,496 KB
testcase_19 AC 4 ms
7,560 KB
testcase_20 AC 4 ms
7,500 KB
testcase_21 AC 4 ms
7,444 KB
testcase_22 AC 4 ms
7,448 KB
testcase_23 AC 4 ms
7,448 KB
testcase_24 AC 4 ms
7,436 KB
testcase_25 AC 4 ms
7,440 KB
testcase_26 AC 5 ms
7,764 KB
testcase_27 AC 4 ms
7,648 KB
testcase_28 AC 5 ms
7,768 KB
testcase_29 AC 5 ms
7,592 KB
testcase_30 AC 4 ms
7,484 KB
testcase_31 AC 4 ms
7,564 KB
testcase_32 AC 4 ms
7,440 KB
testcase_33 AC 4 ms
7,440 KB
testcase_34 AC 5 ms
7,500 KB
testcase_35 AC 4 ms
7,496 KB
testcase_36 AC 4 ms
7,440 KB
testcase_37 AC 4 ms
7,620 KB
testcase_38 AC 4 ms
7,496 KB
testcase_39 AC 4 ms
7,508 KB
testcase_40 AC 4 ms
7,508 KB
testcase_41 AC 4 ms
7,440 KB
testcase_42 AC 4 ms
7,528 KB
testcase_43 AC 4 ms
7,556 KB
testcase_44 AC 4 ms
7,508 KB
testcase_45 AC 4 ms
7,496 KB
testcase_46 AC 4 ms
7,452 KB
testcase_47 AC 4 ms
7,460 KB
testcase_48 AC 4 ms
7,560 KB
testcase_49 AC 4 ms
7,492 KB
testcase_50 AC 5 ms
7,672 KB
testcase_51 AC 5 ms
7,504 KB
testcase_52 AC 5 ms
7,484 KB
testcase_53 AC 6 ms
7,492 KB
testcase_54 AC 5 ms
7,496 KB
testcase_55 AC 5 ms
7,432 KB
testcase_56 AC 5 ms
7,436 KB
testcase_57 AC 4 ms
7,508 KB
testcase_58 AC 4 ms
7,444 KB
testcase_59 AC 4 ms
7,520 KB
testcase_60 AC 4 ms
7,508 KB
testcase_61 AC 4 ms
7,432 KB
testcase_62 AC 4 ms
7,612 KB
testcase_63 AC 4 ms
7,640 KB
testcase_64 AC 4 ms
7,492 KB
testcase_65 AC 6 ms
7,492 KB
testcase_66 AC 6 ms
7,436 KB
testcase_67 AC 7 ms
7,500 KB
testcase_68 AC 6 ms
7,524 KB
testcase_69 AC 4 ms
7,576 KB
testcase_70 AC 5 ms
7,528 KB
testcase_71 AC 6 ms
7,668 KB
testcase_72 AC 4 ms
7,580 KB
testcase_73 AC 4 ms
7,448 KB
testcase_74 AC 4 ms
7,528 KB
testcase_75 AC 5 ms
7,788 KB
testcase_76 AC 5 ms
7,544 KB
testcase_77 AC 5 ms
7,660 KB
testcase_78 AC 4 ms
7,452 KB
testcase_79 AC 5 ms
7,520 KB
testcase_80 AC 5 ms
7,520 KB
testcase_81 AC 5 ms
7,520 KB
testcase_82 AC 5 ms
7,664 KB
testcase_83 AC 4 ms
7,552 KB
testcase_84 AC 5 ms
7,608 KB
testcase_85 AC 5 ms
7,576 KB
testcase_86 AC 5 ms
7,696 KB
testcase_87 AC 4 ms
7,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int H;
int W;
string A[100000];
int main(){
  int i;
  wmem = memarr;
  int cnt[2] = {};
  int fg[2] = {};
  rd(H);
  rd(W);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(H);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(H);i++){
    int j;
    for(j=(0);j<(W);j++){
      cnt[A[i][j]-='0']++;
    }
  }
  if(H==1 || W==1){
    if(cnt[0]==0 || cnt[1]==0){
      wt_L("NO");
      wt_L('\n');
    }
    else{
      wt_L("YES");
      wt_L('\n');
    }
    return 0;
  }
  for(i=(0);i<(H);i++){
    int j;
    cnt[0] = cnt[1] = 0;
    for(j=(0);j<(W);j++){
      cnt[A[i][j]]++;
    }
    if(cnt[0]==0 || cnt[1]==0){
      fg[0]++;
    }
  }
  for(i=(0);i<(W);i++){
    int j;
    cnt[0] = cnt[1] = 0;
    for(j=(0);j<(H);j++){
      cnt[A[j][i]]++;
    }
    if(cnt[0]==0 || cnt[1]==0){
      fg[1]++;
    }
  }
  if(fg[0]&&fg[1]){
    wt_L("NO");
    wt_L('\n');
  }
  else{
    wt_L("YES");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191108-1

// --- original code ---
// int H, W;
// string A[1d5];
// {
//   int cnt[2] = {}, fg[2] = {};
//   rd(H,W,A(H));
//   rep(i,H) rep(j,W) cnt[A[i][j]-='0']++;
//   if(H==1 || W==1) wt( if[cnt[0]==0 || cnt[1]==0, "NO", "YES"] ), return 0;
//   rep(i,H){
//     cnt[0] = cnt[1] = 0;
//     rep(j,W) cnt[A[i][j]]++;
//     if(cnt[0]==0 || cnt[1]==0) fg[0]++;
//   }
//   rep(i,W){
//     cnt[0] = cnt[1] = 0;
//     rep(j,H) cnt[A[j][i]]++;
//     if(cnt[0]==0 || cnt[1]==0) fg[1]++;
//   }
//   wt(if[fg[0]&&fg[1], "NO", "YES"]);
// }
0