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 |
|---|---|---|---|---|---|
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
long long modd = 998244353;
vector<bool> isprime(N);
vector<int> primes;
void seive() {
isprime[0] = false;
isprime[1] = false;
for (int i = 2; i <= 1e6; i++) {
isprime[i] = true;
}
for (int i = 2; i * i <= 1e6; i++) {
if (isprime[i]... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | n, k = [int(x) for x in raw_input().split()]
def get(s):
global k
s1 = s[::-1]
previ = 0
for p in xrange(k - 1):
for i in xrange(previ, len(s1)):
if s1[i] in ['a', 'e', 'i', 'o', 'u']:
s1 = s1[:i] + chr(ord(s1[i])-ord('a')+ord('A')) + s1[i+1:]
previ =... | PYTHON |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | def isRhyme(x, y, k):
lx, ly = len(x), len(y)
cnt = 0
for i, j in zip(xrange(lx - 1, -1, -1), xrange(ly - 1, -1, -1)):
if x[i] != y[j]:
return False
if x[i] in 'aeiou':
cnt += 1
if cnt == k:
return True
return False
n, k = map(int, raw_input()... | PYTHON |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
const string IN_NAME = "input.txt";
const string OUT_NAME = "output.txt";
template <class T>
T abs(T &x) {
return ((x) >= 0) ? (x) : (-(x));
}
template <class T>
T sqr(T &x) {
return (x) * (x);
}
template <class T>
T min(T &a,... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.uti... | JAVA |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | n,k=map(int,raw_input().split())
def f(s):
s=s[::-1]
o=0
for i in range(len(s)):
if s[i] in 'aeiou':
o+=1
if o==k:
return s[:i+1][::-1]
print 'NO'
exit()
A=[]
E=[]
for i in range(n):
B=[ raw_input() for i in range(4) ]
A.append(B)
for x in A:
D=[]
... | PYTHON |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | n, k = map(int, raw_input().split())
t = 0
s = 'aeiou'
for i in range(n):
a = []
for j in range(4):
a.append(raw_input())
cnt = 0
for g in range(len(a[j]) - 1, -1, -1):
if a[j][g] in s: cnt += 1
if cnt == k:
a[j... | PYTHON |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author codeKNIGHT
*/
public class Main {
public static void main(String[] args) {... | JAVA |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double Pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
int num[3000];
int n, k;
struct st {
char str[4][10010];
} poem[2510];
bool is(char ch) {
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
return true;
else
re... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class ProblemC {
public static boolean[] vowel = new boolean[512];
public static String Kth(String line, int k) {
int len = line.length();
for (int i = len-1 ; i >... | JAVA |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
int IntMaxVal = (int)1e20;
int IntMinVal = (int)-1e20;
long long LongMaxVal = (long long)1e20;
long long LongMinVal = (long long)-1e20;
using namespace std;
template <typename T>
struct argument_type;
template <typename T, typename U>
struct argument_type<T(U)> {};
template <typename T1, typena... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const char letters[] = {'a', 'e', 'i', 'o', 'u'};
const char res[][5] = {"aabb", "abab", "abba", "aaaa"};
const int MAXN = 2510;
const int MAXM = 10010;
int n, k;
char s[4][MAXM];
inline int ISV(char c) {
for (int i = 0; i < 5; ++i)
if (c == letters[i]) return 1;
re... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #!/usr/bin/env python
"""(c) gorlum0 [at] gmail.com"""
import itertools as it
from sys import stdin
vowels = 'aeiou'
types_rhymes = 'NO abba abab # aabb # # aaaa'.split()
def suffix(k, w):
for i in xrange(len(w)-1, -1, -1):
if w[i] in vowels:
k -= 1
if not k: break
return w[i:] ... | PYTHON |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;
public class C
{
BufferedReader in;
PrintStream out;
StringTokenizer tok;
public C() throws NumberFormatException, IOException
{
in = new Buffe... | JAVA |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #!/usr/bin/python
line = raw_input().strip().split()
num_quar = int(line[0])
k = int(line[1])
poem = []
scheme = "aaaa"
vowels = "aeiou"
for i in range(num_quar):
end = []
for j in range(4):
line = raw_input().strip()
poem = line[::-1]
temp = 0
id = 0
for char in poem:
id+=1
if char in vowels:
te... | PYTHON |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long vow(char c) {
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
return 1;
} else
return 0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, k, j, i;
set<string> s;
string def1 = "!#1", def2 = "!#2", d... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const string none = "george.ioanisyan.1996";
int n, k;
string first, second, third, fourth;
bool vowel(char ch) {
return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
string getKstring(string str) {
int i, qi = 0;
for (i = str.size() - 1; i >= 0; ... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
int diru[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dirv[] = {-1, 0, 1, -1, 1, -1, 0, 1};
using namespace std;
template <class T>
T sq(T n) {
return n * n;
}
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,... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | // Main Code at the Bottom
import java.util.*;
import java.io.*;
public class Main{
//Fast IO class
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
boolean env=System.getProperty("ONLINE_JUDGE") != null;
if(!env) {
try {
... | JAVA |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, nk;
char s[4][10005];
int f[4][4];
int sce[4];
void cal(int i) {
if (i == 0) puts("aaaa");
if (i == 1) puts("aabb");
if (i == 2) puts("abab");
if (i == 3) puts("abba");
}
int main() {
scanf("%d%d", &n, &nk);
sce[0] = sce[1] = sce[2] = sce[3] = 1;
for (i... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, K;
string res[] = {"aabb", "abab", "abba", "aaaa"};
bool rhymes(string a, string b) {
string ta = "!!!", tb = "###";
int k = K;
for (int i = a.length() - 1; i >= 0; i--) {
if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u')
k-... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #from bisect import bisect_left as bl #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br #c++ upperbound br(array,element)
#from __future__ import print_function, division #while using python2
# from itertools import accumulate
# from collections import defaultdict,... | PYTHON3 |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[5000];
int k;
int no = 0;
string last(string s) {
int w = 0;
int i = (int)s.size() - 1;
while (i >= 0 && w != k) {
if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' ||
s[i] == 'u') {
w++;
}
i--;
}
string res;
if (w == k... | CPP |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | n, k = map(int, input().split())
def get_suffix(line):
position = 0
for _ in range(k):
position -= 1
while -position <= len(line) and line[position] not in 'aeiou':
position -= 1
if -position > len(line):
return ''
return line[position:]
common_rhym... | PYTHON3 |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | import static java.lang.Math.*;
import java.util.*;
import java.io.*;
public class C {
public void solve() throws Exception {
int n = nextInt(), kk = nextInt();
boolean aabb=true, abab=true, abba=true;
for (int i=0; i<n; ++i) {
String[] q = new String[4];
i... | JAVA |
139_C. Literature Lesson | Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, k, i, j, x, l;
bool b[4] = {true, true, true, true};
string s[4], a[4], ans[4] = {"aabb", "abab", "abba", "aaaa"};
int main() {
cin >> n >> k;
for (j = 0; j < n; j++) {
for (i = 0; i < 4; i++) {
cin >> s[i];
a[i] = "";
}
for (l = 0; l < 4;... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
int n, m, cnt;
long long tr[400010], tags[400010], tage[400010];
void addtag(long long s, long long e, int x, int l, int r) {
tr[x] += s * (r - l + 1) + 1ll * (r - l) * (r - l + 1) / 2 * e;
tags[x] += s, tage[x] += e;
}
void pushdown(int x, int ls, int rs, int l, int mid, int r) {
if (tag... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline ll read() {
ll x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = (x << 1) + (x << 3) + ch - '0';
ch = getchar();
}
return x * f;
}
const ll ... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
constexpr int Maxn = 2e5 + 5;
int n, m;
int a[Maxn];
namespace range_tree {
using value_t = int;
struct range {
int l, r;
mutable value_t c;
range() : l(0), r(0), c(value_t()) {}
range(int l, int r, const value_t &c) : l(l), r(r), c(c) {}
range(const range &x) : l... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int Maxn = 200005;
int n, m, ct, a[Maxn], b[Maxn], x[Maxn], y[Maxn], opt[Maxn], val[Maxn];
set<pair<int, int> > Se[Maxn];
struct ele {
int lt, rt, val;
bool operator<(const ele &A) const { return lt < A.lt; }
};
set<ele> S;
struct Tree {
int lt, rt;
pair<int, ... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
constexpr int Maxn = 2e5 + 5;
int n, q;
int a[Maxn];
template <typename _Tp>
class range {
public:
public:
range() : l(0), r(0), v(_Tp()) {}
range(int l, int r, const _Tp &v) : l(l), r(r), v(v) {}
range(const range &x) : l(x.l), r(x.r), v(x.v) {}
friend bool opera... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
namespace FGF {
int n, m;
const int N = 2e5 + 5;
int a[N];
struct Node {
int l, r, x;
Node() {}
Node(int _l, int _r, int _c) : l(_l), r(_r), x(_c) {}
bool operator<(const Node &a) const { return l < a.l; }
};
int id(int x) {
static unordered_map<int, int> mp;
st... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
using ll = long long;
struct P {
int l, r, a;
bool operator<(P a) const { return l < a.l; }
};
using it = set<P>::iterator;
int n, id;
set<P> st;
set<int> ps[N];
unordered_map<int, int> mp;
struct FW {
ll t[N];
void add(int x, int y) {
for... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + c - '0';
c = getchar();
}
return x * f;
}
int a[1... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
const int N = 1e5 + 10;
int n, m, a[N], b[N << 1], pre[N], las[N << 1], ql[N], qr[N], qx[N];
long long tk[N << 2], tb[N << 2];
inline void adt(int rt, long long k, long long b) {
tk[rt] += k;
tb[rt] += b;
}
inline void pushdown(int rt) {
adt(rt << 1, tk[rt], tb[rt]), adt(rt << 1 | 1, tk[r... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, M = 1e3 + 5;
const long long INF = 1e18 + 5;
inline long long read() {
long long sum = 0, fh = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') fh = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
sum = sum *... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long read() {
long long s = 0;
char c = getchar(), lc = '+';
while (c < '0' || '9' < c) lc = c, c = getchar();
while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar();
return lc == '-' ? -s : s;
}
void write(long long x) ... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
int f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
x *= f;
}
inline void write(long lon... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + c - '0';
c = getchar();
}
return x * f;
}
int a[1... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
#pragma GCC target("avx,avx2")
using namespace std;
template <typename T>
void chmin(T &x, const T &y) {
if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
if (x < y) x = y;
}
int read() {
char c;
while ((c = getchar()) < '-')
;
if (c == '-') {
int x = (c... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200005;
int n, q;
struct TNode {
int l, r;
ll a, b;
} t[N << 2];
inline int lc(int pos) { return pos << 1; }
inline int rc(int pos) { return pos << 1 | 1; }
void build(int pos, int l, int r) {
t[pos].l = l;
t[pos].r = r;
if (l =... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int n, cq, a[N + 9];
void into() {
scanf("%d%d", &n, &cq);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
}
struct answer {
struct tree {
long long sum, add;
} tr[N * 4 + 9];
void Pushup(int k) { tr[k].sum = tr[k << 1].sum + tr[k << 1 |... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
int enlarge(int n) {
int res = 1;
while (res < n) {
res <<= 1;
}
return res;
}
struct node {
int c;
long long s;
node() : c(0), s(0) {}
node(int _c, long long _s) : c(_c), s(_s) {}
node operator+(const node &rhs) const { return node(c + rhs.c, s + rhs.s); }
};
class segmen... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
const int N = 200000;
int n, q;
struct BIT {
long long tree[N + 5];
int lowbit(int x) { return x & -x; }
void update(int x, int k) {
for (int i = x; i <= n; i += lowbit(i)) tree[i] += k;
}
long long sum(int x) {
long long ans = 0;
for (int i = x; i; i -= lowbit(i)) ans += ... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int w = 0, x = 0;
char c = getchar();
while (!isdigit(c)) w |= c == '-', c = getchar();
while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
return w ? -x : x;
}
namespace star {
const int maxn = 1e5 + 10;
int n, m;
struct sec {
int l, r,... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
constexpr int Maxn = 2e5 + 5;
int n, m;
int a[Maxn];
namespace range_tree {
using value_t = int;
struct range {
int l, r;
mutable value_t c;
range() : l(0), r(0), c(value_t()) {}
range(int l, int r, const value_t &c) : l(l), r(r), c(c) {}
range(const range &x) : l... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
const int N = 200000;
int n, q;
struct BIT {
long long tree[N + 5];
int lowbit(int x) { return x & -x; }
void update(int x, int k) {
for (int i = x; i <= n; i += lowbit(i)) tree[i] += k;
}
long long sum(int x) {
long long ans = 0;
for (int i = x; i; i -= lowbit(i)) ans += ... | CPP |
1423_G. Growing flowers | Sarah has always been a lover of nature, and a couple of years ago she saved up enough money to travel the world and explore all the things built by nature over its lifetime on earth. During this time she visited some truly special places which were left untouched for centuries, from watching icebergs in freezing weath... | 2 | 13 | #include <bits/stdc++.h>
using namespace std;
namespace FGF {
int n, m;
const int N = 2e5 + 5;
int a[N];
struct Node {
int l, r, x;
Node() {}
Node(int _l, int _r, int _c) : l(_l), r(_r), x(_c) {}
bool operator<(const Node &a) const { return l < a.l; }
};
int id(int x) {
static unordered_map<int, int> mp;
st... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const long long mod = 998244353;
const long long Inf = 1e18;
int inv[1 << 20], cnt, f[N], val[N], mini, id[N];
vector<int> g[N];
bool vis[N];
void dfs(int u) {
vis[u] = 1;
for (auto v : g[u]) {
if (!vis[v]) dfs(v);
val[u] += val[v] * f[v]... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int c = 1002, k = 1 << 20;
int n, m, q, ert[c], mini, inv[k], ts[c], cnt;
vector<int> sz[c];
bool v[c], sp[c];
string s;
void add(int a, int b, int c) {
if (c)
cout << "+ ";
else
cout << "- ";
cout << a << " " << b << "\n";
}
void valt(int a, int b) {
... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
void dfs(int v, vector<int> &col, vector<int> &ts, vector<vector<int> > &g) {
col[v] = 1;
for (auto u : g[v])
if (col[u] == 0) {
dfs(u, col, ts, g);
}
ts.push_back(v);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, t;
cin ... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
public class E {boolean[] vis;ArrayList<Integer> order;int[][] g;
void dfs(int v) {vis[v] = true;for (int u : g[v]) {if (!vis[u]) {dfs(u);}}order.add(v);}
static final int K = 20;
void submit() { int n = nextInt();int m = nextInt(... | JAVA |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
const int MN = 1e3 + 10;
const int K = 20;
int N, M, T, id[MN], t[MN], ctr, m[1 << K];
bool conn[MN][MN];
char s[10];
std::vector<int> a[MN], on[K + 1];
struct Mod {
public:
char c;
int a, b;
void out() const { printf("%c %d %d\n", c, a, b); }
};
std::vector<Mod> f;
void flip(int a, int ... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
void dfs(int v, vector<int> &col, vector<int> &ts, vector<vector<int> > &g) {
col[v] = 1;
for (auto u : g[v])
if (col[u] == 0) {
dfs(u, col, ts, g);
}
ts.push_back(v);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, t;
cin ... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;
using namespace std;
int cx[4] = {0, 0, 1, -1};
int cy[4] = {-1, 1, 0, 0};
string Yes[2] = {"No\n", "Yes\n"};
string YES[2] = {"NO\n", "YES\n"};
string Possible[2] = {"Impossible\n", "Possible\n"};
string PO... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int N = 1003, M = 100003;
template <typename T>
void read(T &x) {
int ch = getchar();
x = 0;
for (; ch < '0' || ch > '9'; ch = getchar())
;
for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
int n, m, K, T, cnt, head[N], to[M], nxt[M],... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
int D = 20;
int n, m, q, cnt = -1;
int fir[1000], in[1000];
int nxt[200000], to[200000];
int tp[1000], pos[1000];
int have[1 << 20];
int K = 0, A[10000], B[10000];
bool C[10000];
inline void addedge(int a, int b, bool c) {
A[K] = a;
B[K] = b;
C[K++] = c;
return;
}
i... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;
using namespace std;
int cx[4] = {0, 0, 1, -1};
int cy[4] = {-1, 1, 0, 0};
string Yes[2] = {"No\n", "Yes\n"};
string YES[2] = {"NO\n", "YES\n"};
string Possible[2] = {"Impossible\n", "Possible\n"};
string PO... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int c = 1002, k = 1 << 20;
int n, m, q, ert[c], mini, inv[k], ts[c], cnt;
vector<int> sz[c];
bool v[c], sp[c];
string s;
void add(int a, int b, int c) {
if (c)
cout << "+ ";
else
cout << "- ";
cout << a << " " << b << "\n";
}
void valt(int a, int b) {
... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
int v = 0, f = 1;
char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-')
f = -1;
else
v = (c & 15);
while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
x = v * f;
}
inline void read(lo... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
public class E {boolean[] vis;ArrayList<Integer> order;int[][] g;
void dfs(int v) {vis[v] = true;for (int u : g[v]) {if (!vis[u]) {dfs(u);}}order.add(v);}
static final int K = 20;
void submit() { int n = nextInt();int m = nextInt(... | JAVA |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
void dfs(int v, vector<int> &col, vector<int> &ts, vector<vector<int> > &g) {
col[v] = 1;
for (auto u : g[v])
if (col[u] == 0) {
dfs(u, col, ts, g);
}
ts.push_back(v);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, t;
cin ... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
int n, m, k, T, head[1010], o = 0, deg[1010], id[1010];
int tpn[1010], l = 1, r = 0, cnt = 0;
int vis[1050000], st[4300][3];
char s[100];
struct edge {
int to, link;
} e[100010];
void add_edge(int u, int v) {
e[++o].to = v, e[o].link = head[u], head[u] = o, deg[v]++;
}
... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, kk, deg[N], id[N], l = 1, r, idx, tp[N];
vector<int> v[N];
int vis[1 << 20];
struct Mov {
int x, y, z;
} mov[N * 5];
char s[N];
int find(int st) {
queue<int> q;
q.push(st);
while (!q.empty()) {
int nd = q.front();
q.pop();
i... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1111, maxm = 111111, maxs = 1111111, mod = 998244353;
inline long long read() {
char ch = getchar();
long long x = 0, f = 0;
while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getc... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, T;
int e[N][N], q[N], deg[N];
int id[N], adj[N];
void topo() {
for (int i = (int)(1); i <= (int)(n); i++)
for (int j = (int)(1); j <= (int)(n); j++)
if (e[i][j]) ++deg[j];
int h = 0, t = 0;
for (int i = (int)(1); i <= (int)(n); ... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;
using namespace std;
int cx[4] = {0, 0, 1, -1};
int cy[4] = {-1, 1, 0, 0};
string Yes[2] = {"No\n", "Yes\n"};
string YES[2] = {"NO\n", "YES\n"};
string Possible[2] = {"Impossible\n", "Possible\n"};
string PO... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
t1 = max(t1, t2);
}
template <typename T>
void mintt(... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
public class E {
boolean[] vis;
ArrayList<Integer> order;
int[][] g;
void dfs(int v) {
vis[v] = true;
for (int u : g[v]) {
if (!vis[u]) {
dfs(u);
}
}
order.add(v);
}
static final int K = 20;
void submit() ... | JAVA |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
void dfs(int v, vector<int> &col, vector<int> &ts, vector<vector<int> > &g) {
col[v] = 1;
for (auto u : g[v])
if (col[u] == 0) {
dfs(u, col, ts, g);
}
ts.push_back(v);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, t;
cin ... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class E {
static final int K = 20;
static final Random rng = new Random();
static final int C = 5;
boolean[] vis;
ArrayList<Integer> order;
int[][] g;
PrintWriter out;
private ... | JAVA |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
struct Modify {
bool add;
int a, b;
};
int n, m, t;
vector<int> x[MAXN];
map<int, int> h;
vector<int> s;
vector<Modify> ans;
int losestate[1 << 20];
int winstate[1 << 20];
void BuildBase() {
int out[MAXN];
vector<int> y[MAXN];
for (int i = 1... | CPP |
1442_F. Differentiating Games | This is an interactive problem
Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.
As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a dir... | 2 | 12 | #include <bits/stdc++.h>
using namespace std;
void dfs(int v, vector<int> &col, vector<int> &ts, vector<vector<int> > &g) {
col[v] = 1;
for (auto u : g[v])
if (col[u] == 0) {
dfs(u, col, ts, g);
}
ts.push_back(v);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, t;
cin ... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | import java.io.*;
import java.util.*;
public final class h{
static int T, N, K, M, b[], pfx[];
public static void main(String args[]) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
T = Intege... | JAVA |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | T = int(input())
for _ in range(T):
n, k, m = map(int, input().split())
b = [int(i) for i in input().split()]
f = False
ff = False
for p, i in enumerate(b):
if i - p - 1 == n - i - len(b) + p + 1:
f = True
break
if i - p - 1 >= k>>1 and n - i - len(b) + p + 1... | PYTHON3 |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=200010;
inline int read(){
int f=1,x=0;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
return f*x;
}
int T,n,k,m;
int vis[maxn],a[ma... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | /**
* Prof.Nicola
**/
#include <bits/stdc++.h>
using namespace std;
template<class T>void re(T&x){cin>>x;}
template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);}
template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}}
template<class T>void re(deque<T>&x){for(long i=0;i<x.... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #pragma GCC diagnostic ignored "-Wunused-parameter"
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define INP "solve"
#define OUT "solve"
const long long INF_LL = 8e18;
const int INF = 1e9 + 100;
const int MOD = 1e9 + 7;
//const int Base = 311;9
const long double EPS = 1e-10;
const int BLOC... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200005];
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t;
cin >> t;
while(t--)
{
int n, k, m;
cin >> n >> k >> m;
for(int i=1;i<=n;++i) a[i] = 1;
for(int i=1;i<=m;++i)
... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 200005
using namespace std;
int T,n,m,K,i,j,k,bz[maxn],cnt[maxn];
int main(){
scanf("%d",&T);
while (T--){
scanf("%d%d%d",&n,&k,&m);
for(i=1;i<=n;i++) bz[i]=0;
for(i=1;i<=m;i++){
int x; scanf("%d",&x);
bz[x]=1;
}
if ... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,abm,mmx,tune=native")
#pragma comment(linker, "/STACK:2769095000")
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdlib>
//#include<cstdint>
#include<sstream>
#include<cmath>
#include<ctime>
#include... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | from sys import stdin, stdout
from collections import defaultdict
import math
def main():
t = int(stdin.readline())
for _ in range(t):
n,k,m = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
if (n - m) % (k - 1) != 0:
stdout.write("NO... | PYTHON3 |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | T = int(input())
for _ in range(T):
n, k, m = map(int, input().split())
b = [int(i) for i in input().split()]
ff = False
for p, i in enumerate(b):
if i - p - 1 >= k>>1 and n - i - len(b) + p + 1 >= k>>1:
ff = True
if b==[int(i)+1 for i in range(n)]:
print('YES')
elif... | PYTHON3 |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ls (x<<1)
#define rs (x<<1|1)
#define db double
#define inf 2147483647
#define llinf 9223372036854775... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public ... | JAVA |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k, m;
bool check(ll suml, int x, int y, ll sumr) {
if (x == 0 || y == 0) return true;
int p = (k - 1) >> 1;
int c = (y + p - 1) / p * p;
if (y + sumr >= c && suml + x - 1 >= c) return true;
return false;
}
signed main() {
... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int b[maxn];
bool vis[maxn];
void work() {
int n, k, m;
scanf("%d%d%d", &n, &k, &m);
for (int i = 1; i <= n; i++) vis[i] = 0;
for (int i = 0; i < m; i++) scanf("%d", b + i), vis[b[i]] = 1;
if ((n - m) % (k - 1)) {
puts... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | JAVA |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
const int NR = 5e5 + 5;
int n, m, c[NR], k, t;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int i;
cin >> t;
while (t--) {
cin >> n >> k >> m;
for (i = 1; i <= m; ++i) {
cin >> c[i];
}
... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include<bits/stdc++.h>
#ifdef miaojie
#define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#else
#define dbg(...)
#endif
using namespace std;
using ll = long... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define ff first
#define ss second
#define YES printf("YES\n")
#define NO printf("NO\n")
#define nn "\n"
#define sci(x) scanf("%d", &x)
#define LL_INF (1LL << 62)
#d... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | //package com.company;
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
public static class Task {
public void solve(Scanner sc, PrintWriter pw) throws IOException {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
... | JAVA |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | // main.cpp
// ervb
//
// Created by Kanak Gautam on 21/04/20.
// Copyright © 2020 Kanak Gautam. All rights reserved.
//
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <un... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | import java.io.*;
import java.util.*;
import java.util.Map.Entry;
public class D {
FastScanner in;
PrintWriter out;
boolean systemIO = true;
public class Pair implements Comparable<Pair> {
int x;
int y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
public Pair clone() {
return new Pai... | JAVA |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | import sys
for _ in range(int(sys.stdin.readline().strip())):
n,k,m=tuple(map(int,sys.stdin.readline().strip().split(" ")))
ml=set(map(int,sys.stdin.readline().strip().split(" ")))
havitada=[]
for i in range(1,n+1):
if i not in ml:
havitada.append(i)
saab=False
if len(havitada)%(k-1)!=0:
print("no")
cont... | PYTHON3 |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, k, m = map(int, input().split())
B = list(map(int, input().split()))
if (n - m) % (k - 1): print("NO")
else:
p = (k - 1) // 2
left, right = [0] * m, [0] * m
for i, b in enumerate(B, 1):
left[i - 1... | PYTHON3 |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | # by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO, IOBase
def solve(n,k,m,b):
if (n-m)%(k-1):
return 'NO'
val,val1,x = 0,0,k//2
for i in range(1,n+1):
if i == b[val]:
val += 1
if val1 >= x and n-m-val1 >= x:
... | PYTHON3 |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define ll long long
#define M 1000000007
#define pb push_back
#define p_q priority_queue
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii ... | CPP |
1468_H. K and Medians | Let's denote the median of a sequence s with odd length as the value in the middle of s if we sort s in non-decreasing order. For example, let s = [1, 2, 5, 7, 2, 3, 12]. After sorting, we get sequence [1, 2, 2, \underline{3}, 5, 7, 12], and the median is equal to 3.
You have a sequence of n integers [1, 2, ..., n] an... | 2 | 14 | #pragma GCC optimize("O3")
#pragma GCC target("sse4")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x) cerr<<#x<<"="<<x<<endl
#define t2(x, y) cerr<<#x<<"="<<x<<" "<... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.