# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
198838 |
2020-01-27T20:16:27 Z |
brcode |
Drzava (COCI15_drzava) |
C++14 |
|
731 ms |
65540 KB |
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5+5;
const long double eps = 0.00001;
bool visited[MAXN];
long long test;
long long n,k;
pair<pair<long long,long long>,long long> p[MAXN];
struct cmpf{
inline bool operator()(const long long& i, const long long& j)const{
if(p[i].first.second!=p[j].first.second){
return p[i].first.second<p[j].first.second;
}
return i>j;
}
};
set<long long,cmpf> s1;
vector<long long> v1[MAXN];
vector<long long> tempv;
bool dp[MAXN][40];
bool dist(long long i,long long j,long double x){
return (long double)((p[i].first.first-p[j].first.first)*(p[i].first.first-p[j].first.first))+((p[i].first.second-p[j].first.second)*(p[i].first.second-p[j].first.second))<=x*x;
}
void dfs(long long curr){
tempv.push_back(curr);
visited[curr] = true;
for(long long x:v1[curr]){
if(!visited[x]){
dfs(x);
}
}
}
bool findsubset(){
long long m = tempv.size();
m--;
if(m>k){
return true;
}
for(long long i=0;i<=m+1;i++){
for(long long j=0;j<=k+1;j++){
dp[i][j] = false;
}
}
for(long long mod = 0;mod<k;mod++){
dp[m+1][mod] = !mod;
}
for(long long i=m;i>=1;i--){
for(long long mod = 0;mod<k;mod++){
dp[i][mod] = dp[i+1][mod];
if(dp[i+1][(mod+p[tempv[i]].second)%k]){
dp[i][mod] = true;
}
}
if(dp[i+1][p[tempv[i]].second]){
return true;
}
}
return false;
}
bool check(long double x){
for(long long i=1;i<=n;i++){
v1[i].clear();
visited[i] = false;
}
s1.clear();
long long j = 1;
for(long long i=1;i<=n;i++){
if(test){
//cout<<p[i].first.first-p[j].first.first<<endl;
}
while((long double)(p[i].first.first-p[j].first.first)>x){
s1.erase(j);
j++;
}
if(!s1.empty()){
long long cnt = 0;
p[n+1] = make_pair(make_pair(p[i].first.first,p[i].first.second-x),0);
for(auto it = s1.lower_bound(n+1);it!=s1.end();it++){
long long idx = *it;
if(test && i==6){
//it--;
//idx = *it;
//cout<<i+1<<" "<<j<<" "<<p[i].first.second-x<<" "<<p[idx].first.first<<" "<<p[i].first.first<<" "<<p[i].first.second<<" "<<p[idx].first.second<<endl;
}
if(p[idx].first.second>p[i].first.second+x){
break;
}
cnt++;
if(cnt>=8*k){
return true;
}
if(dist(i,idx,x)){
v1[i].push_back(idx);
v1[idx].push_back(i);
}
}
}
s1.insert(i);
}
for(long long i=1;i<=n;i++){
if(!visited[i]){
tempv.clear();
tempv.push_back(-1);
dfs(i);
if(test == 23){
// cout<<i<<" "<<tempv.size()-1<<endl;
if(i==5){
test = 25;
}
}
if(findsubset()){
return true;
}
}
}
return false;
}
int main() {
cin>>n>>k;
for(long long i=1;i<=n;i++){
cin>>p[i].first.first>>p[i].first.second>>p[i].second;
p[i].second%=k;
}
sort(p+1,p+n+1);
long double l = 0;
long double r = 1e9;
long double ans = -1;
while(r-l>eps){
long double mid = (l+r)/2;
if(check(mid)){
ans = mid;
r = mid-eps;
}else{
l = mid+eps;
}
}
test=23;
// cout<<check(11163410)<<endl;
if(ans == -1){
cout<<"No solution"<<endl;
}else{
cout<<std::fixed<<setprecision(3)<<ans<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
7 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
2808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
25 ms |
4216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
15 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
29 ms |
3468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
35 ms |
4088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
24 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2808 KB |
Output is correct |
2 |
Correct |
18 ms |
3576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
192 ms |
10872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Runtime error |
363 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Runtime error |
355 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
669 ms |
41868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
731 ms |
43392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Runtime error |
352 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
565 ms |
15020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
618 ms |
24212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
633 ms |
43640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2680 KB |
Output is correct |
2 |
Correct |
637 ms |
44024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
483 ms |
18036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2680 KB |
Output is correct |
2 |
Correct |
511 ms |
16988 KB |
Output is correct |