prompt string | response string |
|---|---|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
map<unsigned long long int, unsigned long long int> m;
int main() {
unsigned long long int n;
unsigned long long int k;
unsigned long long int sol;
cin >> n;
m[1] = n;
unsigned long long int a, b;
auto it = m.begin();
while (it != m.end()) {
a = it->firs... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | var n = parseInt(readline());
//Sol:
var r = [];
//func
var step = function( ){
//Modifica r
// Agrego un Slime
r.push(1);
//Calculo los cambios automaticos
if(r.length>1){
while(r[r.length-1]===r[r.length-2]){
r.pop();
r[r.length-1]++;
}
}
};
while(n-- > 0){
step();
}
r.map((s) => {write(s... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Mai... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | '''input
7
'''
n = input()
s = ''
res = []
for i in xrange(17, -1, -1):
# print n, pow(2, i), i
if pow(2, i) <= n:
n -= pow(2, i)
res.append(i + 1)
print ' '.join(['%s' % x for x in res]) |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
v = []
for i in range(n):
v.append(1)
while len(v) >= 2 and v[-2] == v[-1]:
x = v.pop()
v.pop()
v.append(x+1)
print(' '.join([str(x) for x in v]))
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class abc{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int n=in.nextInt();
while(n>0){
int x=0,i=0;
while(x<=n){
x=(int)Math.pow(2,i);
i++;
}
i=i-2;
x=(int)Math.pow(2,i);
... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n=bin(int(input()))[2:]
for i in range(len(n)):
if int(n[i])==1:
print(len(n)-i, end=' ') |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
vector<long long> a;
int main() {
long long n;
cin >> n;
for (long long i = 0; i < n; i++) {
a.push_back(1);
while (a.size() > 1 && a[a.size() - 1] == a[a.size() - 2]) {
long long x = a[a.size()];
a.pop_back();
a[a.size() - 1]++;
}
}
... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | a=[0]
for _ in range(int(input())):
a+=[1]
while a[-2]==a[-1]:
a.pop()
a[-1]+=1
print(*a[1:])
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
template <class T>
inline T _abs(T n) {
return ((n) < 0 ? -(n) : (n));
}
template <class T>
inline T _max(T a, T b) {
return (!((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _min... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | # https://codeforces.com/problemset/problem/618/A
n = int(input())
stack = [1]
for i in range(1, n):
if stack[-1] == 1:
stack[-1] = 2
while True:
if len(stack) >= 2:
last = stack.pop()
if stack[-1] == last:
stack[-1] = last + 1
... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
int main() {
int two_pow[17];
int max_pow;
int i;
for (i = 0; i <= 16; i++) {
two_pow[i] = pow(2, i);
}
int n, no;
cin >> n;
no = n;
for (i = 16; i >= 0; i--) {
if (two_pow[i] <= n) {
max_pow = i;
break;
}
}
while (no != 0) {
... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | def main():
n = int(input())
a = []
for i in range(n):
a.append(1)
while len(a) > 1 and a[-1] == a[-2]:
a.pop()
a[-1] += 1
print(' '.join(str(i) for i in a))
main() |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
vector<int> a;
int main() {
int n;
cin >> n;
for (int i = 0; true; i++) {
a.push_back(n % 2);
n /= 2;
if (n == 0) {
break;
}
}
for (int i = a.size() - 1; i >= 0; i--) {
if (a[i] == 1) {
cout << i + 1 << " ";
}
}
}
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
int main() {
int n, i, s, a[100];
while (~scanf("%d", &n)) {
s = 1;
for (;; s *= 2) {
if (s > n) break;
}
s /= 2;
for (i = 0; s != 0; i++) {
if (n >= s) {
a[i] = 1;
n = n - s;
s /= 2;
} else {
a[i] = 0;
s = s / 2;... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
v.push_back(1);
while ((int)v.size() > 1) {
int sz = v.size();
if (v[sz - 1] == v[sz - 2]) {
v.pop_back()... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws IOException {
br = new BufferedReader( new InputStreamRea... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
l = [1]
for i in range(1,n):
l.append(1)
for j in range(len(l)):
if len(l)>1 and l[-1]==l[-2] :
l[-2]=l[-2]+1
l.pop(-1)
else:
break
print(*l) |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | N = input()
List=[1 for i in range(N)]
Ans=[]
for i in range(N):
Ans.append(1)
if len(Ans)>=2:
while(1):
if len(Ans)<2:
break
if Ans[-1]==Ans[-2]:
Ans[-2] += 1
del Ans[-1]
else:
break
ans = ""
for i in Ans:
ans += str(i)+" "
print ans[:-1]
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
L = []
for i in range(n):
L.append(1)
while len(L) >= 2 and L[-1] == L[-2]:
L.pop()
L[-1] += 1
print(' '.join(str(i) for i in L))
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | from math import *
from Queue import *
from sys import *
n = int(raw_input())
res = [0 for i in range(n+1)]
p = 0
for i in range(n):
res[p] = 1
while (p-1 >= 0) and (res[p-1] == res[p]):
res[p] = 0
res[p-1] += 1
p -= 1
p += 1
p = 0
while res[p] != 0:
print(res[p]),
p += 1... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Collections;
import java.util.L... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
vector<int> v;
cin >> n;
int x = 1;
int i = 1;
if (n == 1)
cout << "1";
else {
bool dhukse = false;
while (x <= n) {
x *= 2;
if (x == n) {
cout << i + 1 << endl;
dhukse = true;
break;
} ... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | s = input()
k = [0]
for i in xrange(s):
k.append(1)
while len(k) > 1 and k[-1] == k[-2]:
k.pop()
k[-1] = k[-1] + 1
for i in k[1: ]:
print i, |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n=int(input())
d=[]
for i in range(n):
d.append(1)
if len(d)>=2:
while(d[-1]==d[-2]):
if d[-1]==d[-2]:
r=d[-1]+1
d.append(r)
d.pop(-2)
d.pop(-2)
if len(d)<2:
break
print(*d)
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
a = [2 ** i for i in range(20)]
ans = []
#print(a)
while n > 0:
for i in range(19, -1, -1):
if n >= a[i]:
print(i + 1, end=' ')
n -= a[i]
break
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.util.*;
public class slimeCombining
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int n;
ArrayList<Integer> al = new ArrayList<Integer>();
n=in.nextInt();
al.add(1);
for(int i=(n-1); i>0; i--)
{
al.add(1);
if(al.size()>1... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
k = bin(n)[2::]
mas = []
l = len(k)
for a in range(l):
if k[a] == "1":
mas.append(str(l - a))
print(" ".join(mas)) |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
struct nout {
template <class A>
const nout& operator<<(const A& a) const {
return *this;
}
} nout;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long N;
cin >> N;
bool out = false;
for (long long i__count = (20), i = i__count, i__goal = (0... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
void reshenie() {
int n;
cin >> n;
vector<int> bin;
while (n) {
bin.push_back(n % 2);
n /= 2;
}
for (int i = bin.size() - 1; i >= 0; --i) {
if (bin[i]) {
cout << i + 1 << ' ';
}
}
cout << endl;
}
int main() {
reshenie();
return 1 - ... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is a... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int next = 1;
vector<int> ans;
while (n) {
if (n & 1) ans.push_back(next);
next++;
n >>= 1;
}
for (auto i = ans.rbegin(); i != ans.rend(); ++i) cout << *i << " ";
return 0;
}
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import sys
import math
def good(n):
while n%2==0:
n/=2
if n==1:
return True
else :
return False
arr={1:[1],}
t=2
while t<100005:
arr[t]=[]
if good(t):
arr[t]=[int(math.log2(t))+1]
else:
tmp=2**(int(math.log2(t)))
arr[t]=arr[tmp]+arr[t-tmp]
t=t+1
for line in sys.stdin:
n=line.split()
a=int(n[0])
... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.io.*;
import static java.lang.Math.*;
import java.util.*;
import java.util.function.*;
import java.lang.*;
public class Main {
final static boolean debug = false;
final static String fileName = "";
final static boolean useFiles = false;
public static void main(String[] args) throws FileNot... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n=int(input())
l=[2**i for i in range(20)]
while n>0:
if n in l:
i=l.index(n)
print(i+1)
n=0
else:
l.append(n)
l.sort()
i=l.index(n)
print(i,end=" ")
l.remove(n)
n-=2**(i-1) |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | L=[1];
for i in range(2,int(input())+1):
L.append(1);
a=len(L)-1;
while(a>0):
if L[a]==L[a-1]:
L[a-1]=L[a]+1;
L[a:a+1]=[];
else:
break
a=len(L)-1;
if a==0:
break
for i in L:
print(i,end=' ') |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = input()
res = []
for x in xrange(30, -1, -1):
if (n & (1 << x)):
res += [x+1]
print " ".join(map(str, res)) |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import math
def rlist(t):
return map(t, raw_input().split())
def read_int_list():
return rlist(int)
x = input()
ans = []
while x:
pow = 1
i = 0
while pow <= x:
pow *= 2
i += 1
x -= 2**(i-1)
ans.append(str(i))
print " ".join(ans) |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Stack;
import java.util.StringTokenizer;
public class A {
static void solve(InputReader in, PrintWriter out) {
int N = i... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #!/usr/bin/env python
import math, sys, collections, heapq
cache = [1]
for i in range(20):
cache.append(cache[-1]*2)
def twotopow(i):
for j in range(19):
if cache[j] <= i < cache[j+1]: return j
return -1
n = int(raw_input())
res = []
while n:
r = twotopow(n)
res.append(r+1)
n %= 2**r
... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
k = []
for x in range(n):
k.append(1)
while len(k) >= 2 and k[-2] == k[-1]:
k.pop()
k[-1] += 1
print(" ".join(map(str, k))) |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 30; ~i; i--)
if (n >> i & 1) cout << i + 1 << ' ';
return 0;
}
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
ans = list()
for i in range(n):
ans.append(1)
while len(ans) > 1 and ans[-1] == ans[-2]:
t = ans.pop()
ans[-1] = t + 1
print(' '.join(map(str, ans)))
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
s = str(bin(n))[2:]
for i in range(len(s)):
if s[i] == '1':
print(len(s) - i, end=' ') |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int maxn = 100010;
const double eps = 1e-8;
int a[maxn], sz = 0;
int main() {
int n;
scanf("%d", &n);
a[sz++] = 1;
n--;
while (n--) {
a[sz++] = 1;
while (sz >= 2 and a[sz - 1] == a[sz - ... |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | n = int(input())
i = 1;
arr = [];
while True:
if (n & 1 == 1):
arr.append(i);
n >>= 1;
i = i + 1;
if ( n == 0 ):
break;
outstr = "";
for elm in arr:
outstr = str(elm) + " " + outstr;
print(outstr); |
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, i, j, p, ans[1003];
;
cin >> n;
j = 1;
p = n;
while (p > 0) {
int k = p % 2;
ans[j++] = k;
p = p / 2;
}
for (i = j - 1; i >= 1; i--) {
if (ans[i] == 1) {
cout << i << " ";
}
}
return 0;
}
|
Problem: Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.
You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right... | import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n=0;
n=scanner.nextInt();
ArrayList arrayList = new ArrayList();
while(n>0){
arrayList.add(1);
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rread(T& num) {
num = 0;
T f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') num = num * 10 + ch - '0', ch = getchar();
num *= f;
}
inline i... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.Pri... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
public class PogChamp {
public static void main(String[] args) {
new PogChamp().bUrself(Syst... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
int read() {
int ans = 0, f = 1;
char c = getchar();
while (c > '9' || c < '0') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
ans = ans * 10 + c - '0';
c = getchar();
}
return ans * f;
}
const int N = 2e5 + 5;
int n, d... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int M = 200001;
struct Edge {
int u, v;
int ot(int x) { return u ^ x ^ v; }
} e[M];
vector<vector<int>> adj;
bool done[M];
int deg[M];
int num[M];
const int N = 200001;
vector<int> sol[N];
void dfs(int u, int p = -1, int n = -1) {
int cur = 1;
for (auto el : a... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | import java.io.*;
import java.math.*;
import java.util.*;
import static java.lang.System.out;
public class solver {
public static List<pair>[] g;
public static List<Integer>[] arr;
static void dfs(int from, int v, int day) throws Exception{
int d = 0; if(d == day) ++d;
for(pair i : g[v]){
if... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cout.write(nam... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int LEN = 200200;
vector<int> ed[LEN];
vector<pair<int, int> > res[LEN];
int n, a, b, use[LEN], k;
map<int, int> q[LEN];
void dfs(int v, int d) {
int u, k = 1;
use[v] = 1;
for (int i = 0; i < ed[v].size(); i++) {
u = ed[v][i];
if (use[u]) continue;
i... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
bool used[MAXN];
int c[MAXN];
int father[MAXN];
vector<pair<int, int> > color[MAXN];
vector<int> g[MAXN];
map<pair<int, int>, int> e;
int res;
void dfs(int v, int pr, int num) {
father[v] = pr;
used[v] = 1;
int i = 0;
if (v != 1) {
if (c... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > G[200100];
vector<int> rs[200100];
void dfs(int x, int y, int p) {
int pos = 0;
int n = G[x].size();
for (int i = 0; i < n; ++i) {
int to = G[x][i].first;
if (to == y) continue;
if (pos == p) pos++;
rs[pos].push_back(G[x][i].sec... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9;
const double PI = 3.1415926535897932384626433832795;
int n, st[200007];
vector<pair<int, int>> v[200007];
vector<int> ans[200007];
void deep(int c, int day) {
int i, now = 0;
if (day == 0) now++;
st[c] = 1;
for (i = 0; i < v[c].size();... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
std::vector<std::vector<int>> g;
std::vector<std::vector<int>> rn;
std::vector<std::pair<int, int>> d;
std::vector<std::vector<int>> plan;
void calc_dp(int v, int p) {
int mx = 0;
int children = 0;
for (int n : g[v]) {
if (n != p) {
calc_dp(n, v);
mx =... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
map<pair<int, int>, int> MAP;
map<int, vector<int> > colors;
int mx;
void dfs(int v, int c, int p = -1) {
int cur(0);
for (int i(0), _l((int)(((int)g[v].size())) - 1); i <= _l; ++i) {
int to(g[v][i]);
if (to == p) continue;
int k(MAP[... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | // practice with kaiboy
import java.io.*;
import java.util.*;
public class CF638C extends PrintWriter {
CF638C() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF638C o = new CF638C(); o.main(); o.flush();
}
int n;
int[] eo; int[][] eh;
int[] ij;
void appen... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v[200200];
vector<int> ans[200200];
bool vis[200200];
int k = 0;
void dfs(int curr, int c) {
vis[curr] = true;
int x = 0;
for (auto child : v[curr]) {
if (!vis[child.first]) {
if (++x == c) x++;
ans[x].push_back(child.second);
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
vector<pair<int, int> > E[maxn];
vector<int> ans[maxn];
int tot = 0;
void dfs(int x, int fa, int te) {
int now = 0;
for (int i = 0; i < E[x].size(); i++) {
int v = E[x][i].first;
if (v == fa) continue;
now++;
if (now == te) now+... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | import java.io.*;
import java.util.*;
public final class road_improvement
{
static FastScanner sc=new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
static PrintWriter out=new PrintWriter(System.out);
static ArrayList<Node>[] al;
static ArrayList<Integer>[] days;
static int max=1;
static... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
inline int next_int() {
int32_t x;
scanf("%d", &x);
return x;
}
const int maxn = 2e5 + 10;
vector<pair<int, int> > g[maxn];
int res[maxn];
int ans;
inline void dfs(int node, int father = -1, int preCol = -1) {
int curCol = 0;
for (auto u : g[node]) {
if (u.fir... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<int> neigh[200005];
int ptr[200005];
vector<int> children[200005];
int order[200005];
int par[200005];
int get(int v) {
if (par[v] == v) return v;
return par[v] = get(par[v]);
}
void del(int v) { par[get(v)] = par[get(v + 1)]; }
int N;
void init() {
vector<bool... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<int> v[200200], ans[200200];
int color[200200], a[200200], b[200200], n, pat, p[200200], m, j;
void dfs(int x) {
int m = v[x].size(), i, curr = 0;
for (i = 0; i < m; i++) {
if (v[x][i] == 1) continue;
if (color[v[x][i]] != 0) continue;
p[v[x][i]] = x;... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
unordered_map<int, vector<pair<int, int> > > ans;
vector<bool> used;
void rec(vector<vector<int> > &v, int pos, int color) {
int act_color = 0;
for (int act : v[pos])
if (!used[act]) {
act_color += (act_color == color);
used[act] = true;
ans[act_co... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
const int INF = 1e9;
const double cp = 2 * asin(1.0);
const double eps = 1e-9;
const long long mod = 1000000007;
using namespace std;
int n;
vector<vector<pair<int, int> > > g;
int used[200020];
int res;
vector<int> ans[200020];
void d... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[200005];
vector<vector<int> > ans;
int n;
bool u[200005];
void dfs(int v, int w) {
int it = 0;
if (it == w) it++;
for (int i = 0; i < g[v].size(); i++)
if (!u[g[v][i].second]) {
ans[it].push_back(g[v][i].second);
u[g[v][i].sec... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int>> v[200007];
vector<long long int> ans[200007];
long long int cc = 0;
void dfs(long long int x, long long int y, long long int z) {
long long int c = 0;
for (long long int i = 0; i < v[x].size(); i++) {
long long int val = v[... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int32_t> >;
using Plan = map<int32_t, int32_t>;
using Roads = map<pair<int32_t, int32_t>, int32_t>;
Graph G;
Plan plan;
Roads roads;
void dfs_path(int32_t curr, int32_t last, int32_t pair_day) {
int32_t day = 0;
for (auto to : G[curr]) {
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
struct edge {
int v, id, day;
};
vector<edge> g[200100];
vector<int> d[200100];
bool used[200200];
int max_day = 0;
void dfs(int v, int pr_day) {
int day = 1;
for (int i = 0; i < g[v].size(); i++) {
if (day == pr_day) day++;
if (!used[g[v][i].v]) {
used[... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
return x * x;
}
template <class T>
T gcd(T a, T b) {
return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
inline T bigmod(T p, T e, T M) {
if (e == 0) retur... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
int stat[200010];
int fixe[200010];
int loop;
int coun;
vector<pair<int, int>> grafh[200010];
vector<int> day[200010];
int main() {
int m;
scanf("%d", &m);
m--;
for (int i = 0; i < m; i++) {
int a, b;
scanf("%d %d", &a, &b);
grafh[a].push_back({b, i + 1}... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g(2e5 + 10), d;
map<pair<int, int>, int> mp;
queue<pair<int, int> > q;
int main() {
ios_base::sync_with_stdio();
int n;
cin >> n;
int ans = 0;
for (int i = 0; i < n - 1; i++) {
int x, y;
scanf("%d%d", &x, &y);
g[x].push_back(y);
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 1000;
vector<pair<int, int> > g[N];
vector<int> ans[N];
int n, sum, tot, u, v;
void dfs(int x, int fa, int son_t) {
int l = g[x].size();
int sum = 0;
for (int i = 0; i < l; i++) {
int v = g[x][i].first;
if (v == fa) continue;
sum++;
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 62) - 1;
const long long MOD = 1e9 + 7;
const int MAX = 2 * 1e9 + 10;
const int N = 2e5 + 5;
using namespace std;
int bPow(int a, int b) {
int res = 1;
while (b) {
if (b & 1ll) {
res = 1ll * res * a % MOD;
}
b >>= 1;
a... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> vi;
vector<vector<int>> days;
long long result;
long long vis[10000000];
void dfs(int node, int lastday) {
if (vis[node]) return;
vis[node] = 1;
long long day = 1;
for (int nodes = 0; nodes < vi[node].size(); nodes++) {
int n = vi[... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
int n, x, y, zc;
vector<pair<int, int> > a[200020];
vector<int> z[200020];
void dfs(int x, int y, int c) {
int j = 0;
for (pair<int, int> i : a[x]) {
if (i.first != y) {
++j;
if (j == c) {
++j;
}
z[j].push_back(i.second);
zc = m... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 55;
vector<pair<int, int>> v[N];
vector<int> days[N];
bool visited[N];
int mx = 0;
void dfs(int s, int m) {
int l = 1;
if (visited[s]) return;
visited[s] = 1;
for (auto x : v[s]) {
if (visited[x.first]) continue;
if (m == l) l++;
days... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
const double PI = 3.141592653589793;
using namespace std;
std::vector<int> v[200500];
std::vector<int> ans[200500];
int was[200500];
int st[200500];
map<std::pair<int, int>, int> m;
vector<std::pair<int, int> > r;
void dfs(int x, int c) {
was[x] = 1;
int cnt = 1;
for (int y : v[x]) {
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ed[(int)(200005)];
vector<int> ans[(int)(200005)];
int n, cvp;
void dfs(int cur, int back, int back_ed) {
int top = 0;
for (auto i : ed[cur]) {
if (i.first == back) continue;
top++;
if (top == back_ed) top++;
cvp = max(cvp, top);
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double eps = (double)1e-8;
const int mod = (int)1000000007;
const int maxn = (int)2 * 1e5 + 5;
int n, x, y, mx;
int u[maxn], pr[maxn];
pair<int, int> t[maxn];
vector<pair<int, int> > a[maxn];
vector<int> ans;
list<int> q;
list<int>::iterator ... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 200002;
struct NODE {
int v;
int id;
};
vector<NODE> G[MAXN];
vector<int> res[MAXN];
int n, ans = 0;
void DFS(int u, int p, int pcnt) {
int cnt = 0;
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i].v, id = G[u][i].id;
if (v != p) {
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class Codeforces {
ArrayList<Pair>[]graph;
ArrayList<Integer>[]days;
public void dfs(int from,int to,int day){
int d = 0;
if(day == d)d++;
for(Pair p:graph[to]){
if(p.first == from)continue;
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
vector<pair<int, int> > e[MAXN];
vector<int> ans[MAXN];
void fixRoads(int u, int p, int c) {
int i, edgeIndex, v, d = 0;
for (auto it : e[u]) {
v = it.first;
edgeIndex = it.second;
if (v != p) {
if (d < c) {
i = d;
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
vector<int> g[200005];
int n;
vector<int> day[200005];
vector<bool> vis(200005, 0);
map<pair<int, int>, int> mp;
int max_cnt = 0;
void dfs(int node, int cnt) {
vis[node] = 1;
max_cnt = max(max_cn... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
long long n, a;
const long long MAXN = 200000;
vector<pair<long long, long long> > graph[MAXN];
vector<long long> times[MAXN];
long long maxD = 0;
void dfs(long long v, long long p, long long t) {
long long timer = 0;
long long deg = (p == -1 ? 0 : 1);
for (long long ... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
long long bfs(long long n, vector<vector<pair<long long, long long> > > &g,
vector<vector<long long> > &path) {
queue<long long> q;
queue<long long> qs;
vector<bool> used(n + 1);
long long s;
s = 1;
long long k;
q.push(s);
qs.push(0);
qs.push... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
int useday[N];
vector<int> g[N];
int a[N], b[N], fl[N];
int getnxt(int t, int v) {
if (t + 1 != useday[v]) return t + 1;
return t + 2;
}
void dfs(int v, int p) {
int t = getnxt(0, v);
for (int i : g[v]) {
int u = a[i] + b[i] - v;
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
std::vector<pair<int, int> > adjList[200010];
int up_time[200010];
std::vector<int> ans_list[200010];
int U[200010], V[200010];
int ans = 0;
void dfs(int curr, int par) {
std::vector<pair<int, int> >::iterator it;
pair<int, int> temp;
int upd = 1;
it = adjList[curr]... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int MAX = 2000005;
int n, x, y, mxday;
map<pair<int, int>, int> mp2;
vector<vector<int> > adj(MAX);
vector<pair<int, int> > edge;
void dfs(int node, int parent, int pDay) {
int cnt = 1;
for (int i(0); i < int(adj[node].size()); i++) {
int ch = adj[node][i];
... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
struct Edge {
int v, nxt;
int id;
Edge() {}
Edge(int vv, int next) {
v = vv;
nxt = next;
}
} edge[N << 1];
int idx;
int head[N];
void addEdge(int u, int v, int id) {
edge[++idx] = Edge(v, head[u]);
edge[idx].id = id;
head[u] ... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > a, b, ans;
int i, j, n, mx;
int x, y, used[200005];
void paint(int v, int parent_color) {
used[v] = 1;
int cur_color = 0;
for (int i = 0; i < a[v].size(); i++) {
if (!used[a[v][i]]) {
if (cur_color == parent_color) cur_color++;
ans... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > V[200000];
int colors[200000];
int w[200000];
list<int> q;
map<int, vector<int> > answ;
void DFS() {
while (!q.empty()) {
int index = q.front();
q.pop_front();
colors[index] = 1;
vector<pair<int, int> >::iterator it = V[index].begin... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > graph[200001];
vector<int> ans[200001];
int vis[200001] = {0}, v1;
void dfs(int u, int prev) {
vis[u] = 1;
int v, ind, k = 1;
for (int j = 0; j < graph[u].size(); j++) {
v = graph[u][j].first;
ind = graph[u][j].second;
if (!vis[v]) ... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 400000;
const int MAXM = 200000;
const int INF = 1000000010;
const long long int MOD = 1000000007;
const long long int P = 31;
const double EPS = 1e-6;
int N;
vector<pair<int, int> > e;
bool rep[MAXN] = {false};
set<int> g[MAXN];
vector<int> gd[MAXN];
set<i... |
Problem: In Berland there are n cities and n - 1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads.
In each city there is exactly one repair brigade. To repair some road, you need two teams based in the cities connected by the road to wor... | #include <bits/stdc++.h>
using namespace std;
int a[int(1e6 + 6)], i, m, ans, k, l, j, q, x, y, n, ma, mi;
set<int> s;
vector<int> v[int(1e6 + 6)];
vector<int> g[int(1e6 + 6)];
vector<int> an[int(1e6 + 6)];
void go(int x, int p, int raf) {
int beg = 0;
for (int i = 0; i < v[x].size(); i++) {
int to = v[x][i];
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.