比赛 防止浮躁的小练习v0.4 评测结果 AAAAAAAAAA
题目名称 苳岑学姐の超电磁炮 最终得分 100
用户昵称 Fmuckss 运行时间 0.074 s
代码语言 C++ 内存使用 0.53 MiB
提交时间 2016-10-13 18:53:15
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1e4 + 10;

struct Ant {
	int pos, id, dir;
	
	bool operator < (const Ant &b) const {
		return pos < b.pos;
	}
} as[maxn], mv[maxn];

int n, l, m;
int rank[maxn];

inline void read() {
	scanf("%d %d", &n, &l);
	for (int i = 1; i <= n; i++) {
		as[i].id = i;
		scanf("%d %d", &as[i].pos, &as[i].dir);
	}
}

inline void solve() {
	sort(as + 1, as + n + 1);
	for (int i = 1; i <= n; i++) rank[as[i].id] = i;
	int t;
	
	scanf("%d", &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d", &t);
		for (int i = 1; i <= n; i++) mv[i].pos = as[i].pos + (as[i].dir ? -t : t);
		
		sort(mv + 1, mv + n + 1);
		
		for (int i = 1; i <= n; i++) {
			int id = rank[i];
			
			if (mv[id].pos < 1 or mv[id].pos > l) printf("fire in the hole ");
			else printf("%d ", mv[id].pos);
		}
		printf("\n");
	}
}

int main() {
	freopen("dcball.in", "r", stdin);
	freopen("dcball.out", "w", stdout);
	read();
	solve();
	return 0;
}