TopCoder - SRM 423 DIV 2: 250
500のコンパイルまでいけた。しかし250で撃沈…。バグを発見されてしまいました。今回の250のソースをソースコードビューアで公開(後悔…)。うーん何が間違ってたんだろう。今回は難しかったし、間違いがわからん(笑)
public class TheSimpleGame { public int count(int n, int[] x, int[] y) { int counter = 0; if (n<1||n>100){ return counter; } int i = 0; int j = 0; for (i=0;i<x.length&&i<50;i++) { if (n==x[i]) return i; for (j=0;j<y.length&&j<50;j++) { if (n==y[j]) return i + 1; } } return i + 1; } }
問題の内容は?
返信削除>> Ianさん
返信削除ありがとうございます^^
問題
You have a n x n board and several checkers placed on it. The i-th checker is in the cell at row x[i], column y[i]. All coordinates are 1-based. There can be more than one checker in the same cell. A move consists of taking one checker and moving it one cell up, down, left or right.
You want to put each checker in one of the four corners of the board. Return the minimum number of moves necessary to achieve the goal.
定義
Class:
TheSimpleGame
Method:
count
Parameters:
int, int[], int[]
Returns:
int
Method signature:
int count(int n, int[] x, int[] y)
(be sure your method is public)
です。。。