Language: Java

import java.io.*;

class Main{
int[] sx={0,0,1,0,-1};
int[] sy={0,1,0,-1,0};
int[] mx={0,0,1,0,-1,-1,-1,1,1};
int[] my={0,1,0,-1,0,-1,1,-1,1};
int[] lx={0,0,1,0,-1,-1,-1,1,1,0,2,0,-2};
int[] ly={0,1,0,-1,0,-1,1,-1,1,2,0,-2,0};
int total;
int res;
int[][] map=new int[10][10];
int[][] drop=new int[10][10];
static void sd(int x,int y){
for(int i=0;i<sx.length;i++){
map[x+sx[i]][y+sy[i]]--;
}
total-=5;
res--;
}
static void sr(int x,int y){
for(int i=0;i<sx.length;i++){
map[x+sx[i]][y+sy[i]]++;
}
total+=5;
res++;
}
static boolean scd(int x,int y){
for(int i=0;i<sx.length;i++){
int nx=x+sx[i];
int ny=y+sy[i];
if(nx<0||ny<0||nx>=10||ny>=10||map[nx][ny]<=0){
return false;
}
}
return true;
}
static void md(int x,int y){
for(int i=0;i<mx.length;i++){
map[x+mx[i]][y+my[i]]--;
}
total-=9;
res--;
}
static void mr(int x,int y){
for(int i=0;i<mx.length;i++){
map[x+mx[i]][y+my[i]]++;
}
total+=9;
res++;
}
static boolean mcd(int x,int y){
for(int i=0;i<mx.length;i++){
int nx=x+mx[i];
int ny=y+my[i];
if(nx<0||ny<0||nx>=10||ny>=10||map[nx][ny]<=0){
return false;
}
}
return true;
}
static void ld(int x,int y){
for(int i=0;i<lx.length;i++){
map[x+lx[i]][y+ly[i]]--;
}
total-=13;
res--;
}
static void lr(int x,int y){
for(int i=0;i<lx.length;i++){
map[x+lx[i]][y+ly[i]]++;
}
total+=13;
res++;
}
static boolean lcd(int x,int y){
for(int i=0;i<lx.length;i++){
int nx=x+lx[i];
int ny=y+ly[i];
if(nx<0||ny<0||nx>=10||ny>=10||map[nx][ny]<=0){
return false;
}
}
return true;
}
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
res=Integer.parseInt(br.readLine());
total=0;
for(int i=0;i<10;i++){
String[] value=br.readLine().split(" ");
for(int j=0;j<10;j++){
int num=Integer.parseInt(value[j]);
map[i][j]=num;
total+=num;
}
}
if(search(1,1,3)){
for(int i=1;i<9;i++){
for(int j=1;j<9;j++){
if(drop[i][j]!=0){
System.out.println(i+" "+j+" "+drop[i][j]);
}
}
}
}
}
static boolean searchnext(int x,int y){
if(y==8){
return search(x+1,1,3);
}
return search(x,y+1,3);
}
static boolean search(int x,int y,int size){
if(res==0&&total==0){
return true;
}
else if(total<5){
return false;
}
if(x==9){
return false;
}
if(x>2&&y==1){
for(int i=0;i<10;i++){
if(map[x-3][i]!=0){
return false;
}
}
}
switch(size){
case 3:if(lcd(x,y)){
       ld(x,y);
       if(searchnext(x,y)){
       drop[x][y]=size;
       return true;
       break;
       }
       else{
       lr(x,y);
       }
       }
       size--;
       continue;
case 2:if(mcd(x,y)){
       md(x,y);
       if(searchnext(x,y)){
       drop[x][y]=size;
       return true;
       break;
       }
       else{
       mr(x,y);
       }
       }
       size--;
       continue;
case 1:if(scd(x,y)){
       sd(x,y);
       if(searchnext(x,y)){
       drop[x][y]=size;
       return true;
       break;
       }
       else{
       sr(x,y);
       }
       }
       size--;
       continue;
case 0:drop[x][y]=size;
       return searchnext(x,y);
       break;
}
}
}

Compiler output:
Main.java:15: error: non-static variable sx cannot be referenced from a static context
for(int i=0;i<sx.length;i++){
              ^
Main.java:16: error: non-static variable map cannot be referenced from a static context
map[x+sx[i]][y+sy[i]]--;
^
Main.java:16: error: non-static variable sx cannot be referenced from a static context
map[x+sx[i]][y+sy[i]]--;
      ^
Main.java:16: error: non-static variable sy cannot be referenced from a static context
map[x+sx[i]][y+sy[i]]--;
               ^
Main.java:18: error: non-static variable total cannot be referenced from a static context
total-=5;
^
Main.java:19: error: non-static variable res cannot be referenced from a static context
res--;
^
Main.java:22: error: non-static variable sx cannot be referenced from a static context
for(int i=0;i<sx.length;i++){
              ^
Main.java:23: error: non-static variable map cannot be referenced from a static context
map[x+sx[i]][y+sy[i]]++;
^
Main.java:23: error: non-static variable sx cannot be referenced from a static context
map[x+sx[i]][y+sy[i]]++;
      ^
Main.java:23: error: non-static variable sy cannot be referenced from a static context
map[x+sx[i]][y+sy[i]]++;
               ^
Main.java:25: error: non-static variable total cannot be referenced from a static context
total+=5;
^
Main.java:26: error: non-static variable res cannot be referenced from a static context
res++;
^
Main.java:29: error: non-static variable sx cannot be referenced from a static context
for(int i=0;i<sx.length;i++){
              ^
Main.java:30: error: non-static variable sx cannot be referenced from a static context
int nx=x+sx[i];
         ^
Main.java:31: error: non-static variable sy cannot be referenced from a static context
int ny=y+sy[i];
         ^
Main.java:32: error: non-static variable map cannot be referenced from a static context
if(nx<0||ny<0||nx>=10||ny>=10||map[nx][ny]<=0){
                               ^
Main.java:39: error: non-static variable mx cannot be referenced from a static context
for(int i=0;i<mx.length;i++){
              ^
Main.java:40: error: non-static variable map cannot be referenced from a static context
map[x+mx[i]][y+my[i]]--;
^
Main.java:40: error: non-static variable mx cannot be referenced from a static context
map[x+mx[i]][y+my[i]]--;
      ^
Main.java:40: error: non-static variable my cannot be referenced from a static context
map[x+mx[i]][y+my[i]]--;
               ^
Main.java:42: error: non-static variable total cannot be referenced from a static context
total-=9;
^
Main.java:43: error: non-static variable res cannot be referenced from a static context
res--;
^
Main.java:46: error: non-static variable mx cannot be referenced from a static context
for(int i=0;i<mx.length;i++){
              ^
Main.java:47: error: non-static variable map cannot be referenced from a static context
map[x+mx[i]][y+my[i]]++;
^
Main.java:47: error: non-static variable mx cannot be referenced from a static context
map[x+mx[i]][y+my[i]]++;
      ^
Main.java:47: error: non-static variable my cannot be referenced from a static context
map[x+mx[i]][y+my[i]]++;
               ^
Main.java:49: error: non-static variable total cannot be referenced from a static context
total+=9;
^
Main.java:50: error: non-static variable res cannot be referenced from a static context
res++;
^
Main.java:53: error: non-static variable mx cannot be referenced from a static context
for(int i=0;i<mx.length;i++){
              ^
Main.java:54: error: non-static variable mx cannot be referenced from a static context
int nx=x+mx[i];
         ^
Main.java:55: error: non-static variable my cannot be referenced from a static context
int ny=y+my[i];
         ^
Main.java:56: error: non-static variable map cannot be referenced from a static context
if(nx<0||ny<0||nx>=10||ny>=10||map[nx][ny]<=0){
                               ^
Main.java:63: error: non-static variable lx cannot be referenced from a static context
for(int i=0;i<lx.length;i++){
              ^
Main.java:64: error: non-static variable map cannot be referenced from a static context
map[x+lx[i]][y+ly[i]]--;
^
Main.java:64: error: non-static variable lx cannot be referenced from a static context
map[x+lx[i]][y+ly[i]]--;
      ^
Main.java:64: error: non-static variable ly cannot be referenced from a static context
map[x+lx[i]][y+ly[i]]--;
               ^
Main.java:66: error: non-static variable total cannot be referenced from a static context
total-=13;
^
Main.java:67: error: non-static variable res cannot be referenced from a static context
res--;
^
Main.java:70: error: non-static variable lx cannot be referenced from a static context
for(int i=0;i<lx.length;i++){
              ^
Main.java:71: error: non-static variable map cannot be referenced from a static context
map[x+lx[i]][y+ly[i]]++;
^
Main.java:71: error: non-static variable lx cannot be referenced from a static context
map[x+lx[i]][y+ly[i]]++;
      ^
Main.java:71: error: non-static variable ly cannot be referenced from a static context
map[x+lx[i]][y+ly[i]]++;
               ^
Main.java:73: error: non-static variable total cannot be referenced from a static context
total+=13;
^
Main.java:74: error: non-static variable res cannot be referenced from a static context
res++;
^
Main.java:77: error: non-static variable lx cannot be referenced from a static context
for(int i=0;i<lx.length;i++){
              ^
Main.java:78: error: non-static variable lx cannot be referenced from a static context
int nx=x+lx[i];
         ^
Main.java:79: error: non-static variable ly cannot be referenced from a static context
int ny=y+ly[i];
         ^
Main.java:80: error: non-static variable map cannot be referenced from a static context
if(nx<0||ny<0||nx>=10||ny>=10||map[nx][ny]<=0){
                               ^
Main.java:88: error: non-static variable res cannot be referenced from a static context
res=Integer.parseInt(br.readLine());
^
Main.java:89: error: non-static variable total cannot be referenced from a static context
total=0;
^
Main.java:94: error: non-static variable map cannot be referenced from a static context
map[i][j]=num;
^
Main.java:95: error: non-static variable total cannot be referenced from a static context
total+=num;
^
Main.java:101: error: non-static variable drop cannot be referenced from a static context
if(drop[i][j]!=0){
   ^
Main.java:102: error: non-static variable drop cannot be referenced from a static context
System.out.println(i+" "+j+" "+drop[i][j]);
                               ^
Main.java:115: error: non-static variable res cannot be referenced from a static context
if(res==0&&total==0){
   ^
Main.java:115: error: non-static variable total cannot be referenced from a static context
if(res==0&&total==0){
           ^
Main.java:118: error: non-static variable total cannot be referenced from a static context
else if(total<5){
        ^
Main.java:126: error: non-static variable map cannot be referenced from a static context
if(map[x-3][i]!=0){
   ^
Main.java:135: error: non-static variable drop cannot be referenced from a static context
       drop[x][y]=size;
       ^
Main.java:144: error: continue outside of loop
       continue;
       ^
Main.java:148: error: non-static variable drop cannot be referenced from a static context
       drop[x][y]=size;
       ^
Main.java:157: error: continue outside of loop
       continue;
       ^
Main.java:161: error: non-static variable drop cannot be referenced from a static context
       drop[x][y]=size;
       ^
Main.java:170: error: continue outside of loop
       continue;
       ^
Main.java:171: error: non-static variable drop cannot be referenced from a static context
case 0:drop[x][y]=size;
       ^
65 errors