提交记录 11309


用户 题目 状态 得分 用时 内存 语言 代码长度
YeahPotato noip17f. 【NOIP2017】列队 Wrong Answer 50 2 s 66600 KB C++ 1.50 KB
提交时间 评测时间
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
*/

CompilationN/AN/ACompile OKScore: N/A

Testcase #1477.88 us1 MB + 472 KBAcceptedScore: 5

Testcase #2411.1 us1 MB + 328 KBAcceptedScore: 5

Testcase #3438.62 us1 MB + 120 KBAcceptedScore: 5

Testcase #4469.5 us1 MB + 584 KBAcceptedScore: 5

Testcase #5365.43 us1 MB + 400 KBAcceptedScore: 5

Testcase #6441.22 us1 MB + 604 KBAcceptedScore: 5

Testcase #716.121 ms50 MB + 720 KBAcceptedScore: 5

Testcase #816.131 ms53 MB + 920 KBAcceptedScore: 5

Testcase #921.657 ms60 MB + 128 KBAcceptedScore: 5

Testcase #1018.104 ms65 MB + 40 KBAcceptedScore: 5

Testcase #11837.622 ms2 MB + 920 KBWrong AnswerScore: 0

Testcase #12831.421 ms2 MB + 912 KBWrong AnswerScore: 0

Testcase #132 s7 MB + 152 KBTime Limit ExceededScore: 0

Testcase #142 s7 MB + 172 KBTime Limit ExceededScore: 0

Testcase #152 s9 MB + 348 KBTime Limit ExceededScore: 0

Testcase #162 s9 MB + 328 KBTime Limit ExceededScore: 0

Testcase #17678.351 ms4 MB + 40 KBWrong AnswerScore: 0

Testcase #18653.137 ms3 MB + 1004 KBWrong AnswerScore: 0

Testcase #192 s9 MB + 904 KBTime Limit ExceededScore: 0

Testcase #202 s10 MB + 28 KBTime Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2024-04-27 04:21:19 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用