結果

問題 No.5002 stick xor
ユーザー tailstails
提出日時 2018-05-26 00:47:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 1,036 bytes
コンパイル時間 1,854 ms
実行使用メモリ 1,336 KB
スコア 275
最終ジャッジ日時 2018-05-26 00:47:21
ジャッジサーバーID
(参考情報)
judge10 /
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
1,332 KB
testcase_01 AC 7 ms
1,332 KB
testcase_02 AC 6 ms
1,336 KB
testcase_03 AC 7 ms
1,336 KB
testcase_04 AC 7 ms
1,332 KB
testcase_05 AC 6 ms
1,336 KB
testcase_06 AC 6 ms
1,332 KB
testcase_07 AC 6 ms
1,336 KB
testcase_08 AC 8 ms
1,336 KB
testcase_09 AC 6 ms
1,336 KB
testcase_10 AC 6 ms
1,332 KB
testcase_11 AC 6 ms
1,332 KB
testcase_12 AC 6 ms
1,332 KB
testcase_13 AC 6 ms
1,332 KB
testcase_14 AC 7 ms
1,336 KB
testcase_15 AC 6 ms
1,336 KB
testcase_16 AC 6 ms
1,332 KB
testcase_17 AC 6 ms
1,332 KB
testcase_18 AC 6 ms
1,332 KB
testcase_19 AC 7 ms
1,332 KB
testcase_20 AC 7 ms
1,332 KB
testcase_21 AC 7 ms
1,336 KB
testcase_22 AC 7 ms
1,336 KB
testcase_23 AC 6 ms
1,336 KB
testcase_24 AC 6 ms
1,336 KB
testcase_25 AC 6 ms
1,336 KB
testcase_26 AC 7 ms
1,336 KB
testcase_27 AC 7 ms
1,332 KB
testcase_28 AC 8 ms
1,332 KB
testcase_29 AC 6 ms
1,332 KB
testcase_30 AC 6 ms
1,332 KB
testcase_31 AC 6 ms
1,332 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:5: warning: ‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
     gets(a[y]);
     ^
main.cpp:20:14: warning: ‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
     gets(a[y]);
              ^
/tmp/ccJdBmQp.o: In function `main':
main.cpp:(.text.startup+0x14e): warning: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int n,k;
int la[500],li[500];
int ry[500],rx[500];
char a[64][64];
int dbg_sc;

main(){
  scanf("%d%d",&n,&k);
  for(int i=0;i<k;++i){
    scanf("%d ",&la[i]);
    li[i]=i;
  }
  sort(li,li+k,[](int a,int b){return la[b]<la[a];});
  for(int y=0;y<n;++y){
    gets(a[y]);
    for(int x=0;x<n;++x){
      a[y][x]&=1;
    }
  }
  for(int i=0;i<k;++i){
    int l=la[li[i]];
    int by,bx;
    int bs=-30;
    for(int y=0;y<n;++y){
      int s=0;
      for(int x=0;x<l;++x){
        s+=a[y][x]*2-1; 
        a[y][x]^=1;
      }
      for(int x=l;x<=n;++x){
        if(bs<s){
          bs=s; by=y; bx=x;
        }
        s+=a[y][x]*2-1; 
        a[y][x]^=1;
        s+=a[y][x-l]*2-1;
        a[y][x-l]^=1;
      }
    }
    //dbg_sc+=bs;
    ry[li[i]]=by;
    rx[li[i]]=bx;
    for(int x=bx-l;x<bx;++x){
      a[by][x]^=1;
    }
  }
  //printf("score=%d\n",dbg_sc);
  for(int i=0;i<k;++i){
    printf("%d %d %d %d\n",rx[i]-la[i]+1,ry[i]+1,rx[i],ry[i]+1);
  }
}
0