답안 #1092475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092475 2024-09-24T07:34:37 Z alexander707070 Gap (APIO16_gap) C++14
17.9427 / 100
101 ms 10828 KB
#include<bits/stdc++.h>
#include "gap.h"

#define MAXN 600007
using namespace std;

struct interval{
    long long from,to;

    inline friend bool operator < (interval fr,interval sc){
        return fr.to-fr.from<sc.to-sc.from;
    }
};

priority_queue<interval> q;

interval check(long long l,long long r){
    if(l+1==r)return {-1,-1};

	long long mid=(l+r)/2;

    long long *ll,*rr,*lt,*rt;

	ll=new long long();
	rr=new long long();

	lt=new long long();
	rt=new long long();

    MinMax(l+1,mid, ll,rr);
	MinMax(mid,r-1, lt,rt);

    return {*rr,*lt};
}

const long long inf=1e18;

long long *l,*r;

long long findGap(int T, int N){

	while(!q.empty())q.pop();

	l=new long long();
	r=new long long();

    MinMax(1, inf, l,r);
    q.push({*l,*r});

	if(N==2)return *r-*l;

    while(true){
        interval s=check(q.top().from,q.top().to);

        if(s.from==-1 and s.to==-1)return q.top().to-q.top().from;

        interval z=q.top();
        q.pop();

		if(s.from==-1)s.from=s.to;
		if(s.to==-1)s.to=s.from;

        if(z.from!=s.from)q.push({z.from,s.from});
        if(s.from!=s.to)q.push(s);
        if(s.to!=z.to)q.push({s.to,z.to});
    }

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Incorrect 1 ms 600 KB Output isn't correct
16 Correct 8 ms 1112 KB Output is correct
17 Correct 6 ms 856 KB Output is correct
18 Correct 6 ms 856 KB Output is correct
19 Correct 6 ms 856 KB Output is correct
20 Correct 2 ms 600 KB Output is correct
21 Correct 29 ms 2744 KB Output is correct
22 Correct 26 ms 2516 KB Output is correct
23 Correct 37 ms 2508 KB Output is correct
24 Correct 34 ms 2348 KB Output is correct
25 Incorrect 101 ms 10828 KB Output isn't correct
26 Correct 26 ms 2772 KB Output is correct
27 Correct 25 ms 2252 KB Output is correct
28 Correct 26 ms 2508 KB Output is correct
29 Correct 25 ms 2252 KB Output is correct
30 Correct 7 ms 1112 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Partially correct 0 ms 344 KB Partially correct
3 Partially correct 0 ms 344 KB Partially correct
4 Correct 0 ms 344 KB Output is correct
5 Partially correct 0 ms 344 KB Partially correct
6 Partially correct 0 ms 344 KB Partially correct
7 Partially correct 0 ms 344 KB Partially correct
8 Partially correct 0 ms 344 KB Partially correct
9 Partially correct 0 ms 344 KB Partially correct
10 Partially correct 0 ms 344 KB Partially correct
11 Partially correct 1 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 1 ms 344 KB Partially correct
14 Partially correct 1 ms 344 KB Partially correct
15 Partially correct 1 ms 600 KB Partially correct
16 Partially correct 12 ms 1112 KB Partially correct
17 Partially correct 7 ms 1020 KB Partially correct
18 Partially correct 6 ms 856 KB Partially correct
19 Partially correct 7 ms 856 KB Partially correct
20 Partially correct 3 ms 852 KB Partially correct
21 Partially correct 26 ms 2516 KB Partially correct
22 Partially correct 34 ms 2764 KB Partially correct
23 Partially correct 26 ms 2252 KB Partially correct
24 Partially correct 34 ms 2328 KB Partially correct
25 Partially correct 98 ms 10764 KB Partially correct
26 Partially correct 27 ms 2252 KB Partially correct
27 Partially correct 26 ms 2772 KB Partially correct
28 Partially correct 30 ms 2768 KB Partially correct
29 Partially correct 26 ms 2516 KB Partially correct
30 Partially correct 13 ms 1024 KB Partially correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct