Submission #8842687
Source Code Expand
#include <bits/stdc++.h> #define int long long #define inf 0x3f3f3f3f3f3f3f3f #define debug(...) fprintf(stderr, __VA_ARGS__) #define inv(x) Power(x, mod - 2) #define fi first #define se second #define N 200005 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; } signed 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 | 2265 Byte |
Status | CE |
Compile Error
./Main.cpp:37:9: error: ‘<anonymous struct>::operator long long int()’ cannot be overloaded inline operator long long () { return input<long long>(); } ^ ./Main.cpp:36:9: error: with ‘<anonymous struct>::operator long long int()’ inline operator int () { return input<int>(); } ^ ./Main.cpp: In function ‘int main()’: ./Main.cpp:72:48: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] for (i = 1; i <= n; ++i) printf("%d\n", ans[i]); ^