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 |
|---|---|---|---|---|---|
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
std::vector<int> factors;
int mood[100000];
int N;
void calcfactors(int num) {
for (int i = 3; i <= num; i++) {
if (num % i == 0) {
factors.push_back(i);
while (num % i == 0) {
num /= i;
}
}
}
}
bool lucky() {
calcfactors(N);
for (int i = 0; i < factors... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[100010], n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
for (int i = 1; i <= n / 3; i++) {
if (n % i == 0) {
for (int j = 1; j <= i; j++) {
int temp = j;
while (temp <= n && a[temp]) temp = t... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #!/usr/bin/python
n = int(raw_input())
kn = raw_input().split()
for i in xrange(len(kn)):
kn[i] = int(kn[i])
i = 1
while i * i <= n:
if n % i == 0:
a, b = i, n/i
for it in xrange(2):
#print a, b
for sh in xrange(a):
flag = True
for j in xrange(b):
flag = False
if kn[(sh + j * a) % n] =... | PYTHON |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* I=1 V=5 X=10 L=50 C=100 D=500 M=1000 IV 4, IX 9, XL 40, XC 90, CD 400, CM
* 900.
*
* @author pttrung
*/
public class C {
// public static long Mod = 1000000009;
public sta... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | n = int(input())
kinghts = [int(x) for x in input().split()]
d = 1
if 0 not in kinghts:
print('YES')
d = 0
elif 1 not in kinghts:
print('NO')
d = 0
else:
for k in range(3,int(n**0.5) + 3):
if n%k == 0 and d ==1:
a = n//k
for x in range(0, a):
... | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
for (ll i = 0; i < v.size(); ++... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.*;
import java.util.*;
/**
* Problem Cf71C
*/
public class Cf71C {
static class Task extends IOHandler {
public void run() {
int n = in.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; ++i) a[i] = in.nextInt();
if(good(a)) out.println(... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int DEBUGGING = 0;
const int INF = 1000000000;
const int MOD = 1000000007;
const long long LINF = 1e18;
const double PI = 3.1415926535897932;
const double EPS = 1e-7;
long long gcdEx(long long a, long long b, long long *x, long long *y) {
if (!a) {
*x = 0;
*y = 1;... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int OO = (int)1e9;
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
long long n, z, cnt, x, y;
vector<long long> divisors;
vector<int> a;
vector<long long> generate_divisors(long long n) {
vector<long long> v;
long long i;
for (i... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
int n;
scanf("%d", &n);
int i;
for (i = 0; i <= n; i++) {
scanf("%d", &a[i]);
}
int k, l, q, j;
for (i = 3; i <= n; i++) {
if (n % i == 0) {
q = (n / i) - 1;
for (j = 0; j < q + 1; j++) {
for (k = j, l = ... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int n;
cin >> n;
vector<long long int> a(n);
for (long long int i = 0; i < n; i++) cin >> a[i];
long long int z = 0;
for (long long int i = 1; i <= n / ... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | n = input()
s = map(int, raw_input().split())
i = 1
while i*i <= n:
if n%i != 0:
i += 1
continue
if n/i >= 3:
for j in range(i):
if 0 not in s[j::i]:
print 'YES'
exit()
if i >= 3:
for j in range(n/i):
if 0 not in s[j::n/i]:
print 'YES'
exit()
i += 1
print 'NO'
| PYTHON |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | n = input()
kts = map(int, raw_input().split())
can = False
for i in xrange(1,n/3+1):
if n%i != 0:
continue
for j in xrange(i):
can = True
for k in xrange(0,n,i):
if(kts[k+j] == 0):
can = False
break
if(can):
print "YES"
break
if can:
break
if not can:
print "NO"
| PYTHON |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[111111];
int main() {
int n = ({
int t;
scanf("%d", &t);
t;
});
for (int i = 0; i < n; i++)
a[i] = ({
int t;
scanf("%d", &t);
t;
});
for (int jump = 1; jump < n; jump++) {
if (n % jump == 0 && n / jump > 2) {
for... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, knight[100000];
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &knight[i]);
for (int i = 3; i <= n; i++) {
if (n % i != 0) continue;
bool lucky;
for (int j = 0; j < n / i; j++) {
lucky = true;
for (int k = j; k <... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
double tick() {
static clock_t oldt, newt = clock();
double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
oldt = newt;
return diff;
}
vector<int> prime;
void simpleSieve(int limit) {
bool mark[limit + 1];
memset(mark, true, sizeof(mark));
for (int p = 2; p * p ... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static boolean fortunate(int[] v) {
int n = v.length;
for (int i = 0; i < n / 3; i++)
if (v[i] == 1)
for (int j = 1; j <= n / 3; j++) {
int home = i, iter = home;
do{
ite... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.*;
import java.util.*;
public class C {
public static void main(String[] args) {
new Solver().run();
}
static class Solver implements Runnable {
BufferedReader reader;
StringTokenizer tokenizer = null;
Solver() {
... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.util.Scanner;
public class C {
/**
* @param args
*/
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int n=in.nextInt();
boolean[] mas=new boolean[n];
for(int i=0;i<n;i++){
if(in.nextInt()==1)
... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[110000], b[11000], t;
void init() {
t = 0;
long long i;
for (i = 2; i < 100001; i++) {
if (!a[i]) {
b[t++] = i;
long long j = i * i;
while (j < 100001) {
a[j] = 1;
j += i;
}
}
}
}
int main() {
init();
int n, ... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 200005;
bool a[N];
int cnt[N];
int n;
bool check(int k) {
if (n / k < 3) return 0;
for (int start = 0; start < k; ++start) {
bool boo = 1;
for (int i = start; i < n; i += k) boo &= a[i];
if (boo) return 1;
}
return 0;
}
int main() {
scanf... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException
{
Scanner sc = n... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int A[n];
for (int i = 0; i < n; i++) cin >> A[i];
bool found = false;
for (int sides = 3; sides <= n; sides++) {
if (found) break;
if (n % sides == 0) {
int len = n / sides;
for (int j = 0; j < n; j++) {
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RoundTableKnights {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
String s = r.readLine();
int n = new Integer(s);
s ... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long a[300005], n;
bool f(long long x) {
long long i, j, ok;
for (i = 1; i <= x; i++) {
long long cnt = 0;
for (j = i; j <= n; j += x)
if (a[j]) {
cnt++;
}
if (cnt == n / x && cnt >= 3) return 1;
}
return 0;
}
int main() {
ios:... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
double mod(double a) { return (a > 0 ? a : (-a)); }
unsigned long max(unsigned long int a, unsigned long int b) {
return (a) > (b) ? (a) : (b);
}
bool sortbyff(const pair<int, int> &a, const pair<int, int> &b) {
return (a.first < b.first);
}
long long power(long long x,... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<int> fact;
for (int i = 3; i <= n; i++)
if (n % i == 0) fact.push_back(i);
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < fa... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const vector<vector<int> > adj4({{0, 1}, {0, -1}, {1, 0}, {-1, 0}});
const vector<vector<int> > adj8(
{{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}});
int gcd(int a, int b) { return b == 0 ? a : g... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
int a[100000], b[100000];
int main() {
int n, i, j;
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d", &a[i]);
for (i = 1; i <= n / 3; i++) {
if (n % i == 0) {
for (j = 0; j < n; j++) {
if (j < i)
b[j] = a[j];
else
b[j] = a[j] + b[j - i];
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 17;
int n;
int gmood[MAXN];
int main() {
scanf("%d", &n);
for (int i = 0; i < (int)(n); ++i) scanf("%d", &gmood[i]);
for (int i = (int)3; i <= (int)(n); ++i)
if (n % i == 0) {
int ni = n / i;
for (int j = 0; j < (int)(ni); ++j) {
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.util.*;
public class C {
Scanner sc = new Scanner(System.in);
ArrayList<Integer> cands = new ArrayList<Integer>();
private void doIt()
{
int n = sc.nextInt();
int [] kings = new int[n];
for(int i = 0; i < n; i++) kings[i] = sc.nextInt();
cands.add(3);
cands.add(4);
boolean [] isprime = new b... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> v(n);
for (auto &i : v) {
cin >> i;
}
auto check = [&n, &v](int x) {
if (n / x < 3) return;
for (int i = 0; i < x; i++) {
int ch = 1;
for (int j = i; j < n; j +... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | n = int(input())
kinghts = [int(x) for x in input().split()]
d = True
if 0 not in kinghts:
print('YES')
d = False
elif 1 not in kinghts:
print('NO')
d = False
else:
for k in range(3,int(n**0.5) + 3):
if n%k == 0 and d:
a = n//k
for x in range(0, a):
... | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | /*
[ ( ^ _ ^ ) ]
*/
import java.io.*;
import java.util.*;
public class test {
int INF = (int)1e9;
long MOD = 1000000007;
void solve(InputReader in, PrintWriter out) throws IOException {
int n = in.nextInt();
int[] a = new int[n];
for(int i=0; i<n; i++) {
... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | from math import sqrt
def eratosthenes(n):
A = [True]*(n+1)
for i in range(2, int(sqrt(n)) + 1):
if A[i]:
for j in range(i**2, n+1, i):
A[j] = False
return [i for i in range(2, len(A)) if A[i]]
def knights(n, Table):
P = eratosthenes(n)
P[0] = 4
for k in P:
... | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import math
import sys
import collections
import bisect
import string
import time
def get_ints():return map(int, sys.stdin.readline().strip().split())
def get_list():return list(map(int, sys.stdin.readline().strip().split()))
def get_string():return sys.stdin.readline().strip()
for tc in range(1):
n=int(input())
... | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
vector<int> a;
int x;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
a.push_back(x);
}
int t = 0;
for (int i = 3; i <= n; i++) {
if (n % i == 0) {
for (int j = 0; j <= n / i; j++) {
int k = 0;
for (int... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long N = 2e5 + 1;
const long long INF = 1e9;
void solve() {
int n;
cin >> n;
int t = n;
vector<int> pf, a(n);
for (int i = 0; i < t; i++) cin >> a[i];
for (int i = 2; i < n; i++) {
if (n % i) continue;
pf.push_... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.util.Scanner;
public class RoundTableKnights {
static Scanner in=new Scanner(System.in);
public static void main(String[] args)
{
int possible = 0, n;
n=in.nextInt();
int []a=new int[n];
for (int i = 0; i < n; i++)
a[i]=in.nextInt();
for (int k = 1; k <= n/3; k++)
{
if (n % k =... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
* Date 11.11.2011
* Time 21:52:37
* Author Woodey
* $
*/
public class C71 {
private void Solution() throws IOException {
int n = nextInt();
boolean[]... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
@SuppressWarnings("unused")
public class Main implements Runnable {
static StringTokenizer st;
static BufferedReader br;
static PrintWriter out;
static String file = "";
public static void main(String[] args) throws IOExcep... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #!/usr/bin/env python3
import itertools
import math
n = int(input())
good_mood = [(m == 1) for m in map(int, input().split())]
longest_run_of_bad_moods = max((len(list(group)) for (key,group) in itertools.groupby(good_mood) if key == False), default=0)
def get_divisors(nr):
divisors = []
for i in range(1,math.... | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | def divisors(n):
i = 1
res = []
while i * i <= n:
if n % i == 0:
d = n // i
if i >= 3:
res.append(i)
if d != i and d >= 3:
res.append(d)
i += 1
return res
def main():
n = int(input())
knights = [i... | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, m, i, j, k, t, s, x, y, z, h[N], hh[N], d, l, ii, jj, u;
vector<int> V;
int main() {
cin >> n;
for (i = 1; i <= n; i++) scanf("%d", h + i);
m = n;
for (i = 2; i * i <= n; i++, d = 0)
while (m % i == 0) {
if (i != 2 and !d) {
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 |
import java.io.IOException;
import java.util.Locale;
import java.util.Scanner;
public class C {
private void processInput() throws IOException {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
boolean[] m = new boolean[n];
for (int i = 0;i < n; i++) {
m[i] = in.nextInt() == 0 ? false : tr... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.util.Scanner;
public class RoungKnightsTable {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int[] arr = new int[n];
for(int i=0; i<n;i++)arr[i] = input.nextInt();
for(in... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int b[111111], n;
int check(int k) {
int l = n / k;
for (int i = 0; i < l; i++) {
int ok = 1;
int cur = i;
for (int j = 0; ok && j < k; j++) {
if (!b[cur]) ok = 0;
cur += l;
cur %= n;
}
if (ok) return 1;
}
return 0;
}
int main()... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.*;
import java.util.ArrayList;
import java.util.*;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) throws IOException {
new C().solve();
}
BufferedReader br;
StringTokenizer st = new StringTokenizer("");
void solve() throws IOExcept... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 100005;
int n, a[maxn], dp[maxn];
bool check(int d) {
if (n / d < 3) return 0;
for (int i = 1; i <= n; i++) {
if (a[i] == 0)
dp[i] = 0;
else {
if (i > d)
dp[i] = dp[i - d] + 1;
else
dp[i] = 1;
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | def f(n):
n += 1
t = [1] * n
for i in range(3, int(n ** 0.5) + 1, 2):
u, v = i * i, 2 * i
if t[i]: t[u :: v] = [0] * ((n - u - 1) // v + 1)
return [4] + [i for i in range(3, n, 2) if t[i]]
n, t = int(raw_input()), raw_input()[:: 2]
q = [n / i for i in f(n) if n % i == 0]
print... | PYTHON |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int i, j, n, r, vr, a[100001], b[35001], x, y;
vector<int> v;
int main() {
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
r = n;
for (j = 2; j <= r; j++)
if (r % j == 0) {
v.push_back(j);
while (r % j == 0) r /= j;
}
if (v[0] == 2) v[0] = 4;
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | n,a=int(input()),[*map(int,input().split())]
for j in range(1,(n+1)//2):
if n%j==0:
for l in range(j):
t=1
for i in range(l,n,j):
if a[i]==0:t=0;break
if t:exit(print("YES"))
print("NO") | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
bool good[100001];
for (int i = 0; i < n; i++) cin >> good[i];
vector<int> d;
for (int i = 1; i <= n / 3; i++)
if (n % i == 0) d.push_back(i);
for (int j = 0; j < d.size(); j++) {
for (int start = 0; start < d[j]; start++)... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.util.Scanner;
public class coder {
public static void main(String[]args){
Scanner sc= new Scanner(System.in);
int n= sc.nextInt();
int [] mas= new int [n+1];
for(int i=1;i<=n;i++){
mas[i]=sc.nextInt();
}
int s=0;
for(int i=1;i<=n/2;i++)... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long mod(long long a, long long b) {
if (a % b < 0) {
return a % b + b;
}
return a % b;
}
long long mod_exp(long long a, long long b, long long c) {
long long res = 1;
a = a % c;
while (b > 0) {
if (b % 2 == 1) {
res = (res * a) % c;
}
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
bool m[maxn];
int a[maxn];
int main() {
int n, sum = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
if (n == sum) {
cout << "YES" << endl;
return 0;
}
bool flag = false;
for (int t = 3; t ... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[110000], b[11000], t;
void init() {
t = 0;
long long i;
for (i = 2; i < 110000; i++) {
if (!a[i]) {
b[t++] = i;
long long j = i * i;
while (j < 110000) {
a[j] = 1;
j += i;
}
}
}
}
int main() {
init();
int n, ... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
double sqr(double x) { return x * x; }
int const N = (int)2e6 + 1, INF = (int)1e9 + 1, MOD = (int)1e9 + 9;
long long mypow(long long a, long long b, int mod) {
long long rv = 1;
while (b) {
if (b % 2) rv = rv * a % mod;
a = a * a % mod;
b /= 2;
}
return ... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.IOException;
import java.util.*;
public class RoundTableKnights
{
public static void main(String[] args)
{
FasterScanner sc = new FasterScanner();
int n = sc.nextInt();
int knights[] = sc.nextIntArray(n);
boolean check = false;
first:for(int i = 1; i < (n+1)/2; i++)
{
if(n % i ... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long i, p[100005], j, n, k, flag, ctr, a[100005];
vector<long long> fac;
int main() {
cin >> n;
for (i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
fac.push_back(i);
fac.push_back(n / i);
}
}
flag = 1;
for (i = 0; i < n; i++) {
cin >> a... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool ar[100005], prime[100005];
int n;
bool check(int i) {
for (int k = 0; k < (int)(i); k++) {
int c = 0;
for (int j = k; j < n; j += i) c += ar[j];
if (c == n / i) return 1;
}
return 0;
}
int main() {
for (int i = 2; i <= 1e5; i++)
if (!prime[i])
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(1,n//3+1):
if n%i==0:
b[i]=i
for i in b[::-1]:
if i!=0:
z=0
for j in range(i):
if a[j:n:i]==[1]*(n//i):
print('YES')
z=1
break
if z==1:
b... | PYTHON3 |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
}
sieveLinear(n);
Arr... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n;
int str[100010];
int ok(int i) {
if (n % i != 0)
return 0;
else {
int big = n / i;
for (int j = 0; j < big; j++) {
int key = 1;
for (int k = 0; k < i; k++)
if (str[j + k * big] == 0) {
key = 0;
break;
}
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | import java.io.*;
import java.util.*;
public class tr {
public static void main(String[] args) throws IOException {
Scanner sc=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int n=sc.nextInt();
int []a=new int[n];
int ones=0;
int yyyy=0;
for(int i=0;i<n;i++) {... | JAVA |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int a[n];
int b[n];
bool found = false;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 1; i <= n / 3; i++) {
if (n % i != 0) continue;
for (int j = 0; j < n; j++) {
... | CPP |
71_C. Round Table Knights | There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool check(int num, int n, vector<int> ar) {
if (num * 3 > n) return 0;
vector<int> us(num, 1);
for (int i = 0; i < n; ++i) {
us[i % num] &= ar[i];
}
for (int i = 0; i < num; ++i) {
if (us[i]) {
return 1;
}
}
return 0;
}
signed main() {
ios... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct four {
int a, b, c, d;
four(int a_ = 0, int b_ = 0, int c_ = 0, int d_ = 0) {
a = a_;
b = b_;
c = c_;
d = d_;
}
int f() { return d - a; }
};
bool operator<(const four& f, const four& g) { return (f.a < g.a); }
int n, m;
vector<long long> a, b,... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct node {
int lb, rb, l_max, r_max, s_max;
};
int n, m, l, r, k, offset = 1 << 19, a[300004], z, t;
long long d[600004];
node trn[1100000];
int sgn(long long x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
void update(int pos) {
if (pos < 0) return... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
const int Mod = 1e9 + 7;
int n, m, a[N];
long long b[N];
struct Node {
int sl, sr, ml, mr, m, len;
long long v;
Node() {}
} tree[N << 2];
inline Node merge(Node &a, Node &b) {
Node res;
res.m = max(a.m, b.m);
if (a.sr != 0 && b.sl != 0 && a.sr... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, m;
long long A[N], D[N];
set<int> pts;
unordered_set<int> nonzero;
map<int, int> cnt;
bool isExtr(int k) {
if (k == 0 || k == n - 1) return true;
if (D[k] == 0 || D[k + 1] == 0) return true;
if (D[k] < 0 && D[k + 1] > 0) return true;
ret... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int mult(int x, int y) {
long long int ans, x1 = (long long int)x, y1 = (long long int)y;
ans = (x1 * y1) % 1000000007;
return (int)ans;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
long long int ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, a[300005];
long long b[300005];
struct seg {
struct node {
int opt, lopt, ropt, lp, lm, rp, rm, sz;
} tree[1050000];
node merge(node &l, node &r) {
node x;
x.sz = l.sz + r.sz;
x.opt = max({l.opt, r.opt, l.ropt + r.lm, l.rp + r.lopt});
x.lp =... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long S[1200008];
long long A[300002];
int n;
void add(int l, int r, int num, int id = 1, int sl = 0, int sr = n + 1) {
if (r <= sl or sr <= l) return;
if (l <= sl and sr <= r) {
S[id] += num;
return;
}
int mid = (sl + sr) / 2;
S[2 * id] += S[id];
S[... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a[300005];
int sign(long long x) { return x > 0 ? 1 : -1; }
struct Node {
int l, r, lx, mx, rx;
void up(Node L, Node R) {
lx = L.lx;
rx = R.rx;
mx = max(L.mx, R.mx);
if (a[L.r] && a[R.l] && sign(a[L.r]) >= sign(a[R.l])) {
mx = max(mx, L.r... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int UPR = 0, UPL = 1, DWR = 2, DWL = 3;
int n;
int sum(pair<int, int> i) { return i.first + i.second; }
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
return {a.first + b.first, a.second + b.second};
}
pair<int, int> maxii(pair<int, int> a, pair<int,... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int n, a[N];
long long lazy[4 * N];
struct node {
int prf, sfx, best, len, prfup, sfxdw, prfbes, sfxbes;
long long st, en;
} seg[4 * N];
inline void mrg(node& x, node& y, node& res) {
res.prf = x.prf;
if (x.prf == x.len && x.en > y.st) res.prf ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
int n, m;
long long d[2 * MAXN];
long long lb[4 * MAXN], le[4 * MAXN], l[4 * MAXN];
int sign(long long a) {
if (a == 0) {
return 0;
} else {
return (a > 0 ? 1 : -1);
}
}
void build(int v, int tl, int tr) {
if (tl == tr) {
if (d... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x7ffffffffffffff;
const double eps = 1e-8;
unsigned int seed = 19260817;
__inline__ __attribute__((always_inline)) unsigned int Rand() {
return seed = seed * 998244353u + 1000000007u;
}
template <typename _Tp>
_Tp gcd(const ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
long long num[300005];
struct Node {
int l, r, mid, lans1, lans2, rans1, rans2, ans;
long long lazy, lnum, rnum;
} tre[1200006];
void build(int x, int l, int r) {
tre[x].l = l;
tre[x].r = r;
tre[x].mid = (l + r) >> 1;
if (l == r) {
tre[x].lnum = tre[x... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct treenode {
int size, max, toleft, toright, Toleft, Toright, topleft, topright;
};
treenode tree[2000000];
long long g[500000];
int i, m, n, x, y, z;
inline treenode merge(treenode l, treenode r) {
treenode t;
t.size = l.size + r.size;
t.toleft = l.toleft;
i... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a[300010];
int c[4 * 300010], p[4 * 300010], s[4 * 300010];
int b[4 * 300010], d[4 * 300010];
void update(int n, int tl, int tr, int pos, long long val) {
if (tl == tr) {
if (val == 0) {
p[n] = 0;
s[n] = 0;
c[n] = 0;
return;
}
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
struct node {
int ph, sh, pu, pd, su, sd, mx, l, r;
long long vl, vr;
} seg[N * 4];
int n;
long long lzy[N * 4];
node merge(node a, node b) {
node ret;
ret.l = a.l;
ret.vl = a.vl;
ret.r = b.r;
ret.vr = b.vr;
ret.pu = a.pu + (a.pu == a.... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long NMAX = 3e5 + 5;
struct Node {
int maxLen;
int leftLen, rightLen;
};
Node segmTree[4 * NMAX];
int n, m;
long long a[NMAX], v[NMAX];
bool cmp(long long x, long long y) {
if (x == 0 || y == 0) return true;
int vx = (x > 0) ? (1) : ((x < 0) ? (-1) : 0);
... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct node {
int lb, rb, l_max, r_max, s_max;
};
int n, m, l, r, k, offset = 1 << 19, a[300004];
long long d[600004];
node trn[1100000];
int sgn(long long x) {
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
void update(int pos) {
if (pos < 0) return;
if... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1500001;
struct JS {
int l, r, sum, ld, rd, ud, lud, udr;
long long d, lone, rone;
} f[N];
int i, j, n, m;
long long a[N], b[N];
void update(int k) {
if (f[k].l == f[k].r) {
return;
}
long long x = f[2 * k].rone + f[2 * k].d,
y = f[2 ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, l[300005 * 4], r[300005 * 4], b[300005 * 4], d[300005];
long long a[300005];
int sign(long long x) {
if (x > 0) return 1;
return -1;
}
void update(int pos, int L, int R, int seg, int val) {
if (L == 2 && R == 1) return;
if (L == 6 && R == 5) return;
if (L =... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, l, r;
long long a[maxn], d[maxn], v;
struct ss {
int l, r, lm, mm, rm;
} seg[maxn << 2];
inline int sign(long long x) { return !x ? 0 : x < 0 ? -1 : 1; }
void pushup(int x) {
int l = seg[x].l, r = seg[x].r, m = (l + r) >> 1;
seg[x].m... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, l, r;
long long a[maxn], d[maxn], v;
struct s {
int l, r, mm, lm, rm;
inline void get(int t) { mm = lm = rm = t; }
} seg[maxn << 2];
inline int sign(long long v) { return !v ? 0 : v > 0 ? 1 : -1; }
void pushup(int x) {
int l = seg[x]... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct node {
int l, r, m;
} AINT[1200005];
int N, M;
long long V[400005];
int sign(int x) { return !V[x] ? 0 : (V[x] < 0 ? 1 : -1); }
void compute(int nod, int st, int dr) {
AINT[nod].l = AINT[2 * nod].l;
AINT[nod].r = AINT[2 * nod + 1].r;
AINT[nod].m = max(AINT[2 ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
ifstream fin(".in");
ofstream fout(".out");
struct nod {
long long int best, suf, pre;
} tree[1200000];
long long int sgn[300010], v[300010], i, j, q, a, b, n, val;
int fmm1, fmm2, fmm3;
__attribute__((always_inline)) long long int sign(long long int x);
long long int sig... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 300010;
const int INF = 0x3f3f3f3f;
void MOD(long long &a) {
if (a >= mod) a -= mod;
}
void MOD(long long &a, long long c) {
if (a >= c) a -= c;
}
void ADD(long long &a, long long b) {
a += b;
MOD(a);
}
void ADD(long long &a... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x7ffffffffffffff;
const double eps = 1e-8;
unsigned int seed = 19260817;
__inline__ __attribute__((always_inline)) unsigned int Rand() {
return seed = seed * 998244353u + 1000000007u;
}
template <typename _Tp>
_Tp gcd(const ... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
int sign(T x) {
return x > 0 ? 1 : x < 0 ? -1 : 0;
}
struct Node {
int lval, mval, rval;
};
Node tr[2340400];
long long a[1010101];
inline void recalc(int cur, int l, int r) {
int m = (l + r) / 2;
int dcur = cur + cur;
tr[cur].mval = max(tr[dcur... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long arr[N];
struct node {
long long first, last, maxi;
int downLeft, downRight, upLeft, upRight, hillLeft, hillRight;
long long lazy;
int ans;
node *l, *r;
void merge(int start, int end) {
int size_l = (start + end) / 2 - start +... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct pl {
int val, _left, _right;
} arb[4 * 300005];
int n, i, j;
int v[300005];
long long diff[300005];
void update_val(int nod, int st, int dr) {
arb[nod].val = max(arb[2 * nod].val, arb[2 * nod + 1].val);
arb[nod]._left = arb[2 * nod]._left;
arb[nod]._right = a... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long maxn = 300010;
long long n, a[maxn], lmx[maxn << 2], rmx[maxn << 2], mx[maxn << 2],
p[maxn << 2], L[maxn << 2], R[maxn << 2], Q, b[maxn];
void pushup(long long o) {
long long lc = o * 2, rc = o * 2 + 1;
lmx[o] = lmx[lc], rmx[o] = rmx[rc];
mx[o] = m... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, m, l, r;
long long a[maxn], d[maxn], v;
struct s {
int l, r, mm, lm, rm;
inline void get(int t) { mm = lm = rm = t; }
} seg[maxn << 2];
inline int sign(long long v) { return !v ? 0 : v > 0 ? 1 : -1; }
void pushup(int x) {
int l = seg[x]... | CPP |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
... | JAVA |
740_E. Alyona and towers | Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.
Sometimes Alyona chooses some segment towers, and put on the top of each tower several cub... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 60);
const int MX = 300009;
struct node {
int ans, suff, pref, sz, prefc, suffc;
node() {}
node(long long V) {
sz = 1;
if (V == 0) suff = pref = ans = prefc = suffc = 0;
if (V > 0) suff = pref = ans = prefc = suffc = 1;
if... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.