提交记录 11308
| 提交时间 |
评测时间 |
| 2019-11-14 11:56:09 |
2020-08-01 02:41:49 |
#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[505], 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[x][i] = (x - 1) * m + i;
} int _ = f[x];
ans = a[_][y];
for (int i=y; i<m-1; i++)
a[x][i] = a[x][i+1];
a[x][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 | 38.98 us | 64 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #2 | 44.55 us | 60 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #3 | 47.01 us | 72 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #4 | 35.19 us | 48 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #5 | 37.05 us | 64 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #6 | 38.06 us | 64 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #7 | 70.1 us | 400 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #8 | 68.82 us | 400 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #9 | 72.86 us | 432 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #10 | 69.51 us | 392 KB | Runtime Error | Score: 0 | 显示更多 |
| Testcase #11 | 837.43 ms | 2 MB + 920 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #12 | 831.638 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.277 ms | 4 MB + 40 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #18 | 653.136 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: 2026-03-28 00:08:20 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠