답안 #743190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743190 2023-05-17T08:43:01 Z jamezzz Nicelines (RMI20_nicelines) C++17
79.8051 / 100
104 ms 308 KB
#include <bits/stdc++.h>
using namespace std;
#include "nice_lines.h"

#define pf printf
#define pb push_back
#define maxn 10000
#define EPS 1e-5
#define dist(a,b,x,y) (ld)abs(y-a*x-b)/pow(1+a*a,0.5)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

map<ii,ld> memo;
vector<ii> know;

ld ask(ld x,ld y){
	//ld res;
	//if(memo.find({x,y})!=memo.end())res=memo[{x,y}];
	//else res=memo[{x,y}]=query(x,y);
	ld res=query(x,y);
	for(auto[a,b]:know)res-=dist(a,b,x,y);
	return res;
}

void solve(int subtask_id,int N){
	ld far=ask(0,10001);
	for(int i=0;i<N;++i){
		int lo=-10000,hi=10000,mid,res;
		while(lo<=hi){
			mid=lo+((hi-lo)>>1);
			if(ask(0,mid)>ask(0,mid+1))lo=mid+1;
			else res=mid,hi=mid-1;
		}
		int b=(int)res;
		lo=-10000,hi=10000;
		while(lo<=hi){
			mid=lo+((hi-lo)>>1);
			if(ask(EPS,mid*EPS+b)>ask(EPS,(mid+1)*EPS+b))lo=mid+1;
			else res=mid,hi=mid-1;
		}
		int a=(int)res;
		know.push_back({a,b});
	}
	vector<int> A,B;
	for(auto[a,b]:know)A.pb(a),B.pb(b);
	the_lines_are(A,B);
}

Compilation message

nicelines.cpp: In function 'void solve(int, int)':
nicelines.cpp:27:5: warning: unused variable 'far' [-Wunused-variable]
   27 |  ld far=ask(0,10001);
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 86 ms 288 KB Output is partially correct
2 Partially correct 92 ms 296 KB Output is partially correct
3 Partially correct 94 ms 288 KB Output is partially correct
4 Partially correct 97 ms 292 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 22 ms 208 KB Output is partially correct
2 Partially correct 23 ms 208 KB Output is partially correct
3 Partially correct 24 ms 208 KB Output is partially correct
4 Partially correct 27 ms 208 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 86 ms 288 KB Output is partially correct
2 Partially correct 92 ms 296 KB Output is partially correct
3 Partially correct 94 ms 288 KB Output is partially correct
4 Partially correct 97 ms 292 KB Output is partially correct
5 Partially correct 22 ms 208 KB Output is partially correct
6 Partially correct 23 ms 208 KB Output is partially correct
7 Partially correct 24 ms 208 KB Output is partially correct
8 Partially correct 27 ms 208 KB Output is partially correct
9 Partially correct 86 ms 292 KB Output is partially correct
10 Partially correct 104 ms 208 KB Output is partially correct
11 Partially correct 83 ms 308 KB Output is partially correct
12 Partially correct 82 ms 288 KB Output is partially correct