265 | 2021-04-07 18:42:00 | 4rt3xp0 | 2015. szeptember | cpp11 | Wrong answer on test 2 | 2ms | 1764 KiB |
#include<bits/stdc++.h>
using namespace std;
vector<int> p(100),r(100,1);
vector<bool> u1(100,0),u2(100,0);
int f(int v){
if(p[v]==v) return v;
return p[v]=f(p[v]);
}
void u(int a, int b){
a=f(a);
b=f(b);
if(a==b) return;
if(r[a]<r[b]) swap(a,b);
p[b]=a;
r[a]+=r[b];
}
void init(){
for(int i=0;i<100;i++) p[i]=i;
}
struct kor{
int x,y,r;
};
bool metsz(kor a, kor b){
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)<=(a.r+b.r)*(a.r+b.r);
}
int main(){
int n,m,k; cin >> n >> m >> k;
vector<kor> a(k); for(kor &i: a) cin >> i.x >> i.y >> i.r;
init();
for(int i=1;i<k;i++){
for(int j=0;j<i;j++){
if(metsz(a[i],a[j])) u(i,j);
}
}
for(int i=0;i<k;i++){
if(a[i].y<=a[i].r) u1[f(i)]=1;
if(a[i].y>=m-a[i].r) u2[f(i)]=1;
}
for(int i=0;i<k;i++) if(u1[i] && u2[i]) return cout << "Nem vezet " << i,0;
cout << "Vezet";
}
Vezet
Expected output:Vezet
Checker output:ok "Vezet"
Nem vezet 1
Expected output:Nem vezet
Checker output:wrong answer Participant output contains extra tokens