提交记录 22415


用户 题目 状态 得分 用时 内存 语言 代码长度
McIron233 noip17f. 【NOIP2017】列队 Accepted 100 417.665 ms 278724 KB C++14 1.09 KB
提交时间 评测时间
2024-08-26 16:12:41 2024-08-26 16:12:50
#include<stdio.h>
#include<vector>
#define N 1000005
#define int long long
using namespace std;
int n,m,q,X;
vector<int>v[N<<3];
int rt[N<<3];
struct segment_tree{
	#define mid ((l+r)>>1)
	int sum[N<<3],ls[N<<3],rs[N<<3],tot=0;
	void modify(int &k,int l,int r,int pos){
		if(!k)k=++tot; ++sum[k];
		if(l==r)return;
		if(pos<=mid)modify(ls[k],l,mid,pos);
		else modify(rs[k],mid+1,r,pos);
	}
	int query(int k,int l,int r,int val){
		if(l==r)return l;
		int tmp=mid-l+1-sum[ls[k]];
		if(val<=tmp)return query(ls[k],l,mid,val);
		return query(rs[k],mid+1,r,val-tmp);
	}
	#undef mid
}seg;
int solve2(int x,int y){
	int pos=seg.query(rt[n+1],1,X,x); seg.modify(rt[n+1],1,X,pos);
	int ans=(pos<=n)?(pos*m):(v[n+1][pos-n-1]);
	v[n+1].push_back(y?y:ans); return ans;
}
int solve1(int x,int y){
	int pos=seg.query(rt[x],1,X,y); seg.modify(rt[x],1,X,pos);
	int ans=(pos<m)?((x-1)*m+pos):(v[x][pos-m]);
	v[x].push_back(solve2(x,ans)); return ans;
}
signed main(){
	scanf("%lld %lld %lld",&n,&m,&q); X=max(n,m)+q;
	while(q--){
		int x,y; scanf("%lld %lld",&x,&y);
		printf("%lld\n",y==m?solve2(x,0):solve1(x,y));
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #131.685 ms183 MB + 280 KBAcceptedScore: 5

Testcase #231.676 ms183 MB + 268 KBAcceptedScore: 5

Testcase #331.67 ms183 MB + 268 KBAcceptedScore: 5

Testcase #431.715 ms183 MB + 292 KBAcceptedScore: 5

Testcase #531.874 ms183 MB + 280 KBAcceptedScore: 5

Testcase #631.693 ms183 MB + 288 KBAcceptedScore: 5

Testcase #732.424 ms183 MB + 632 KBAcceptedScore: 5

Testcase #831.868 ms183 MB + 648 KBAcceptedScore: 5

Testcase #932.115 ms183 MB + 680 KBAcceptedScore: 5

Testcase #1031.824 ms183 MB + 684 KBAcceptedScore: 5

Testcase #11100.054 ms196 MB + 100 KBAcceptedScore: 5

Testcase #1299.821 ms196 MB + 28 KBAcceptedScore: 5

Testcase #13298.991 ms224 MB + 100 KBAcceptedScore: 5

Testcase #14282.105 ms222 MB + 404 KBAcceptedScore: 5

Testcase #15284.918 ms223 MB + 148 KBAcceptedScore: 5

Testcase #16299.345 ms224 MB + 388 KBAcceptedScore: 5

Testcase #17134.168 ms212 MB + 1000 KBAcceptedScore: 5

Testcase #18128.789 ms211 MB + 652 KBAcceptedScore: 5

Testcase #19416.145 ms272 MB + 196 KBAcceptedScore: 5

Testcase #20417.665 ms271 MB + 856 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:26:01 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠