結果

問題 No.5004 Room Assignment
ユーザー phocomphocom
提出日時 2021-12-01 01:44:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 2,912 bytes
コンパイル時間 1,353 ms
実行使用メモリ 22,356 KB
スコア 137,168,931
平均クエリ数 7642.54
最終ジャッジ日時 2021-12-01 01:44:50
合計ジャッジ時間 21,348 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
22,104 KB
testcase_01 AC 139 ms
21,936 KB
testcase_02 AC 140 ms
21,972 KB
testcase_03 AC 140 ms
21,972 KB
testcase_04 AC 140 ms
21,960 KB
testcase_05 AC 139 ms
21,792 KB
testcase_06 AC 139 ms
21,984 KB
testcase_07 AC 139 ms
21,612 KB
testcase_08 AC 139 ms
22,032 KB
testcase_09 AC 146 ms
22,116 KB
testcase_10 AC 139 ms
21,956 KB
testcase_11 AC 139 ms
21,948 KB
testcase_12 AC 138 ms
22,008 KB
testcase_13 AC 139 ms
21,960 KB
testcase_14 AC 140 ms
22,212 KB
testcase_15 AC 139 ms
21,792 KB
testcase_16 AC 139 ms
21,936 KB
testcase_17 AC 138 ms
21,900 KB
testcase_18 AC 137 ms
21,924 KB
testcase_19 AC 138 ms
21,900 KB
testcase_20 AC 140 ms
21,924 KB
testcase_21 AC 138 ms
22,212 KB
testcase_22 AC 139 ms
21,924 KB
testcase_23 AC 140 ms
21,908 KB
testcase_24 AC 140 ms
21,888 KB
testcase_25 AC 143 ms
21,912 KB
testcase_26 AC 142 ms
21,960 KB
testcase_27 AC 141 ms
22,128 KB
testcase_28 AC 139 ms
22,140 KB
testcase_29 AC 138 ms
21,912 KB
testcase_30 AC 141 ms
22,020 KB
testcase_31 AC 140 ms
21,972 KB
testcase_32 AC 139 ms
21,948 KB
testcase_33 AC 138 ms
21,780 KB
testcase_34 AC 141 ms
21,816 KB
testcase_35 AC 141 ms
21,924 KB
testcase_36 AC 141 ms
21,924 KB
testcase_37 AC 139 ms
21,984 KB
testcase_38 AC 140 ms
21,984 KB
testcase_39 AC 137 ms
21,936 KB
testcase_40 AC 137 ms
21,924 KB
testcase_41 AC 140 ms
21,792 KB
testcase_42 AC 139 ms
22,140 KB
testcase_43 AC 138 ms
22,140 KB
testcase_44 AC 137 ms
21,888 KB
testcase_45 AC 139 ms
21,960 KB
testcase_46 AC 140 ms
21,912 KB
testcase_47 AC 141 ms
21,912 KB
testcase_48 AC 139 ms
21,960 KB
testcase_49 AC 139 ms
21,900 KB
testcase_50 AC 141 ms
21,780 KB
testcase_51 AC 143 ms
21,912 KB
testcase_52 AC 139 ms
21,912 KB
testcase_53 AC 136 ms
22,032 KB
testcase_54 AC 139 ms
22,020 KB
testcase_55 AC 139 ms
21,924 KB
testcase_56 AC 140 ms
21,972 KB
testcase_57 AC 140 ms
21,912 KB
testcase_58 AC 137 ms
21,960 KB
testcase_59 AC 138 ms
22,092 KB
testcase_60 AC 139 ms
22,092 KB
testcase_61 AC 140 ms
21,924 KB
testcase_62 AC 139 ms
21,780 KB
testcase_63 AC 140 ms
22,128 KB
testcase_64 AC 139 ms
21,792 KB
testcase_65 AC 137 ms
21,924 KB
testcase_66 AC 139 ms
21,792 KB
testcase_67 AC 138 ms
21,948 KB
testcase_68 AC 138 ms
21,768 KB
testcase_69 AC 139 ms
21,896 KB
testcase_70 AC 137 ms
21,792 KB
testcase_71 AC 139 ms
21,936 KB
testcase_72 AC 139 ms
21,948 KB
testcase_73 AC 140 ms
21,960 KB
testcase_74 AC 139 ms
21,948 KB
testcase_75 AC 140 ms
22,356 KB
testcase_76 AC 139 ms
22,140 KB
testcase_77 AC 140 ms
21,984 KB
testcase_78 AC 139 ms
21,900 KB
testcase_79 AC 138 ms
21,912 KB
testcase_80 AC 138 ms
22,020 KB
testcase_81 AC 139 ms
21,996 KB
testcase_82 AC 138 ms
21,960 KB
testcase_83 AC 139 ms
21,936 KB
testcase_84 AC 140 ms
21,924 KB
testcase_85 AC 139 ms
21,924 KB
testcase_86 AC 138 ms
21,936 KB
testcase_87 AC 139 ms
21,780 KB
testcase_88 AC 141 ms
22,212 KB
testcase_89 AC 138 ms
21,936 KB
testcase_90 AC 139 ms
22,056 KB
testcase_91 AC 139 ms
21,996 KB
testcase_92 AC 140 ms
21,804 KB
testcase_93 AC 139 ms
22,020 KB
testcase_94 AC 138 ms
21,900 KB
testcase_95 AC 140 ms
22,008 KB
testcase_96 AC 140 ms
21,948 KB
testcase_97 AC 147 ms
22,212 KB
testcase_98 AC 139 ms
21,948 KB
testcase_99 AC 140 ms
22,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma GCC optimize("Ofast")
#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
using Pii = pair<int, int>;
constexpr int inf = 1 << 30;

struct Timer {
  static constexpr double ONE_CLOCK = 0.000000333;
  unsigned long long get_cycle() {
    unsigned int low, high;
    __asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
    return ((unsigned long long int)low) | ((unsigned long long int)high << 32);
  }
  unsigned long long start_time, last_time;
  Timer() { start_time = last_time = get_cycle(); }
  int get_time() { return get_cycle() * ONE_CLOCK - start_time * ONE_CLOCK; }
  int split_time() { return get_cycle() * ONE_CLOCK - last_time * ONE_CLOCK; }
  void split() { last_time = get_cycle(); }
} timer;

class RandInt {
 public:
  int x = 8753, y = 239017, z = 1000000123;
  int next(int d) {
    int t = x ^ (x << 11);
    x = y;
    y = z;
    z ^= (z >> 19) ^ t ^ (t >> 8);
    return z % d;
  }
} ri;

template <class T>
string to_string(T s);
template <class S, class T>
string to_string(pair<S, T> p);
string to_string(char c) { return string(1, c); }
string to_string(string s) { return s; }
string to_string(const char s[]) { return string(s); }

template <class T>
string to_string(T v) {
  if (v.empty()) return "{}";
  string ret = "{";
  for (auto x : v) ret += to_string(x) + ",";
  ret.back() = '}';
  return ret;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + ":" + to_string(p.second) + "}";
}
void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

constexpr int T = 3600, R = 4;
int id = 1;

int main(int argc, char **argv) {
  int _;
  cin >> _ >> _;
  vector<vector<Pii>> ls(30);
  REP(t, T) {
    int N;
    cin >> N;
    vector<Pii> S(N);
    vector<Pii> ans;
    REP(i, N) {
      cin >> S[i].first;
      S[i].second = id++;
      int g = (max(0, S[i].first - 1)) / 5;
      if (ls[g].size() != 0) {
        ans.emplace_back(ls[g].back().second, S[i].second);
      }
      ls[g].push_back(S[i]);
      if (ls[g].size() == 4) {
        ls[g].clear();
      }
    }
    cout << ans.size() << endl;
    for (auto p : ans) cout << p.first << " " << p.second << endl;
  }
  return 0;
}
0