Submission #8842645


Source Code Expand

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define N 100005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, L, T, t, cnt, now;
int x[N], pos[N], d[N], ans[N];

int Next(int x) { return x == n ? 1 : x + 1; }
int Pre(int x) { return x > 1 ? x - 1 : n; }

int main() {
	read(n, L, T);
	t = T / L, T %= L;
	for (int i = 1; i <= n; ++i) read(x[i], d[i]), d[i] = d[i] == 2 ? -1 : 1;
	for (int i = 1; i <= n; ++i) pos[i] = ((x[i] + T * d[i]) % L + L) % L;
	for (int i = 2; i <= n; ++i) cnt += d[i] == -d[1];

	now = 1ll * cnt * t % n + 1;
	for (int i = 2; i <= n; ++i)
		if (d[i] == -d[1]) {
			if (d[1] == 1) {
				if (x[i] - x[1] < T << 1) now = Next(now);
				if (x[i] - x[1] < T * 2 - L) now = Next(now);
			} else {
				if (L - x[i] + x[1] <= T << 1) now = Pre(now);
				if (L - x[i] + x[1] <= T * 2 - L) now = Pre(now);
			}
		}

	ans[now] = pos[1];
	sort(pos + 1, pos + n + 1);
	int i = now % n + 1, j = (lower_bound(pos + 1, pos + n + 1, ans[now]) - pos) % n + 1;
	for (; i ^ now; i = i % n + 1, j = j % n + 1) ans[i] = pos[j];
	for (i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	return 0;
}

Submission Info

Submission Time
Task C - Ants on a Circle
User tuliwei
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2240 Byte
Status WA
Exec Time 26 ms
Memory 2816 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 11
WA × 9
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 AC 16 ms 1792 KB
subtask_1_02.txt WA 12 ms 1408 KB
subtask_1_03.txt WA 25 ms 2816 KB
subtask_1_04.txt WA 26 ms 2688 KB
subtask_1_05.txt WA 4 ms 640 KB
subtask_1_06.txt WA 6 ms 768 KB
subtask_1_07.txt WA 22 ms 2432 KB
subtask_1_08.txt WA 23 ms 2432 KB
subtask_1_09.txt WA 15 ms 1664 KB
subtask_1_10.txt WA 13 ms 1408 KB
subtask_1_11.txt AC 4 ms 640 KB
subtask_1_12.txt AC 21 ms 2432 KB
subtask_1_13.txt AC 15 ms 1920 KB
subtask_1_14.txt AC 14 ms 1792 KB
subtask_1_15.txt AC 1 ms 256 KB
subtask_1_16.txt AC 1 ms 256 KB