AtCoder Beginner Contest 013

Submission #6903664

Source codeソースコード

#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

vector<int> get_binary_number(int n){
  vector<int> b;
  while(n != 0){
    b.emplace_back(n%2);
    n /=2;
  }
  return b;
}


int main() {
//  int n = 256;
//  while(n != 0){
//    cout << n%2 << endl;
//    n /=2;
//  }


  // 入力
  long long N, M, D;
  cin >> N >> M >> D;
  vector<int> a(M);
  for (int i = 0; i < M; ++i) {
    cin >> a[i];
    a[i]--;
  }

  //
  int c, lim = 33;
  int results[lim][N];
  for (int i = 0; i < N; ++i) {
    c = i;
//    printf("%d, (%d, %d)\n", c, left, right);

    for (int j = 0; j < M; ++j) {
      if(a[j] == c){
//        printf("%d, (%d -> %d)\n", a[j], c, a[j]+1);
        c = a[j]+1;

      }else if(a[j]+1 == c){
//        printf("%d, (%d -> %d)\n", a[j], c, a[j]);
        c = a[j];
      }
    }

//    cout << c+1 << endl;
    results[0][i] = c;
//    break;
  }

  // ダブリング
  for (int i = 1; i < lim; ++i) {
    for (int j = 0; j < N; ++j) {
      int k = results[i-1][j];
      results[i][j] = results[i-1][k];
//      cout << results[i][j] << endl;
    }
  }

  //
  vector<int> ans(N);
  for (int i = 0; i < N; ++i) {
    ans[i] = i;
  }

  vector<int> b = get_binary_number(D);
  for (int i = 0; i < b.size(); ++i) {
    if(b[i] == 0) continue;
//    printf("i: %d\n", i);
    for (int j = 0; j < N; ++j) {
      ans[j] = results[i][ans[j]];
    }
  }

  for (int a: ans) {
    cout << a+1 << endl;
  }

  return 0;
}


Submission

Task問題 D - 阿弥陀
User nameユーザ名 moono08
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 40
Source lengthソースコード長 1597 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Subtask1 0 / 10 sample_1.txt,01_i.txt,01_random01.txt,01_random02.txt,01_random03.txt,01_random04.txt,01_random05.txt,01_random06.txt,01_random07.txt
Subtask2 20 / 20 sample_1.txt,sample_2.txt,sample_3.txt,02_i.txt,02_p.txt,02_random01.txt,02_random02.txt,02_random03.txt,02_random04.txt,02_random05.txt,02_random06.txt,02_random07.txt,02_random08.txt,02_rp01.txt,02_rp02.txt,02_rp03.txt,02_rp04.txt,02_rp05.txt
Subtask3 20 / 20 sample_1.txt,sample_2.txt,03_i.txt,03_random01.txt,03_random02.txt,03_random03.txt,03_random04.txt,03_random05.txt,03_random06.txt,03_random07.txt,03_random08.txt,03_random09.txt,03_random10.txt,03_random11.txt,03_random12.txt,03_random13.txt,03_random14.txt,03_random15.txt
Subtask4 0 / 50 sample_1.txt,sample_2.txt,sample_3.txt,04_i.txt,04_p1.txt,04_p2.txt,04_random01.txt,04_random02.txt,04_random03.txt,04_random04.txt,04_random05.txt,04_random06.txt,04_random07.txt,04_random08.txt,04_random09.txt,04_random10.txt,04_random11.txt,04_random12.txt,04_random13.txt,04_rp01.txt,04_rp02.txt,04_rp03.txt,04_rp04.txt,04_rp05.txt,04_rp06.txt,04_rp07.txt,04_rp08.txt,04_rp09.txt,04_rp10.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01_i.txt TLE
01_random01.txt AC 1 ms 256 KB
01_random02.txt AC 1 ms 256 KB
01_random03.txt AC 1 ms 256 KB
01_random04.txt AC 38 ms 640 KB
01_random05.txt AC 3083 ms 14208 KB
01_random06.txt TLE
01_random07.txt TLE
02_i.txt AC 5 ms 384 KB
02_p.txt AC 4 ms 384 KB
02_random01.txt AC 1 ms 256 KB
02_random02.txt AC 1 ms 256 KB
02_random03.txt AC 6 ms 384 KB
02_random04.txt AC 3 ms 384 KB
02_random05.txt AC 27 ms 512 KB
02_random06.txt AC 122 ms 768 KB
02_random07.txt AC 241 ms 1152 KB
02_random08.txt AC 241 ms 1152 KB
02_rp01.txt AC 4 ms 384 KB
02_rp02.txt AC 4 ms 384 KB
02_rp03.txt AC 4 ms 384 KB
02_rp04.txt AC 4 ms 384 KB
02_rp05.txt AC 4 ms 384 KB
03_i.txt AC 1 ms 256 KB
03_random01.txt AC 4 ms 256 KB
03_random02.txt AC 32 ms 1024 KB
03_random03.txt AC 26 ms 896 KB
03_random04.txt AC 27 ms 896 KB
03_random05.txt AC 6 ms 384 KB
03_random06.txt AC 6 ms 384 KB
03_random07.txt AC 9 ms 384 KB
03_random08.txt AC 2 ms 256 KB
03_random09.txt AC 11 ms 512 KB
03_random10.txt AC 19 ms 640 KB
03_random11.txt AC 32 ms 1024 KB
03_random12.txt AC 33 ms 1024 KB
03_random13.txt AC 26 ms 768 KB
03_random14.txt AC 21 ms 768 KB
03_random15.txt AC 9 ms 384 KB
04_i.txt TLE
04_p1.txt TLE
04_p2.txt TLE
04_random01.txt TLE
04_random02.txt AC 2054 ms 6528 KB
04_random03.txt AC 1095 ms 2048 KB
04_random04.txt AC 1607 ms 2176 KB
04_random05.txt AC 2087 ms 2688 KB
04_random06.txt TLE
04_random07.txt TLE
04_random08.txt TLE
04_random09.txt AC 3363 ms 3328 KB
04_random10.txt AC 3529 ms 8832 KB
04_random11.txt TLE
04_random12.txt TLE
04_random13.txt TLE
04_rp01.txt TLE
04_rp02.txt TLE
04_rp03.txt TLE
04_rp04.txt TLE
04_rp05.txt TLE
04_rp06.txt TLE
04_rp07.txt TLE
04_rp08.txt TLE
04_rp09.txt TLE
04_rp10.txt TLE
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB