AtCoder Regular Contest 047

Submission #1062069

Source codeソースコード

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vi ch(n);
  rep (i, n) {
    ch[i] = i+1;
  }
  vi ans(n, 0);
  int rr = 1;
  rep (i, n) {
    int q = (ll)rr * (n - i) / k;
    rr = (ll)rr * (n - i) % k;
    if (rr == 0) {
      q -= 1;
      rr = k;
    }
    ans[i] = ch.at(q);
    ch.erase(begin(ch) + q);
  }
  rep (i, n) {
    printf("%d\n", ans[i]);
  }

  return 0;
}

Submission

Task問題 C - N!÷K番目の単語
User nameユーザ名 cyglef
Created time投稿日時
Language言語 C++14 (Clang++ 3.4)
Status状態 AC
Score得点 100
Source lengthソースコード長 1302 Byte
File nameファイル名
Exec time実行時間 81 ms
Memory usageメモリ使用量 1568 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt
Subtask1 30 / 30 sample_01.txt,sample_02.txt,subtask1_01.txt,subtask1_02.txt,subtask1_03.txt,subtask1_04.txt,subtask1_05.txt,subtask1_06.txt,subtask1_07.txt,subtask1_08.txt,subtask1_09.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask1_20.txt,subtask1_21.txt
Subtask2 70 / 70 sample_01.txt,sample_02.txt,subtask1_01.txt,subtask1_02.txt,subtask1_03.txt,subtask1_04.txt,subtask1_05.txt,subtask1_06.txt,subtask1_07.txt,subtask1_08.txt,subtask1_09.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask1_20.txt,subtask1_21.txt,subtask2_01.txt,subtask2_02.txt,subtask2_03.txt,subtask2_04.txt,subtask2_05.txt,subtask2_06.txt,subtask2_07.txt,subtask2_08.txt,subtask2_09.txt,subtask2_10.txt,subtask2_11.txt,subtask2_12.txt,subtask2_13.txt,subtask2_14.txt,subtask2_15.txt,subtask2_16.txt,subtask2_17.txt,subtask2_18.txt,subtask2_19.txt,subtask3_01.txt,subtask3_02.txt,subtask3_03.txt,subtask3_04.txt,subtask3_05.txt,subtask3_06.txt,subtask3_07.txt,subtask3_08.txt,subtask3_09.txt,subtask3_10.txt,subtask3_11.txt,subtask3_12.txt,subtask3_13.txt,subtask3_14.txt,subtask3_15.txt,subtask3_16.txt,subtask3_17.txt,subtask3_18.txt,subtask3_19.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 17 ms 800 KB
sample_02.txt AC 16 ms 924 KB
subtask1_01.txt AC 18 ms 796 KB
subtask1_02.txt AC 17 ms 800 KB
subtask1_03.txt AC 18 ms 800 KB
subtask1_04.txt AC 19 ms 796 KB
subtask1_05.txt AC 18 ms 800 KB
subtask1_06.txt AC 18 ms 928 KB
subtask1_07.txt AC 18 ms 796 KB
subtask1_08.txt AC 17 ms 800 KB
subtask1_09.txt AC 18 ms 800 KB
subtask1_10.txt AC 18 ms 924 KB
subtask1_11.txt AC 16 ms 800 KB
subtask1_12.txt AC 19 ms 756 KB
subtask1_13.txt AC 18 ms 792 KB
subtask1_14.txt AC 17 ms 800 KB
subtask1_15.txt AC 18 ms 924 KB
subtask1_16.txt AC 16 ms 928 KB
subtask1_17.txt AC 17 ms 800 KB
subtask1_18.txt AC 18 ms 796 KB
subtask1_19.txt AC 18 ms 792 KB
subtask1_20.txt AC 18 ms 924 KB
subtask1_21.txt AC 18 ms 800 KB
subtask2_01.txt AC 53 ms 1568 KB
subtask2_02.txt AC 57 ms 1564 KB
subtask2_03.txt AC 39 ms 1180 KB
subtask2_04.txt AC 50 ms 1440 KB
subtask2_05.txt AC 20 ms 800 KB
subtask2_06.txt AC 37 ms 1180 KB
subtask2_07.txt AC 50 ms 1308 KB
subtask2_08.txt AC 47 ms 1308 KB
subtask2_09.txt AC 38 ms 1308 KB
subtask2_10.txt AC 63 ms 1312 KB
subtask2_11.txt AC 43 ms 1308 KB
subtask2_12.txt AC 42 ms 1308 KB
subtask2_13.txt AC 39 ms 1308 KB
subtask2_14.txt AC 21 ms 800 KB
subtask2_15.txt AC 30 ms 1052 KB
subtask2_16.txt AC 70 ms 1560 KB
subtask2_17.txt AC 51 ms 1568 KB
subtask2_18.txt AC 81 ms 1432 KB
subtask2_19.txt AC 42 ms 1184 KB
subtask3_01.txt AC 22 ms 928 KB
subtask3_02.txt AC 56 ms 1440 KB
subtask3_03.txt AC 20 ms 924 KB
subtask3_04.txt AC 30 ms 1180 KB
subtask3_05.txt AC 46 ms 1312 KB
subtask3_06.txt AC 58 ms 1484 KB
subtask3_07.txt AC 46 ms 1308 KB
subtask3_08.txt AC 20 ms 924 KB
subtask3_09.txt AC 19 ms 924 KB
subtask3_10.txt AC 19 ms 800 KB
subtask3_11.txt AC 23 ms 800 KB
subtask3_12.txt AC 19 ms 916 KB
subtask3_13.txt AC 46 ms 1440 KB
subtask3_14.txt AC 56 ms 1568 KB
subtask3_15.txt AC 38 ms 1184 KB
subtask3_16.txt AC 36 ms 1052 KB
subtask3_17.txt AC 35 ms 1176 KB
subtask3_18.txt AC 39 ms 1176 KB
subtask3_19.txt AC 30 ms 1184 KB