Chokudai Contest 001

Submission #9889112

Source codeソースコード

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <random>
#include <chrono>

using namespace std;
const int N = 30;
int A[30][30];
int ans_size = 0;
int h_moves[4] = {-1, 1, 0, 0};
int w_moves[4] = {0, 0, -1, 1};
vector <pair<int, int> > ans;
chrono::system_clock::time_point start;
chrono::system_clock::time_point cur_time;
void input(){
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cin >> A[i][j];
    }
  }
}

void solve(){
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      while(A[i][j] != 0){
        ans.push_back(make_pair(i + 1, j + 1));
        ans_size ++;
        A[i][j] --;
        int cur_i = i;
        int cur_j = j;
        while(true){
          bool changed = false;
          cout << cur_i << " " << cur_j << endl;
          for(int k = 0; k < 4; k++){
            int next_i = i + h_moves[k];
            int next_j = j + w_moves[k];
            if(0 <= next_i && next_i < N && 0 <= next_j && next_j < N){
              if(A[cur_i][cur_j] == A[next_i][next_j] && A[next_i][next_j] != 0){
                ans.push_back(make_pair(next_i, next_j));
                A[next_i][next_j] --;
                changed = true;
                cur_i = next_i;
                cur_j = next_j;
                break;
              }
            }
          }
          if(!changed){
            break;
          }
        }

      }
    }
  }
}

void output(){
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}

int main(void){
  start = chrono::system_clock::now();
  input();
  solve();
  output();
  return 0;
}

Submission

Task問題 A - 高橋君の山崩しゲーム
User nameユーザ名 katom
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1920 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
test_01 0 / 100000 subtask_01_01.txt
test_02 0 / 100000 subtask_01_02.txt
test_03 0 / 100000 subtask_01_03.txt
test_04 0 / 100000 subtask_01_04.txt
test_05 0 / 100000 subtask_01_05.txt
test_06 0 / 100000 subtask_01_06.txt
test_07 0 / 100000 subtask_01_07.txt
test_08 0 / 100000 subtask_01_08.txt
test_09 0 / 100000 subtask_01_09.txt
test_10 0 / 100000 subtask_01_10.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask_01_01.txt WA
subtask_01_02.txt WA
subtask_01_03.txt WA
subtask_01_04.txt WA
subtask_01_05.txt WA
subtask_01_06.txt WA
subtask_01_07.txt WA
subtask_01_08.txt WA
subtask_01_09.txt WA
subtask_01_10.txt WA