結果
問題 |
No.5002 stick xor
|
ユーザー |
![]() |
提出日時 | 2018-05-31 00:42:29 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,844 bytes |
コンパイル時間 | 7,380 ms |
実行使用メモリ | 24,644 KB |
スコア | 0 |
最終ジャッジ日時 | 2018-05-31 00:42:39 |
ジャッジサーバーID (参考情報) |
judge8 / |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 32 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args){ /*Preprocessing*/ Scanner sc = new Scanner(System.in); int N =sc.nextInt(); int K =sc.nextInt(); int[] len =new int[K]; int [][] grid =new int[N][N]; int initScore=0; for(int i=0; i<K;i++){ len[i] =sc.nextInt(); } for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ grid[i][j] =sc.nextInt(); if(grid[i][j]==0){ initScore++; } } } int a,b,c,d=0; for(int i=0;i<K;i++){ //横で探索 int maxBlack_W=0; int maxY_W=0; int maxX_W=0; //全列 for (int j=0;j+len[i]<N;j++){ //各列 for(int start =j;start<j+len[i];start++){ int cnt=0; for(int l=start;l<start+len[i];l++){ if (grid[j][l] ==1){ cnt++; } } if(cnt>maxBlack_W){ maxBlack_W =cnt; maxY_W =j; maxX_W =start; } } } //縦 //横で探索 //全列 int maxBlack_H=0; int maxY_H=0; int maxX_H=0; for (int j=0;j+len[i]<N;j++){ //各列 for(int start =j;start<j+len[i];start++){ int cnt=0; for(int l=start;l<start+len[i];l++){ if (grid[l][j] ==1){ cnt++; } } if(cnt>maxBlack_H){ maxBlack_H =cnt; maxY_H =start; maxX_H =j; } } } //評価 if(maxBlack_H>maxBlack_W){ a=maxY_H+1; b=maxX_H+1; c=maxY_H+len[i]; d=maxX_H+1; for(int j=maxY_H;j<maxY_H+len[i];j++){ grid[maxY_H][j]=convert(grid[maxY_H][j]); } }else{ a=maxY_W+1; b=maxX_W+1; c=maxY_W+1; d=maxX_W+len[i]; for(int j=maxX_W;j<maxX_W+len[i];j++){ grid[j][maxX_W]=convert(grid[j][maxX_W]); } } System.out.println(a+" "+b+" "+c+ " "+ d); } } public static int convert(int input){ if(input ==1){ return 0; }else{ return 1; } } }