提交记录 11311


用户 题目 状态 得分 用时 内存 语言 代码长度
YeahPotato noip17f. 【NOIP2017】列队 Wrong Answer 65 110.089 ms 66600 KB C++ 2.28 KB
提交时间 评测时间
2019-11-14 13:02:54 2020-08-01 02:42:10
#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] = (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);
			if (n >= 2)
				a. push_back(b[r-n+2]), b[++r] = ans;
			else
				a. push_back(ans);
		}
	}
}
namespace task3 {
	int cnt, r, lim, ans, tree[600005]; ll a[600005], b[600005];
	inline void update(int s, int t) {
		for (; s<=lim; s+=s&-s)
			tree[s] += t;
	}
	inline int search(int x) {
		int res = 0, sum = 0;
		for (int i=19; ~i; i--)
			if (res + (1 << i) <= lim && sum + tree[res + (1 << i)] < x)
				res += 1 << i, sum += tree[res];
		return res + 1;
	}
	inline void solve() {
		cnt = m, lim = m + q;
		for (int i=1; i<=m; i++)
			a[i] = i, update(i, 1);
		for (int i=2; i<=n; i++)
			b[i] = 1ll * i * m;
		r = n;
		while (q--) {
			x = read(), y = read(), ans = search(y);
			write1(a[ans]), putchar('\n');
			update(ans, -1);
			if (n >= 2)
				a[++cnt] = b[r-n+2], update(cnt, 1), b[++r] = a[ans];
			else
				a[++cnt] = a[ans], update(cnt, 1);
		}
	}
}
int main() {
//	freopen ("phalanx.in", "r", stdin);
//	freopen ("phalanx.out", "w", stdout);
	cin >> n >> m >> q;
	if (q <= 500) task1 :: solve();
	else task3 :: 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

2 3 2
1 2
1 3
*/

CompilationN/AN/ACompile OKScore: N/A

Testcase #1474.63 us1 MB + 444 KBAcceptedScore: 5

Testcase #2412.74 us1 MB + 316 KBAcceptedScore: 5

Testcase #3444.49 us1 MB + 124 KBAcceptedScore: 5

Testcase #4457.52 us1 MB + 552 KBAcceptedScore: 5

Testcase #5374.23 us1 MB + 380 KBAcceptedScore: 5

Testcase #6435.05 us1 MB + 560 KBAcceptedScore: 5

Testcase #715.687 ms50 MB + 684 KBWrong AnswerScore: 0

Testcase #815.585 ms53 MB + 956 KBAcceptedScore: 5

Testcase #921.403 ms60 MB + 132 KBWrong AnswerScore: 0

Testcase #1017.84 ms65 MB + 40 KBWrong AnswerScore: 0

Testcase #1127.544 ms2 MB + 772 KBAcceptedScore: 5

Testcase #1227.385 ms2 MB + 756 KBAcceptedScore: 5

Testcase #13105.36 ms8 MB + 356 KBAcceptedScore: 5

Testcase #1499.614 ms8 MB + 108 KBAcceptedScore: 5

Testcase #15105.022 ms12 MB + 860 KBAcceptedScore: 5

Testcase #16109.469 ms13 MB + 104 KBAcceptedScore: 5

Testcase #1729.807 ms4 MB + 536 KBWrong AnswerScore: 0

Testcase #1828.756 ms4 MB + 436 KBWrong AnswerScore: 0

Testcase #19109.047 ms13 MB + 300 KBWrong AnswerScore: 0

Testcase #20110.089 ms13 MB + 676 KBWrong AnswerScore: 0


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