QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#289238#7866. Teleportationucup-team191#WA 1ms3892kbC++141.1kb2023-12-23 16:21:152023-12-23 16:21:16

Judging History

你现在查看的是最新测评结果

  • [2023-12-23 16:21:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3892kb
  • [2023-12-23 16:21:15]
  • 提交

answer

#include <cstdio>
#include <set>

#define X first
#define Y second

using namespace std;

typedef pair < int, int > pii;
typedef long long ll;
typedef pair < ll, pii > plp;

const int N = 1e5 + 500;

int a[N], n, dst, bio[N];
ll ans[N];

set < plp > S;
set < pii > tme;

void add_closest(int x){
	if(x == -1 || tme.empty()) return;
	int y = tme.rbegin() -> Y;
	if(tme.begin() -> X <= x) {
		y = (--tme.lower_bound({x, -1}))->Y;
	}
	S.insert({1 + ans[x] + (x + 2 * n - a[y] - y) % n, {y, x}});
	// ubaci y
}

int main(){
	scanf("%d%d", &n, &dst);
	for(int i = 0;i < n;i++) {
		scanf("%d", a + i);	
		if(i != dst) {
			tme.insert({(i + a[i]) % n, i});
			ans[i] = -1;
		} else {
			S.insert({0, {i, -1}});
			ans[i] = 0;
		}
	}
	for(;!S.empty();) {
		int st = S.begin()->Y.X;
		int from = S.begin()->Y.Y;
		if(bio[st]) {
			add_closest(from);
			S.erase(S.begin());
			continue;
		}
		ans[st] = S.begin()->X;
		S.erase(S.begin());
		bio[st] = 1;
		tme.erase({(st + a[st]) % n, st});
		add_closest(from);
		add_closest(st);
	}
	printf("%lld\n", ans[0]);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3880kb

input:

4 3
0 1 2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

4 3
0 0 0 0

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

4 3
2 2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

2 1
0 0

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

2 1
1 1

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3892kb

input:

300 25
182 9 13 211 258 132 27 42 218 200 271 258 164 121 8 84 29 195 141 290 110 0 272 93 142 134 140 32 232 99 162 199 297 287 212 29 182 53 61 98 116 282 75 245 230 165 22 4 179 89 274 231 46 299 248 208 200 285 221 50 221 199 294 241 195 138 22 204 113 100 132 276 158 146 238 178 100 94 131 157 ...

output:

13

result:

wrong answer 1st numbers differ - expected: '10', found: '13'