Submission #8809367


Source Code Expand

#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define BITF(n, i) (((n) >> i) & 1)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= x; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define REPZ(i, x) for (int i = 0; i <= x; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
using namespace std;
#define PRINTARR(x, y)                                     \
  cerr << #x << "=\n";                                     \
  for (auto itr = x; itr != y; itr++) cerr << *itr << " "; \
  cerr << endl;
#define PRINTARR2(x, i0, i1)                                       \
  cerr << #x << "=\n";                                             \
  for (int ii0 = 0; ii0 < i0; ii0++) {                             \
    for (int ii1 = 0; ii1 < i1; ii1++) cerr << x[ii0][ii1] << " "; \
    cerr << endl;                                                  \
  }
#define DUMPOUT cerr
// vector
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U> ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  REP(i, (int)vec.size())
  os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
  os << "}";
  return os;
}
// map
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  FORA(itr, map_var) {
    os << *itr;
    itr++;
    if (itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  FORA(itr, set_var) {
    os << *itr;
    itr++;
    if (itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if (sizeof...(Tail) > 0) DUMPOUT << ", ";
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define DUMP(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define DUMP(...)
#endif
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF0 = 1061109567, INF = INF0 * INF0;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN 100100
//----//
int x[MAXN];
int w[MAXN];
int pos[MAXN];
int f[MAXN];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N, L, T;
  cin >> N >> L >> T;
  vec<int> x1, x2;
  REP(i, N) {
    cin >> x[i] >> w[i];
    if (w[i] == 2) w[i] = -1;
    //    if (w[i] != w[0]) x1[i].pb(i);
  }
  int cnt = 0;
  REPS(i, N - 1) {
    if (w[0] != w[i]) {
      int init = (L + x[i] - x[0]) % L;
      int val = (T * 2) / L;
      int res = (T * 2) % L;
      //     DUMP(init, val + init <= res);
      cnt += val + (1 && init <= res);
    }
  }
  int ans = w[0] * cnt;
  ans %= N;
  ans += N;
  ans %= N;
  assert(0 <= ans && ans <= N - 1);
  // case 1だと1番目のアリは0番目のアリの場所にたどり着く.
  REP(i, N) pos[i] = (x[i] + T * w[i]) % L, pos[i] += L, pos[i] %= L;
  // DUMP(ans, x[0] + 3, w[0], pos[0]);
  REP(i, N) { print(pos[(i - ans + N) % N]); }  //  iota(f, f + N, 0);
  // PRINTARR(pos, pos + N);
  // PRINTARR(f, f + N);
}

Submission Info

Submission Time
Task C - Ants on a Circle
User cygnus
Language C++14 (GCC 5.4.1)
Score 0
Code Size 4587 Byte
Status WA
Exec Time 30 ms
Memory 3584 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 8
WA × 12
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
subtask_1_01.txt WA 18 ms 2304 KB
subtask_1_02.txt WA 15 ms 1792 KB
subtask_1_03.txt WA 29 ms 3584 KB
subtask_1_04.txt WA 30 ms 3584 KB
subtask_1_05.txt WA 5 ms 768 KB
subtask_1_06.txt WA 7 ms 1024 KB
subtask_1_07.txt WA 27 ms 3200 KB
subtask_1_08.txt WA 27 ms 3200 KB
subtask_1_09.txt WA 18 ms 2176 KB
subtask_1_10.txt WA 16 ms 1920 KB
subtask_1_11.txt AC 5 ms 768 KB
subtask_1_12.txt AC 25 ms 3200 KB
subtask_1_13.txt WA 20 ms 2432 KB
subtask_1_14.txt WA 18 ms 2304 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 1 ms 256 KB