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;
  }
}

コメント

  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)

    です。。。

    返信削除

コメントを投稿

このブログの人気の投稿

Python から Win32 API 経由で印刷する

財務諸表 (Financial Statements)

Netflix のスケール - オートメーション編