提交记录 3760


用户 题目 状态 得分 用时 内存 语言 代码长度
attack noi18a. 【NOI2018】归程 Runtime Error 50 4 s 3544 KB C++ 1.77 KB
提交时间 评测时间
2018-07-18 17:20:48 2020-07-31 21:32:11
#include<cstdio>
#include<map>
#include<cstring>
#include<queue>
using namespace std;
const int MAXN = 1e5 + 10, INF = 1e9 + 10;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int N, M, lastans;
struct Edge {
	int u, v, l, a, t, nxt;
}E[MAXN];
int head[MAXN], num = 1;
int dis[MAXN], vis[MAXN];
void init() {
	memset(head, -1, sizeof(head));
	num = 1;
	memset(vis, 0, sizeof(vis));
	lastans = 0;
}
void AddEdge(int x, int y, int z, int GG) {
	E[num] = (Edge){x, y, z, GG, 0, head[x]};
	head[x] = num++;
}
void SPFA(int S) {
	memset(dis, 0x3f, sizeof(dis));
	dis[S] = 0; 
	queue<int> q; q.push(S);
	while(!q.empty()) {
		int p = q.front(); q.pop(); vis[p] = 0;
		for(int i = head[p]; i != -1; i = E[i].nxt) {
			int to = E[i].v;
			if(dis[to] > dis[p] + E[i].l) {
				dis[to] = dis[p] + E[i].l;
				if(!vis[to]) 
					q.push(to), vis[to] = 1;
			}
		}
	}
}
void dfs(int now, int hi, int ti) {
	vis[now] = ti; 
	lastans = min(lastans, dis[now]);
	for(int i = head[now]; i != -1; i = E[i].nxt) {
		int to = E[i].v;
		if(vis[to] == ti) continue;
		if(E[i].a <= hi) continue;
		dfs(to, hi, ti);
	}
}
int main() {

	int QwQ = read();
	while(QwQ--) {
		init();
		N = read(); M = read();
		for(int i = 1; i <= M; i++) {
			int x = read(), y = read(), z = read(), GG = read();
			AddEdge(x, y, z, GG);
			AddEdge(y, x, z, GG);
		}
		SPFA(1);
		int Q = read(), K = read(), S = read();
		for(int i = 1; i <= Q; i++) {
			int v = read(), p = read();
			v = (v + K * lastans - 1) % N + 1;
			p = (p + K * lastans) % (S + 1);
			lastans = INF; dfs(v, p, i);
			printf("%d\n", lastans);
		}
	}
	return 0;
}
/*
1
4 3
1 2 50 1
2 3 100 2
3 4 50 1
5 0 2
3 0
2 1
4 1
3 1
3 2
*/

CompilationN/AN/ACompile OKScore: N/A

Testcase #1152.94 us1 MB + 172 KBAcceptedScore: 5

Testcase #2170.09 us1 MB + 176 KBAcceptedScore: 5

Testcase #3293.86 us1 MB + 184 KBAcceptedScore: 5

Testcase #4447.47 us1 MB + 196 KBAcceptedScore: 5

Testcase #527.011 ms1 MB + 432 KBAcceptedScore: 5

Testcase #62.783 ms3 MB + 76 KBRuntime ErrorScore: 0

Testcase #740.965 ms1 MB + 352 KBAcceptedScore: 5

Testcase #839.702 ms1 MB + 356 KBAcceptedScore: 5

Testcase #940.397 ms1 MB + 352 KBAcceptedScore: 5

Testcase #103.846 ms3 MB + 80 KBRuntime ErrorScore: 0

Testcase #113.869 ms3 MB + 468 KBRuntime ErrorScore: 0

Testcase #123.691 ms3 MB + 80 KBRuntime ErrorScore: 0

Testcase #133.696 ms3 MB + 76 KBRuntime ErrorScore: 0

Testcase #144 s3 MB + 468 KBTime Limit ExceededScore: 0

Testcase #15194.006 ms1 MB + 452 KBAcceptedScore: 5

Testcase #16195.026 ms1 MB + 452 KBAcceptedScore: 5

Testcase #173.72 ms3 MB + 472 KBRuntime ErrorScore: 0

Testcase #183.696 ms3 MB + 88 KBRuntime ErrorScore: 0

Testcase #194 s3 MB + 464 KBTime Limit ExceededScore: 0

Testcase #203.693 ms3 MB + 76 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-18 01:12:49 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠