提交记录 11309
提交时间 |
评测时间 |
2019-11-14 12:06:20 |
2020-08-01 02:42:01 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, q, x, y;
inline int read() {
int s = 0;
char ch = getchar();
while (ch < '0' || ch > '9')
ch = getchar();
while (ch >= '0' && ch <= '9')
s = s * 10 + ch - '0', ch = getchar();
return s;
}
void write1(ll x) {
if (x > 9) write1(x / 10);
putchar(x % 10 + '0');
}
namespace task1 {
ll a[505][50005], b[50005], ans; int f[50005], cnt;
inline void solve() {
for (int i=1; i<=n; i++)
b[i] = 1ll * i * m;
while (q--) {
x = read(), y = read();
if (y ^ m) {
if (! f[x]) {
f[x] = ++ cnt;
for (int i=1; i<=m; i++)
a[cnt][i] = 1ll * (x - 1) * m + i;
} int _ = f[x];
ans = a[_][y];
for (int i=y; i<m-1; i++)
a[_][i] = a[_][i+1];
a[_][m-1] = b[x];
} else ans = b[x];
for (int i=x; i<n; i++)
b[i] = b[i+1];
b[n] = ans;
write1(ans), putchar('\n');
}
}
}
namespace task2 {
vector <ll> a; ll b[600005], ans; int r;
inline void solve() {
for (int i=1; i<=m; i++)
a. push_back(i);
for (int i=2; i<=n; i++)
b[i] = 1ll * i * m;
r = n;
while (q--) {
x = read(), y = read();
write1(ans = a[y-1]), putchar('\n');
a. erase(a. begin() + y - 1);
a. push_back(b[r-n+2]);
b[++r] = ans;
}
}
}
int main() {
// freopen ("phalanx.in", "r", stdin);
// freopen ("phalanx.out", "w", stdout);
cin >> n >> m >> q;
if (q <= 500) task1 :: solve();
else task2 :: solve();
// task2 :: solve();
return 0;
}
/*
2 2 3
1 1
2 2
1 2
3 5 10
1 1
1 4
1 5
1 3
1 2
1 5
1 2
1 4
1 1
1 3
*/
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 477.88 us | 1 MB + 472 KB | Accepted | Score: 5 | 显示更多 |
Testcase #2 | 411.1 us | 1 MB + 328 KB | Accepted | Score: 5 | 显示更多 |
Testcase #3 | 438.62 us | 1 MB + 120 KB | Accepted | Score: 5 | 显示更多 |
Testcase #4 | 469.5 us | 1 MB + 584 KB | Accepted | Score: 5 | 显示更多 |
Testcase #5 | 365.43 us | 1 MB + 400 KB | Accepted | Score: 5 | 显示更多 |
Testcase #6 | 441.22 us | 1 MB + 604 KB | Accepted | Score: 5 | 显示更多 |
Testcase #7 | 16.121 ms | 50 MB + 720 KB | Accepted | Score: 5 | 显示更多 |
Testcase #8 | 16.131 ms | 53 MB + 920 KB | Accepted | Score: 5 | 显示更多 |
Testcase #9 | 21.657 ms | 60 MB + 128 KB | Accepted | Score: 5 | 显示更多 |
Testcase #10 | 18.104 ms | 65 MB + 40 KB | Accepted | Score: 5 | 显示更多 |
Testcase #11 | 837.622 ms | 2 MB + 920 KB | Wrong Answer | Score: 0 | 显示更多 |
Testcase #12 | 831.421 ms | 2 MB + 912 KB | Wrong Answer | Score: 0 | 显示更多 |
Testcase #13 | 2 s | 7 MB + 152 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Testcase #14 | 2 s | 7 MB + 172 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Testcase #15 | 2 s | 9 MB + 348 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Testcase #16 | 2 s | 9 MB + 328 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Testcase #17 | 678.351 ms | 4 MB + 40 KB | Wrong Answer | Score: 0 | 显示更多 |
Testcase #18 | 653.137 ms | 3 MB + 1004 KB | Wrong Answer | Score: 0 | 显示更多 |
Testcase #19 | 2 s | 9 MB + 904 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Testcase #20 | 2 s | 10 MB + 28 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-04-27 04:21:19 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用