QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#62020#138. Bali SculpturesLand_ER0 3ms4604kbC++141.7kb2022-11-16 23:35:002022-11-16 23:35:01

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-16 23:35:01]
  • Judged
  • Verdict: 0
  • Time: 3ms
  • Memory: 4604kb
  • [2022-11-16 23:35:00]
  • Submitted

answer

#include <bits/stdc++.h>
#define u32 unsigned int
#define i64 long long int
#define u64 unsigned long long int
#define N 30005
#define INF 0x3f3f3f3f
int n, m, b[N], p[N];
struct node {
	int v, w;
	node(void) {
		return;
	}
	node(int a, int b) {
		v = a, w = b;
		return;
	}
	bool operator<(const node &x) const {
		return w > x.w;
	}
};
int read(void) {
	int w = 0;
	char c = getchar();
	while(!isdigit(c))
		c = getchar();
	while(isdigit(c))
		w = w * 10 + c - '0', c = getchar();
	return w;
}
int min(int a, int b) {
	return a < b ? a : b;
}
void init(void) {
	n = read(), m = read();
	for(int i = 0; i < m; ++ i)
		b[i] = read(), p[i] = read();
	return;
}
namespace subtask1 {
	std::vector<node> graph[N];
	int dis[N], vis[N];
	std::priority_queue<node> q;
	void dijkstra(int s, int t) {
		memset(dis, 0x3f, sizeof(dis));
		memset(vis, 0, sizeof(vis));
		dis[s] = 0;
		q.push(node(s, 0));
		while(!q.empty()) {
			int u = q.top().v;
			q.pop();
			if(u == t)
				return;
			if(vis[u])
				continue;
			vis[u] = 1;
			for(node e : graph[u]) {
				if(dis[u] + e.w < dis[e.v]) {
					dis[e.v] = dis[u] + e.w;
					q.push(node(e.v, dis[e.v]));
				}
			}
		}
		return;
	}
	void solve(void) {
		for(int i = 0; i < m; ++ i) {
			for(int j = 1; b[i] - j * p[i] >= 0; ++ j) {
				graph[b[i]].push_back(node(b[i] - j * p[i], j));
			}
			for(int j = 1; b[i] + j * p[i] < n; ++ j) {
				graph[b[i]].push_back(node(b[i] + j * p[i], j));
			}
		}
		dijkstra(b[0], b[1]);
		printf("%d", dis[b[1]] == INF ? -1 : dis[b[1]]);
		return;
	}
}
void solve(void) {
	subtask1::solve();
	return;
}
int main(void) {
	init();
	solve();
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 4476kb

input:

8 1 4
1 2 1 1 1 0 4 6

output:

4

result:

wrong answer 1st lines differ - expected: '6', found: '4'

Subtask #2:

score: 0
Wrong Answer

Test #13:

score: 0
Accepted
time: 3ms
memory: 4604kb

input:

6 2 3
1 1 1 1 1 1

output:

2

result:

ok single line: '2'

Test #14:

score: -0
Wrong Answer
time: 3ms
memory: 4552kb

input:

20 4 7
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10

output:

-1

result:

wrong answer 1st lines differ - expected: '30', found: '-1'

Subtask #3:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 3ms
memory: 4484kb

input:

5 1 3
451631570 250518388 397580948 477427142 699144811

output:

-1

result:

wrong answer 1st lines differ - expected: '1040187263', found: '-1'

Subtask #4:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 3ms
memory: 4548kb

input:

21 1 20
7 2 8 9 5 5 2 8 3 0 5 0 5 9 3 4 1 4 7 7 10

output:

-1

result:

wrong answer 1st lines differ - expected: '15', found: '-1'

Subtask #5:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 0ms
memory: 4592kb

input:

51 1 20
6 10 12 9 0 3 14 3 0 1 18 20 4 9 7 16 11 15 17 16 10 15 11 1 6 16 19 15 12 17 10 3 6 5 14 6 11 0 18 6 0 2 4 7 7 16 7 9 10 13 0

output:

-1

result:

wrong answer 1st lines differ - expected: '31', found: '-1'

Subtask #6:

score: 0
Wrong Answer

Test #55:

score: 0
Wrong Answer
time: 3ms
memory: 4528kb

input:

51 1 20
112872931 738945953 683278169 770763749 516510818 790818428 875172481 703986370 60868760 918060338 785761560 775662511 633498896 598270657 590667589 115223551 657182582 662359373 423527461 442741161 404625684 341975402 396747626 126186088 753822361 159840892 743886212 135361223 217348329 815...

output:

-1

result:

wrong answer 1st lines differ - expected: '1879048191', found: '-1'

Subtask #7:

score: 0
Memory Limit Exceeded

Test #63:

score: 0
Memory Limit Exceeded

input:

90 45 90
0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 1 1 2

output:


result:


Subtask #8:

score: 0
Wrong Answer

Test #74:

score: 0
Wrong Answer
time: 1ms
memory: 4484kb

input:

101 1 20
109288331 167187936 289459547 455669706 656308194 233503022 562258473 2210429 243994669 58628149 750503963 610269250 29072940 251143410 458350486 696874700 870849343 646709707 646709077 746808795 87439926 187779526 762073671 569489420 380238922 982163795 784978520 933220915 264403502 755738...

output:

-1

result:

wrong answer 1st lines differ - expected: '3221159935', found: '-1'

Subtask #9:

score: 0
Skipped

Dependency #1:

0%

Subtask #10:

score: 0
Skipped

Dependency #1:

0%

Subtask #11:

score: 0
Skipped

Dependency #1:

0%

Subtask #12:

score: 0
Skipped

Dependency #1:

0%

Subtask #13:

score: 0
Skipped

Dependency #1:

0%