Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 100009;
int main() {
string s;
cin >> s;
int l = s.size();
for (int i = 0; i < l; i++) s += s[i];
int ans = 1;
for (int i = 0; i < l;) {
int j = i;
for (; j < l + i - 1; j++) {
if (s[j] == s[j + 1])
break;
else
a... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
char s[1000050];
int max(int x, int y) { return (x > y) ? x : y; }
int main() {
scanf("%s", &s);
int len = strlen(s);
int cnt = 1, j;
int result = 1;
for (int i = len; i < 2 * len; i++) {
s[i] = s[i - len];
}
len = 2 * len;
for (int i = 0; i < len; i = j... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | import java.util.Scanner;
public class Main {
public static int maxLength(String s) {
int max = 1, count = 1;
for(int i = 1; i < s.length(); i++) {
if(s.charAt(i - 1) != s.charAt(i)) {
count++;
}else {
if(count > max) {
max = count;
}
count = 1;
}
}
return Math.... | JAVA |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
public static void main(String[] args) {
... | JAVA |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long n;
long long tab[250007];
int32_t main() {
ios_base::sync_with_stdio(false);
string s;
cin >> s;
n = s.size();
string mm = s + s;
long long maxi = 1;
tab[0] = 1;
for (long long i = 1; i < n * 2; ++i) {
long long old = min(tab[i - 1], n - 1);
... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | s = input()
n = len(s)
s = s+s+s
max = cur = 1
for i in range(len(s)-1):
if s[i] != s[i+1]:
cur += 1
if max < cur:
max = cur
else:
cur = 1
if max > n:
print(n)
else:
print(max)
| PYTHON3 |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | import java.util.*;
public class PlasticineZebra {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
char[] s = scan.nextLine().toCharArray();
int n = s.length;
int ans = 0;
int roll = 0;
char last = s[0];
for(int i = 0; i < 3*n; i++) {
if(s[i%n] == last)
roll = 1;
... | JAVA |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
def li():
return list(map(int , input().split()))
# https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
def modInverse(a , m):
m0 = m
y = 0
x = 1
if (m == 1):
return 0
while (a > 1):... | PYTHON3 |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | s=raw_input()
n=len(s)
s=2*s
maxi=0;i=0;
while i<n:
j=i
while j-i<n-1:
if s[j]!=s[j+1]:
j+=1
else:
break
maxi=max(maxi,j-i+1)
i=j+1
print maxi
| PYTHON |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | s=input()
s=s*2
l=[0]*len(s)
l[0]=1
for i in range(1,len(s)):
if s[i-1]!=s[i]:
l[i]=l[i-1]+1
else:
l[i]=1
print(min(max(l),int(len(s)/2)))
# Made By Mostafa_Khaled | PYTHON3 |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | /**
* Created by Baelish on 8/19/2018.
*/
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class C {
public static void main(String[] args)throws Exception {
FastReader in = new FastReader(System.in);
PrintWriter pw = new PrintWriter(System.out);
char[] s = i... | JAVA |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
ios ::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s;
cin >> s;
char c1 = 'w', c2 = 'b';
long long int n = s.length(), k = 1, k1 = 1;
for (long long int i = 1; i < n; i++) {
if (s[i] != s[i - 1]) {
... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | # -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 12/10/18
"""
s = input()
ans = 0
n = len(s)
i = 0
while i < len(s):
j = i + 1
while j != i and s[(j-1+n) % n] != s[j % n]:
j = (j+1)%n
if j == i:
ans = n
break
elif j > i:
ans = max(j-i, ans)
el... | PYTHON3 |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, i, L, l;
char a[200002];
int main() {
cin >> a;
n = strlen(a);
for (i = 0; i < n; ++i) a[n + i] = a[i];
if (n == 1) {
cout << 1;
return 0;
}
n *= 2;
L = 1;
l = 0;
for (i = 1; i < n; ++i) {
if (a[i] != a[i - 1])
++l;
else {
... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class d {
public static void main(String[] args) throws IOException {
//Scanner s = new Scanner(System.in);
BufferedReader s=new BufferedReader(new InputStreamReader(System.in));
... | JAVA |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
char A[1 << 20];
int f(int n) {
int i;
for (i = (0); i < (n); ++i) A[i + n] = A[i];
int res = 1;
int cur = 1;
for (i = (1); i < (n + n); ++i) {
if (A[i] == A[i - 1]) cur = 0;
++cur;
res = max(res, cur);
}
return min(n, res);
}
int main() {
scanf(... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.*;
public class Main {
public static String s="";
public static int gcd(int a, int b) {
if(a>b) {
int c=a;
a=b;
b=c;
}
if(a == 0) return b;
return gcd(b%a, a);
}
public static int j;
... | JAVA |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #skonrad
def matches(a, b):
return a != b
txt = str(input())
n = len(txt)
txt = txt + txt
res = 0
j = 0
for i in range(n):
j = max(i, j)
while j - i + 1 < n and matches(txt[j + 1], txt[j]):
j = j + 1
res = max(res, j - i + 1)
print(res)
| PYTHON3 |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int i = 0, n, t = 0, cnt = 1, maxm = 1;
n = s.size();
while (t < 2) {
if ((s[i] == 'b' && s[(i + 1) % n] == 'w') ||
(s[i] == 'w' && s[(i + 1) % n] == 'b')) {
while ((s[i] == 'b' && s[(i + 1) % n] == 'w') ||
... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int test = 1;
while (test--) {
string s;
cin >> s;
int n = s.size();
if (n == 1) {
cout << 1;
return 0;
}
int cnt = 0, c1 = 1, cc = 1, chc = 1;
for (int i = n - ... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n;
char c[200005];
int main() {
int i;
char t;
t = getchar(), n = 0;
while (t != '\n') c[++n] = t, t = getchar();
for (i = 1; i <= n; i++) c[n + i] = c[i];
int cnt = 1, ans = 1;
for (i = 2; i <= 2 * n; i++) {
if (c[i] != c[i - 1]) {
cnt++;
... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long test, n, i, j, k;
string input;
cin >> input;
k = input.size();
for (i = 0; i < (k - 1); i++) {
if (input[i] == input[i + 1] && input[0] != input[input.size() - 1]) {
reverse(input.begin(), input.begin() + i + 1);
reverse(inp... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long qpow(long long n, long long k) {
long long ans = 1;
while (k > 0) {
if (k & 1) ans = ans * n;
n = n * n;
k >>= 1;
}
return ans;
}
long long INV(long long x) {
return x == 1 ? x : 1LL * (mod - mod / x) * INV(mod ... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | a=list(input())
m=1
c=1
z=0
for i in range(len(a)-1):
if a[i]!=a[i+1]:
c+=1
else:
c=1
m=max(m,c)
if a[0]!=a[-1]:
d=1
f=1
for i in range(len(a)-1):
if a[i]!=a[i+1]:
d+=1
else:
break
for i in range(len(a)-2,-1,-1):
if a[i]!=a[i+1]:
f+=1
else:
break
z=min(len(a),d+f)
print(max(m,z)) ... | PYTHON3 |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 421543;
const int M = 26543;
const int INF = 1023456789;
int n, m, k, start, goal;
struct node {
int t, x, y;
} b[N];
char s[N];
int main() {
int cases = 1;
for (int iii = 1; iii <= cases; ++iii) {
scanf("%s", s);
n = strlen(s);
int ans = 0, ... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;
public class VKR505C {
public static void main (String[] args) throws java.lang.Exception {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
String s = in.next();
... | JAVA |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | s = raw_input()
n = len(s)
bit = s[0]
count = 1
for i in range(1,len(s)):
if(s[i] == bit):
break
else:
count += 1
bit = s[i]
if(count == n):
print n
else:
s += s
maxi = 1
count = 1
bit = s[0]
for i in range(1,len(s)):
if(s[i] == bit):
maxi = max(ma... | PYTHON |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
if (s[0] != s[s.size() - 1]) {
for (int i = 0; i < s.size() - 1; i++) {
if (s[i] == s[i + 1]) {
string s1 = s.substr(0, i + 1), s2 = s.substr(i + 1);
reverse((s1).begin(), (s1).end());
reverse((s2).beg... | CPP |
1025_C. Plasticine zebra | Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras.
Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int mx = 300100;
const int md = 1000000007;
bool compare(const pair<int, int>& a, const pair<int, int>& b) {
if (a.first == b.first) return a.second < b.second;
return a.first > b.first;
}
int main() {
string a;
int ans = 1, cnt = 1, depan = 1, belakang = 1;
... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
struct point {
int x, y, c, id;
point() {}
point(int x, int y) : x(x), y(y) {}
point operator-(const point &b) const { return {x - b.x, y - b.y}; }
int operator^(const point &b) const { return x * b.y - y *... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int c[5010], n, x[5010], y[5010], top, d[5010], sta[5010], t;
struct DOT {
int x, y;
DOT(int _x = 0, int _y = 0) { x = _x, y = _y; }
} a[5010];
DOT operator-(DOT a, DOT b) { return DOT(a.x - b.x, a.y - b.y); }
int ctime(DOT a, DOT b) { return a.x * b.y - a.y * b.x; }
bo... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
const int N = 1054;
struct vec2 {
int x, y;
vec2(int x0 = 0, int y0 = 0) : x(x0), y(y0) {}
vec2 *read() {
scanf("%d%d", &x, &y);
return this;
}
inline vec2 operator-() const { return vec2(-x, -y); }
inline vec2 operator+(const vec2 &B) const { return vec2(x + B.x, y + B.y); ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int c[5010], n, x[5010], y[5010], top, d[5010], sta[5010], t;
struct DOT {
int x, y;
DOT(int _x = 0, int _y = 0) { x = _x, y = _y; }
} a[5010];
DOT operator-(DOT a, DOT b) { return DOT(a.x - b.x, a.y - b.y); }
int ctime(DOT a, DOT b) { return a.x * b.y - a.y * b.x; }
bo... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 1000;
struct P {
int x, y, col, id;
P() {}
P(int x, int y) : x(x), y(y), col(-1), id(-1) {}
};
bool operator<(const P &a, const P &b) {
if (a.x != b.x) return a.x < b.x;
return a.y < b.y... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
const int MAXN = 1010;
struct vec {
int x, y, c, id;
vec() { x = y = 0; }
vec(int a, int b) { x = a, y = b; }
vec operator+(vec b) const { return vec(x + b.x, y + b.y); }
vec operator-(vec b) const { return vec(x - b.x, y - b.y); }
int operator^(vec b) const { return x * b.y - y * b... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
const int N = 1e6 + 50;
int n, f[N];
inline int find(int x) {
while (x != f[x]) x = f[x] = f[f[x]];
return x;
}
struct point_t {
int x, y, c, id;
point_t() = default;
point_t(int x, int y, int c = -1, int id = -1) : x(x), y(y), c(c), id(id) {}
inline bool operator<(const point_t &rh... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (a == 0LL) return b;
if (b == 0LL) return a;
return gcd(b, a % b);
}
struct point {
int x, y, col, ind;
};
bool cw(const point &a, const point &b, const point &c) {
return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct Point {
long long x, y;
Point() : x(), y() {}
Point(long long _x, long long _y) : x(_x), y(_y) {}
void scan() { scanf("%lld%lld", &x, &y); }
void print() { 42; }
Point operator+(const Point &a) const { return Point(x + a.x, y + a.y); }
Point operator-(c... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct pt {
long long x, y;
int id;
pt() {}
pt(long long a, long long b, int c = -1) : x(a), y(b), id(c) {}
};
pt operator+(pt a, pt b) { return pt(a.x + b.x, a.y + b.y); }
pt operator-(pt a, pt b) { return pt(a.x - b.x, a.y - b.y); }
long long dot(pt a, pt b) { ret... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void read(_T &f) {
f = 0;
_T fu = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') {
fu = -1;
}
c = getchar();
}
while (c >= '0' && c <= '9') {
f = (f << 3) + (f << 1) + (c & 15);
c = getch... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int n;
vector<pair<int, int> > ed;
class Point {
public:
int x, y, c, id;
Point() {}
Point(int x_, int y_, int c_, int id_) : x(x_), y(y_), c(c_), id(id_) {}
inline bool operator<(const Point &oth) const {
return make_pair(x, id) < make_p... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct point {
int x, y, op, id;
} p[1100];
int multi(point p1, point p2, point p0) {
int x1, y1, x2, y2;
x1 = p1.x - p0.x;
y1 = p1.y - p0.y;
x2 = p2.x - p0.x;
y2 = p2.y - p0.y;
return x1 * y2 - x2 * y1;
}
bool cmp(point p1, point p2) { return multi(p1, p2, p[... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
int dcmp(double x) { return (fabs(x) < eps) ? (0) : ((x < 0) ? (-1) : (1)); }
typedef class Point {
public:
double x, y;
int id;
Point(double x = 0.0, double y = 0.0, int id = 0) : x(x), y(y), id(id) {}
double length();
Point normal();
... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ans;
int n;
struct point {
int x, y;
point(int _x = 0, int _y = 0) {
x = _x;
y = _y;
}
bool operator<(const point &a) const { return atan2(y, x) < atan2(a.y, a.x); }
};
point operator+(const point &a, const point &b) {
return point(... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
struct pt {
long long x, y;
pt(long long x = 0, long long y = 0) : x(x), y(y) {}
pt operator-(const pt &o) const { return pt(x - o.x, y - o.y); }
long long cross(const pt &o) const { retur... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1100;
int n;
struct pt {
int x, y, c, id;
pt() {}
pt(int x, int y, int c) : x(x), y(y), c(c) {}
void in(int i) {
cin >> x >> y >> c;
id = i;
}
bool operator<(const pt &p) const {
return make_pair(x, y) < make_pair(p.x, p.y);
}
bool ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void read(_T &f) {
f = 0;
_T fu = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') {
fu = -1;
}
c = getchar();
}
while (c >= '0' && c <= '9') {
f = (f << 3) + (f << 1) + (c & 15);
c = getch... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(b... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (a == 0LL) return b;
if (b == 0LL) return a;
return gcd(b, a % b);
}
struct point {
int x, y, col, ind;
};
bool cw(const point &a, const point &b, const point &c) {
return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct UnionFindSet {
vector<int> f;
int n;
UnionFindSet(int n) : f(n) { clear(n); }
void clear(int n) {
this->n = n;
for (int i = 0; i < n; i++) {
f[i] = i;
}
}
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
void Union(int x, ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct point_t {
int x, y, id, color;
point_t() {}
point_t(int x, int y) : x(x), y(y) {}
bool operator<(const point_t &b) const {
return x < b.x || (x == b.x && y < b.y);
}
point_t operator-(const point_t &b) const {
return point_t(x - b.x, y - b.y);
}... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= ch == '-', ch = getchar();
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
const int N = 1005;
int n;
struct Point {
int x, y;... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
const int N = 10005, M = 1000000;
std::pair<int, int> operator-(std::pair<int, int> a, std::pair<int, int> b) {
return std::pair<int, int>(a.first - b.first, a.second - b.second);
}
long long operator*(std::pair<int, int> a, std::pair<int, int> b) {
return (long long)a.first * b.second - (l... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m;
struct P {
int x, y, c, id;
P() {}
P(int _x, int _y) {
x = _x;
y = _y;
}
P operator+(const P &a) const { return P(x + a.x, y + a.y); }
P operator-(const P &a) const { return P(x - a.x, y - a.y); }
long long operator*(const... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
c h, n;
};
template <class c>
rge<c> range(c h, c n) {
return rge<c>{h, n};
}
template <class c>
auto dud(c *r) -> decltype(cerr << *r);
template <class c>
char dud(...);
struct muu {
template <class c>
muu ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
const int N = 1005;
int sgn(long long x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
struct pt {
long long x, y;
};
pt operator-(const pt &a, const pt &b) { return {a.x - b.x, a.y - b.y}; }
long long cross(const pt &a, const pt &b) { return a.x * b.y - a.y * b.x; }
long lon... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int x[N], y[N], c[N], vt[N], st[N];
int n;
bool mark[N];
vector<pair<int, int>> res;
inline bool cmp(int i, int j) {
return (x[i] - x[vt[0]]) * (y[j] - y[vt[0]]) >
(x[j] - x[vt[0]]) * (y[i] - y[vt[0]]);
}
inline bool good(int i, int j, int k) ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int get() {
char ch;
while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
;
if (ch == '-') {
int s = 0;
while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
return -s;
}
int s = ch - '0';
while (ch = getchar(), ch >= '0' &... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using std::make_pair;
using std::pair;
using std::sort;
using std::swap;
const int N = 1e3 + 10;
int n, top, ans[N][2], cnt;
bool incv[N];
struct point {
int x, y, org;
bool color;
inline point(int a = 0, int b = 0) {
x = a;
y = b;
}
inline const bool operator==(const point &p... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, st[N], top;
struct po {
int x, y, c, id;
bool operator!=(const po& k) const { return x != k.x || y != k.y; }
} a[N];
long long cross(long long a, long long b, long long c, long long d) {
return a * d - b * c;
}
void sol(po k1, po k2, po k3, ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
int x[1024], y[1024], c[1024];
int pts[1024];
int chull[1024], tp;
int chull_size;
int ans_l[1024], ans_r[1024], ans_len = 0;
void add_edge(int u, int v) {
ans_l[ans_len] = u;
ans_r[ans_len] = v;
ans_len++;
}
void print_ans() {
printf("%d\n", ans_len);
for ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int RLEN = 1 << 18 | 1;
inline char nc() {
static char ibuf[RLEN], *ib, *ob;
(ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
return (ib == ob) ? -1 : *ib++;
}
inline int rd() {
char ch = nc();
int i = 0, f = 1;
while (!isdigit(ch)) {
if... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct Point {
long long x, y;
Point() : x(), y() {}
Point(long long _x, long long _y) : x(_x), y(_y) {}
void scan() { scanf("%lld%lld", &x, &y); }
void print() { 42; }
Point operator+(const Po... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, st[N], top;
struct po {
int x, y, c, id;
bool operator!=(const po& k) { return x != k.x || y != k.y; }
} a[N];
long long cross(long long a, long long b, long long c, long long d) {
return a * d - b * c;
}
void sol(po k1, po k2, po k3, vector... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, stk[1010], tp, ord[1010];
struct Vector {
int x, y;
Vector(int X = 0, int Y = 0) { x = X, y = Y; }
friend Vector operator+(const Vector &u, const Vector &v) {
return Vector(u.x + v.x, u.y + v.y);
}
friend Vector operator-(const Vector &u, const Vector &... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1010, inf = 0x3f3f3f3f;
struct point {
int x, y, col;
long long operator*(const point &rhs) const { return y * rhs.x - x * rhs.y; }
point operator-(const point &rhs) const { return {x - rhs.x, y - rhs.y}; }
bool operator<(const point &rhs) const {
... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using std::make_pair;
using std::pair;
using std::sort;
using std::swap;
const int N = 1e3 + 10;
int n, top, ans[N][2], cnt;
bool incv[N];
struct point {
int x, y, org;
bool color;
inline point(int a = 0, int b = 0) {
x = a;
y = b;
}
inline const bool operator==(const point &p... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const int NINF = 0x3f3f3f40;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0x3f3f3f3f3f3f3f40;
const int mxN = 2001;
int n;
vector<pair<i... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
struct point {
long long x, y;
int c, id;
point() {}
point(long long x, long long y, int c = -1, int id = -1)
: x(x), y(y), c(c), id(id) {}
inline point operator-() const { return point(... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
struct point {
int x, y, c, i;
point() {}
point(int x, int y, int c = 0, int i = 0) : x(x), y(y), c(c), i(i) {}
} pnt[maxn];
int det(const point &a, const point &b) { return a.x * b.y - a.y * b.x; }
bool operator==(const point &a, const poin... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
struct point {
long long x, y;
int c;
int n;
point() { x = y = c = 0; }
point(long long x, long long y) : x(x), y(y) {}
point operator-(point a) { return point(x - a.x, y - a.y); }
long long operator*(point a) { return x * a.y - y * ... | CPP |
1045_E. Ancient civilizations | On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restricti... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1005;
struct Point {
long long x, y;
int id, c;
inline Point(long long _x = 0, long long _y = 0) : x(_x), y(_y) {}
inline bool operator<(const Point &oth) const {
return x < oth.x || (x == oth.x && y < oth.y);
}
inline Point operator+(const Poi... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args)
{
FastReader reader = new FastReader();
PrintWriter writer = new PrintWriter(System.out);
int n = reader.nextInt();
int k = reader.nextInt();
MyList[] graph = new MyList[n];
for (int i=0; i<n; i++)
graph... | JAVA |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
public class P1068E
{
@SuppressWarnings("unchecked")
public static void main(String[] args)
{
FastScanner in = new FastScanner(System.in);... | JAVA |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e9;
const long long int INFF = 1e18;
const long long int M = 1e9 + 7;
long long int n, k;
vector<long long int> adj[100005];
long long int par[100005];
long long int dep[100005];
long long int mx = 0, mxNode = 0;
bool valid = 1;
void dfs(long long... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long int n, k, l;
vector<vector<long long int> > adj;
vector<long long int> level;
vector<long long int> d;
long long int distance(long long int x) {
long long int last = x;
for (long long int j = 1; j <= n; j++) d[j] = INT_MAX;
queue<long long int> q;
q.push(x... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
char _;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long fpow(long long b, long long exp, long long mod) {
if (exp == 0) return 1;
long long t = fpow(b, exp / 2, mod);
if (exp & 1) return t * t % mod * b % mod;
return t * t % ... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5;
int n, k;
struct Edge {
int to, next;
} edge[M * 2];
int head[M], now = 0, deg[M], cdeg[M], minh[M], maxh[M], sumh;
bool vis[M], flag = true;
int rootn, layer[M];
void adde(int u, int v) {
edge[++now].to = v;
edge[now].next = head[u];
head[u] ... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<vector<int>> graph;
int N, K;
int next(int v, int p) {
int n = 0;
if (graph[v][0] == p) {
n = 1;
}
return graph[v][n];
}
struct itframe {
int v;
int p;
vector<int> bestd;
int pc;
int i;
int u;
};
vector<int> rec(int v, in... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
#pragma warning(disable : 4018)
using namespace std;
namespace {
const int N = int(1e5) + 7;
int n;
vector<int> tr[N];
int deg[N], dep[N], dmax;
void dfs(int a, int p = 0, int d = 1) {
dep[a] = d;
for (int b : tr[a])
if (b != p) dfs(b, a, d + 1);
}
inline void fail() {
cout << "No"
... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
public class E {
public void solve(JS in, PrintWriter out) {
int n = in.nextInt();
int k = in.nextIn... | JAVA |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, k, root = -1;
vector<vector<int>> g;
bool findRoot(int v, int last, int depth) {
bool b = false;
for (int u : g[v])
if (u != last) b |= findRoot(u, v, depth + 1);
if (b && depth == k) root = v;
return b || depth == 2 * k;
}
bool check(int v, int last, int... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
void no() {
cout << "No";
exit(0);
}
vector<vector<int64_t> > v;
vector<int64_t> bfs(int64_t u) {
queue<int64_t> q;
vector<int64_t> ch(v.size(), 0);
q.push(u);
ch[u] = 1;
while (q.size()) {
int64_t t = q.front();
q.pop();
for (int64_t j = 0; j < v[... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
vector<set<int> > g;
vector<int> g1[500001];
vector<int> par;
vector<int> dist;
vector<int> deg;
vector<int> deg3;
void bfs(int sr) {
queue<int> q;
q.push(sr);
while (!q.empty()) {
int u = q.front();
q.pop();
bool fg = 0;
for (int v : g1[u]) {
if... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
static int N, K, deg[MAXN], vis[MAXN];
static vector<int> edge[MAXN];
int main() {
scanf("%d%d", &N, &K);
for (int i = 0, u, v; i < N - 1; i++) {
scanf("%d%d", &u, &v);
edge[u].push_back(v);
edge[v].push_back(u);
deg[u]++;
de... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 11;
int n, k;
vector<int> g[MAXN];
int deg[MAXN], d[MAXN], cnt[MAXN];
bool visited[MAXN];
int main() {
scanf("%d%d", &n, &k);
int u, v;
for (int i = 0; i < n - 1; i++) {
scanf("%d%d", &u, &v);
g[u].push_back(v);
g[v].push_back(u);
... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
public class E {
public static void main(String[] args) throws IOException {
try (Input input = new StandardInput(); PrintWriter writer = new PrintWriter(System.out)) {
... | JAVA |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> g;
int main() {
long long n, k;
cin >> n >> k;
g.resize(n);
for (int i = 0; i < n - 1; i++) {
long long x, y;
cin >> x >> y;
x--;
y--;
g[x].push_back(y);
g[y].push_back(x);
}
for (int i = 0; i < n; i++) {
if ... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline bool checkBit(int n, int pos) { return (bool)(n & (1 << pos)); }
inline int countBit(long long n) { return __builtin_popcountll(n); }
int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};
const int MAX = 100010;
vector<int> ed[MAX]... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 61);
const int MX = 3e5 + 9;
int n, sub[MX], depth[MX], blocked[MX], par[MX], sz[MX], dis[MX], vis[MX];
long long ans = 0;
vector<int> v[MX];
void dfs(int x, int p, int d = 0) {
par[x] = p;
dis[x] = d;
for (auto pp : v[x]) {
if (pp ==... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct edge_t {
int v, w, next_id;
edge_t(int _v, int _w, int _next_id) : v(_v), w(_w), next_id(_next_id) {}
};
void add_edge(vector<int>& LE, vector<edge_t>& E, int v, int w) {
E.push_back(edge_t(v, w, LE[v]));
LE[v] = E.size() - 1;
}
bool multihedgehog(int n, vect... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const long long Inf = 9223372036854775807ll;
const string file = "";
int n, m, g[100005], g2[100005], c[100005], d[100005];
vector<int> v[100005];
queue<int> q;
bool ok[100005];
void dfs(int x, int pred = 0) {
ok[x] = 0;
d[x] = d[pred] + 1;
... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class Multihedgehog {
int[] dep, par;
int[][] G;
void solve() {
int n = in.n... | JAVA |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | from collections import deque
n, k = list(map(int, input().split()))
G = [set() for _ in range(n + 1)]
q, nq = deque(), deque()
for _ in range(n - 1):
u, v = list(map(int, input().split()))
G[u].add(v)
G[v].add(u)
for u in range(1, n + 1):
if len(G[u]) == 1:
q.append(u)
step = 0
removed = ... | PYTHON3 |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
vector<int> dis[100002];
vector<int> v[100002];
int don[100002] = {0};
int ans = 0;
int dfs(int r) {
int i;
int maxx = 0;
don[r] = 1;
for (i = 0; i < v[r].size(); i++) {
if (don[v[r][i]] == 0) {
int d = dfs(v[r][i]);
maxx = max(maxx, d);
dis[r]... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > mv;
int cen, k;
int bus(int cu, int fa) {
int i, s = mv[cu].size(), b, ma = 0;
for (i = 0; i < s; i++)
if (mv[cu][i] != fa) {
b = bus(mv[cu][i], cu);
if (b == k) cen = cu;
if (b > ma) ma = b;
}
return ma + 1;
}
bool che(i... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<vector<int>> graph;
int N, K;
int next(int v, int p) {
int n = 0;
if (graph[v][0] == p) {
n = 1;
}
return graph[v][n];
}
struct itframe {
int v;
int p;
vector<int> bestd;
int pc;
int i;
int u;
};
vector<int> rec(int v, in... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> adj[(int)1e5 + 7];
int vis[(int)1e5 + 7];
int deg[(int)1e5 + 7];
int cnt[(int)1e5 + 7];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
;
scanf("%d %d", &n, &k);
for (int i = 1; i <= n - 1; i++) {
int u, v;
scanf("%d... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T> >;
const int lim = 1e5 + 5;
long long n, k, u, v, cn;
map<long long, long long> deg;
set<long long> adj[lim];
int main() {
cin >> n >> k;
for (int i = 1; i <= n - 1; i++) {
cin >> ... | CPP |
1068_E. Multihedgehog | Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9, maxn = 1e5 + 213, N = 4e6 + 20, mod = 998244353;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
const double eps = 1e-5, pi = 3.14159265359;
const pair<unsigned long long, unsigned long long> base = make_pair(1171, 3307);
const long long INF = 1e... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.