contest_id stringclasses 33
values | problem_id stringclasses 14
values | statement stringclasses 181
values | tags listlengths 1 8 | code stringlengths 21 64.5k | language stringclasses 3
values |
|---|---|---|---|---|---|
1287 | B | B. Hypersettime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shape... | [
"brute force",
"data structures",
"implementation"
] | #include<bits/stdc++.h>
using namespace std;
struct hashFunction
{
size_t operator()(const vector<string>
&myVector) const
{
std::hash<string> hasher;
size_t answer = 0;
for (string i : myVector)
{
answer ^= hasher(i) + 0x9e3779b9 +
... | cpp |
1141 | B | B. Maximal Continuous Resttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEach day in Berland consists of nn hours. Polycarp likes time management. That's why he has a fixed schedule for each day — it is a sequence a1,a2,…,ana1,a2,…,an (each aiai is either 00 or 11)... | [
"implementation"
] | #include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define el "\n"
#define matrix vector<vector<int>>
#define pt complex<ld>
#define ordered_set tr... | cpp |
1320 | A | A. Journey Planningtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTanya wants to go on a journey across the cities of Berland. There are nn cities situated along the main railroad line of Berland, and these cities are numbered from 11 to nn. Tanya plans her journey... | [
"data structures",
"dp",
"greedy",
"math",
"sortings"
] | #include<bits/stdc++.h>
using namespace std;
int64_t n,a,b,i;
map<int,int64_t> m;
main(){
cin >> n;
while(i++<n)
{
cin >> b;
m[b-i]+=b;
a=max(a,m[b-i]);
}
cout << a;
} | cpp |
1305 | C | C. Kuroni and Impossible Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo become the king of Codeforces; Kuroni has to solve the following problem.He is given nn numbers a1,a2,…,ana1,a2,…,an. Help Kuroni to calculate ∏1≤i<j≤n|ai−aj|∏1≤i<j≤n|ai−aj|. As re... | [
"brute force",
"combinatorics",
"math",
"number theory"
] | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int N, M; cin >> N >> M;
vector<int> A(N); for (auto &a : A) cin >> a;
sort(A.rbegin(), A.rend());
map<int, int> cnt;
vector<int> nums;
int res = 1;
for (auto a : A) {
a %= M;
if (c... | cpp |
1286 | C1 | C1. Madhouse (Easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is different with hard version only by constraints on total answers lengthIt is an interactive problemVenya joined a tour to the madhouse; in which orderlies play with patients th... | [
"brute force",
"constructive algorithms",
"interactive",
"math"
] | #include<iostream>
#include<cstring>
#include<set>
#include<algorithm>
using namespace std;
using LL = long long;
void ask(int l, int r){
cout << "? " << l << ' ' << r << endl;
}
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cou... | cpp |
1285 | F | F. Classical?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array aa, consisting of nn integers, find:max1≤i<j≤nLCM(ai,aj),max1≤i<j≤nLCM(ai,aj),where LCM(x,y)LCM(x,y) is the smallest positive integer that is divisible by both xx and yy. For example, LCM(6,8... | [
"binary search",
"combinatorics",
"number theory"
] | #include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+9;
const int mx=1e5;
int mob[maxn];
vector<int>d[maxn];
int turn[maxn];
int cnt[maxn];
int coprime(int x){
int ans=0;
for (auto v:d[x]){
ans+=mob[v]*cnt[v];
}
return ans;
}
signed main(){
ios_base::sync_with_stdio(NULL);
cin.tie(nullptr);
//freopen(... | cpp |
1296 | A | A. Array with Odd Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array aa consisting of nn integers.In one move, you can choose two indices 1≤i,j≤n1≤i,j≤n such that i≠ji≠j and set ai:=ajai:=aj. You can perform such moves any number of times (poss... | [
"math"
] | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int sum = 0;
bool odd = false, even = false;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
sum += x;
odd |= x % 2 != 0;
even |= x % 2 == 0;
}
if (sum % 2 != 0 ... | cpp |
1305 | E | E. Kuroni and the Score Distributiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done; and he is discussing with the team about the score distrib... | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | #ifdef MY_LOCAL
#include "D://competitive_programming/debug/debug.h"
#define debug(x) cerr << "[" << #x<< "]:"<<x<<"\n"
#else
#define debug(x)
#endif
#define REP(i, n) for(int i = 0; i < n; i ++)
#define REPL(i,m, n) for(int i = m; i < n; i ++)
#define SORT(arr) sort(arr.begin(), arr.end())
#define LSOne(S) (... | cpp |
1307 | C | C. Cow and Messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However; Bessie is sure that there is a secret message hidden inside.The text is a string ss of lowercase Latin letter... | [
"brute force",
"dp",
"math",
"strings"
] | #pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long int
//bool prime[30007];
//vector<int> fact(200005);
#define INF 1e9;
#ifndef ONLINE_JUDGE
#define debug(x) cerr<< #x <<"= "; _print(x);cerr<<endl;
#else
#define debug(x)
#en... | cpp |
1310 | E | E. Strange Functiontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's define the function ff of multiset aa as the multiset of number of occurences of every number, that is present in aa.E.g., f({5,5,1,2,5,2,3,3,9,5})={1,1,2,2,4}f({5,5,1,2,5,2,3,3,9,5})={1,1,2,2,... | [
"dp"
] | // LUOGU_RID: 95985746
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define ef emplace_front
#define lowbit(x) (x & (-x))
#define ti chrono::system_clock::now().time_since_epoch().count()
#define Fin(... | cpp |
1324 | A | A. Yet Another Tetris Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given some Tetris field consisting of nn columns. The initial height of the ii-th column of the field is aiai blocks. On top of these columns you can place only figures of size 2×12... | [
"implementation",
"number theory"
] | #include<bits/stdc++.h>
using namespace std;
void res(){
long long a,c = 0;
cin>>a;
long long n[a];
for( long long i = 1 ; i <= a ; i++ ){
cin>>n[i];
c+=(n[i]%2);
}
if( c==a || c==0)
{
cout<<"YES";
}
e... | cpp |
1304 | C | C. Air Conditionertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGildong owns a bulgogi restaurant. The restaurant has a lot of customers; so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memor... | [
"dp",
"greedy",
"implementation",
"sortings",
"two pointers"
] | #include <bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n, m;
cin >> n >> m;
vector<vector<int>> a(n, vector<int>(3));
for (int i = 0; i < n; i++)
cin >> a[i][0] >> a[i][1] >> a[i][2];
// sort(a.begin(), a.end());
int lt = m, ht = m;
... | cpp |
1311 | F | F. Moving Pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn points on a coordinate axis OXOX. The ii-th point is located at the integer point xixi and has a speed vivi. It is guaranteed that no two points occupy the same coordinate. All nn points mo... | [
"data structures",
"divide and conquer",
"implementation",
"sortings"
] | #include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef
tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int main() {
#ifdef... | cpp |
1296 | E2 | E2. String Coloring (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a hard version of the problem. The actual problems are different; but the easy version is almost a subtask of the hard version. Note that the constraints and the output format a... | [
"data structures",
"dp"
] | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vs = vector<string>;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define SZ(v) int(v.... | cpp |
1320 | C | C. World of Darkraft: Battle for Azathothtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRoma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.Roma has a choice to buy exactly one of nn diff... | [
"brute force",
"data structures",
"sortings"
] | #include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/extc++.h>
typedef long long ll;
#define int long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(a) (a).begin(), (a).end()
#define clr(a, h) memset(a, (... | cpp |
1295 | C | C. Obtain The Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings ss and tt consisting of lowercase Latin letters. Also you have a string zz which is initially empty. You want string zz to be equal to string tt. You can perform the followi... | [
"dp",
"greedy",
"strings"
] | /* iamujj15 */
#pragma GCC optimize("O3,unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using namespace std::chrono;
#define fstio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 5e18
#define nline "\n"
#define pb e... | cpp |
1294 | A | A. Collecting Coinstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has three sisters: Alice; Barbara, and Cerene. They're collecting coins. Currently, Alice has aa coins, Barbara has bb coins and Cerene has cc coins. Recently Polycarp has returned from the ... | [
"math"
] | #include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n;
vector<int> v;
for (int i = 0; i < 3; i++)
{
int a;
cin >> a;
v.push_back(a);
}
cin >> n;
int a =... | cpp |
1313 | C1 | C1. Skyscrapers (easy version)time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an easier version of the problem. In this version n≤1000n≤1000The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the constructio... | [
"brute force",
"data structures",
"dp",
"greedy"
] | //ANY TIME YOU SEE OPTIMIZATION PROBLEM -> BINARY SEARCH THE ANSWER!!!
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define No cout<<"No"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define YES cout<<"YES"<<endl;
#define MOD 1000000007
#define endl '\n'
void solv... | cpp |
1311 | C | C. Perform the Combotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou want to perform the combo on your opponent in one popular fighting game. The combo is the string ss consisting of nn lowercase Latin letters. To perform the combo, you have to press all buttons ... | [
"brute force"
] | #include<bits/stdc++.h>
#define nl "\n"
#define fi first
#define se second
#define pi 3.14159
#define ll long long
#define odd(a) (a&1)
#define even(a) !(a&1)
#define Mod 1'000'000'007
#define INF 2'000'000'000
#define sz(x) int(x.size())
#define charToInt(s) (s - '0')
#define ull unsigned long long
#def... | cpp |
1313 | C1 | C1. Skyscrapers (easy version)time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an easier version of the problem. In this version n≤1000n≤1000The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the constructio... | [
"brute force",
"data structures",
"dp",
"greedy"
] | #include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<map>
#include<cmath>
#include<cstdio>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
const int inf=0x3f3f3f3f,hamod=1e9+7,HAmod=1e9+9,mod=200907,N=1... | cpp |
1294 | C | C. Product of Three Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given one integer number nn. Find three distinct integers a,b,ca,b,c such that 2≤a,b,c2≤a,b,c and a⋅b⋅c=na⋅b⋅c=n or say that it is impossible to do it.If there are several answers, yo... | [
"greedy",
"math",
"number theory"
] | // LUOGU_RID: 102499094
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
int n;
cin>>n;
int x[3]={0,0,0},len=0;
for(int j=2;j*j<=n;j++)
{
if(n%j==0)
{
x[0]=j;
... | cpp |
1288 | E | E. Messenger Simulatortime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is a frequent user of the very popular messenger. He's chatting with his friends all the time. He has nn friends, numbered from 11 to nn.Recall that a permutation of size nn is an array o... | [
"data structures"
] | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll , ll> pll;
#define sp " "
#define nl "\n"
#define F first
#define S second
#define PB push_back
#define all(arr) arr.begin(), arr.end()
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
cons... | cpp |
1323 | A | A. Even Subset Sum Problemtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array aa consisting of nn positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by 22) or determine that there is no such subse... | [
"brute force",
"dp",
"greedy",
"implementation"
] | #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_set>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
#define int long long
#define ld long double
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
#define FOR(i,a,b) for (int i = a; i < b; i++... | cpp |
1303 | A | A. Erasing Zeroestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string ss. Each character is either 0 or 1.You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a cont... | [
"implementation",
"strings"
] | /******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, ... | cpp |
1292 | B | B. Aroma's Searchtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTHE SxPLAY & KIVΛ - 漂流 KIVΛ & Nikki Simmons - PerspectivesWith a new body; our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.The space can... | [
"brute force",
"constructive algorithms",
"geometry",
"greedy",
"implementation"
] | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int maxn=1e5+11;
const int Maxx=1e5+11;
const int mod=1e9+7;
//int t;
ll xo,yo,ax,ay,bx,by;
ll xs,ys,t;
void solve()
{
cin>>xo>>yo>>ax>>ay>>bx>>by;
cin>>xs>>ys>>t;
vector<pair<ll,ll>>v;
v.emplac... | cpp |
1320 | B | B. Navigation Systemtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe map of Bertown can be represented as a set of nn intersections, numbered from 11 to nn and connected by mm one-way roads. It is possible to move along the roads from any intersection to any othe... | [
"dfs and similar",
"graphs",
"shortest paths"
] | // Problem: B. Navigation System
// Contest: Codeforces - Codeforces Round #625 (Div. 1, based on Technocup 2020 Final Round)
// URL: https://codeforces.com/problemset/problem/1320/B
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#def... | cpp |
1305 | F | F. Kuroni and the Punishmenttime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKuroni is very angry at the other setters for using him as a theme! As a punishment; he forced them to solve the following problem:You have an array aa consisting of nn positive integers. ... | [
"math",
"number theory",
"probabilities"
] | // LUOGU_RID: 99461421
#include <stdio.h>
#include <random>
#include <time.h>
#include <set>
#define int long long
std::mt19937 random_pool(time(NULL));
std::set<int> PrimeFactor;
int n, a[200001], m = 1e18;
inline void Decompose(int x)
{
if(x <= 0)
return;
for(register int i = 2; i * i <= x; ++ i)
if(!(x ... | cpp |
1307 | C | C. Cow and Messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However; Bessie is sure that there is a secret message hidden inside.The text is a string ss of lowercase Latin letter... | [
"brute force",
"dp",
"math",
"strings"
] | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include<fstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring... | cpp |
1310 | D | D. Tourismtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMasha lives in a country with nn cities numbered from 11 to nn. She lives in the city number 11. There is a direct train route between each pair of distinct cities ii and jj, where i≠ji≠j. In total there are ... | [
"dp",
"graphs",
"probabilities"
] | // LUOGU_RID: 97142796
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=85;
int n,k,Map[INF][INF],p[INF],f[INF][INF],ans;
mt19937 rnd(20080209);
int gen(int l,int r) {return rnd()%(r-l+1)+l;}
void solve() {
memset(f,63,sizeof f);
for (int i=1;i<=n;i++) p[i]=gen(0,1);
f[1][... | cpp |
1321 | A | A. Contest for Robotstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is preparing the first programming contest for robots. There are nn problems in it, and a lot of robots are going to participate in it. Each robot solving the problem ii gets pipi points, a... | [
"greedy"
] | #include<bits/stdc++.h>
#include<iostream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#include<math.h>
#include<algorithm>
#include<vector>
#include<stdbool.h>
using std::cout;
const int N = 3000008;
using namespace std;
int main(){
ll n;
... | cpp |
1307 | F | F. Cow and Vacationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBessie is planning a vacation! In Cow-lifornia; there are nn cities, with n−1n−1 bidirectional roads connecting them. It is guaranteed that one can reach any city from any other city. Bessie is consi... | [
"dfs and similar",
"dsu",
"trees"
] | #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define per(i, a, b) for(int i = (a); i >= (b); i --)
#define Ede(i, u) for(int i = head[u]; i; i = e[i].nxt)
using namespace std;
#define eb emplace_back
inline int read() {
... | cpp |
1294 | F | F. Three Paths on a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an unweighted tree with nn vertices. Recall that a tree is a connected undirected graph without cycles.Your task is to choose three distinct vertices a,b,ca,b,c on this tree such t... | [
"dfs and similar",
"dp",
"greedy",
"trees"
] | #include <bits/stdc++.h>
// v.erase( unique(all(v)) , v.end() ) -----> removes duplicates and resizes the vector as so
using namespace std;
#define ll long long
#define lld long double
const lld pi = 3.14159265358979323846;
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.... | cpp |
1285 | C | C. Fadi and LCMtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday; Osama gave Fadi an integer XX, and Fadi was wondering about the minimum possible value of max(a,b)max(a,b) such that LCM(a,b)LCM(a,b) equals XX. Both aa and bb should be positive integers.LCM(a,b)L... | [
"brute force",
"math",
"number theory"
] | #include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using namespace std;
ll gcd(ll a, ll b)
{
if (a==0) return b;
return gcd(b%a, a);
}
ll lcm(ll a, ll b)
{
return (a*b)/gcd(a,b);
}
int main() {
IOS;
time_t start, en... | cpp |
1291 | A | A. Even But Not Eventime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's define a number ebne (even but not even) if and only if its sum of digits is divisible by 22 but the number itself is not divisible by 22. For example, 1313, 12271227, 185217185217 are ebne num... | [
"greedy",
"math",
"strings"
] | #include<bits/stdc++.h>
using namespace std;
int main(){
string str , ans;
int t,n,x,i;
cin>>t;
while( t-- ){
cin>>n>>str;
x = 2;
ans = "";
for( i=0 ; i<n && x>0 ; i++ ){
if( (str[i]-'0') % 2 ){
x--;
a... | cpp |
1286 | D | D. LCCtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn infinitely long Line Chillland Collider (LCC) was built in Chillland. There are nn pipes with coordinates xixi that are connected to LCC. When the experiment starts at time 0, ii-th proton flies from the ii-th... | [
"data structures",
"math",
"matrices",
"probabilities"
] | #include<bits/stdc++.h>
#define LL long long
#define mod 998244353
using namespace std;
int n,vec_t=0;
LL ans=0;
LL X[100002],v[100002];
LL p[100002][2];
struct aaa
{
int x;
bool o1,o2;
LL a,b;
}vec[200002];
inline bool cmp(aaa a,aaa b)
{
return a.a*b.b>b.a*a.b;
}
inline LL Pow(int a,int b)
{
i... | cpp |
1304 | C | C. Air Conditionertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGildong owns a bulgogi restaurant. The restaurant has a lot of customers; so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memor... | [
"dp",
"greedy",
"implementation",
"sortings",
"two pointers"
] | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define cel(x,a) ((x + a - 1) / a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define haan cout<<"YES\n";
#define na cout<<"NO\n";
#define pb push_back
#define finish if(flag){cout<<"YES\n";}else{cout<<"NO\n";}
#define start int a... | cpp |
1305 | C | C. Kuroni and Impossible Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo become the king of Codeforces; Kuroni has to solve the following problem.He is given nn numbers a1,a2,…,ana1,a2,…,an. Help Kuroni to calculate ∏1≤i<j≤n|ai−aj|∏1≤i<j≤n|ai−aj|. As re... | [
"brute force",
"combinatorics",
"math",
"number theory"
] | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = tuple<int, int>;
using vi = vector<ll>;
using vii = vector<ii>;
using vvi = vector<vi>;
using si = set<ll>;
int main() {
cin.tie(0), ios::sync_with_stdio(0);
ll n, m;
cin >> n >> m;;
vi a(n);
ll p = 1;
for (int ... | cpp |
1292 | F | F. Nora's Toy Boxestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSIHanatsuka - EMber SIHanatsuka - ATONEMENTBack in time; the seven-year-old Nora used to play lots of games with her creation ROBO_Head-02, both to have fun and enhance his abilities.One day, Nora's a... | [
"bitmasks",
"combinatorics",
"dp"
] | #include<bits/stdc++.h>
#define Cn const
#define CI Cn int&
#define N 60
#define X 1000000007
using namespace std;
int n,a[N+5],C[N+5][N+5],c,s[N+5],tt,ans=1;
int vis[N+5];void dfs(int x)
{
vis[x]=1,s[++c]=a[x];for(int i=1;i<=n;++i) !vis[i]&&(!(a[i]%a[x])||!(a[x]%a[i]))&&(dfs(i),0);
}
int w[N+5],q[N+5],g[1<... | cpp |
1313 | C1 | C1. Skyscrapers (easy version)time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an easier version of the problem. In this version n≤1000n≤1000The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the constructio... | [
"brute force",
"data structures",
"dp",
"greedy"
] | #include <bits/stdc++.h>
#define Zeoy std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define int long long
#define mp make_pair
#define endl '\n'
using namespace std;
typedef unsigned long long ULL;
typedef long long ll;
typedef pair<int, int> pii;
ty... | cpp |
1315 | B | B. Homecomingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter a long party Petya decided to return home; but he turned out to be at the opposite end of the town from his home. There are nn crossroads in the line in the town, and there is either the bus or the tr... | [
"binary search",
"dp",
"greedy",
"strings"
] | #include <bits/stdc++.h>
using namespace std;
#define ll long long
// ll int N = 1e9+7;
#define f(n) for (auto i = 0; i < n; i++)
#define fo(i, k, n) for (auto i = k; i < n; i++)
#define ff first
#define ss second
#define vi vector<int>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#d... | cpp |
1286 | D | D. LCCtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn infinitely long Line Chillland Collider (LCC) was built in Chillland. There are nn pipes with coordinates xixi that are connected to LCC. When the experiment starts at time 0, ii-th proton flies from the ii-th... | [
"data structures",
"math",
"matrices",
"probabilities"
] | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
const int MOD = 998244353;
inline ll _p(ll x, ll y) {
ll ans = 1;
while (y) {
if (y & 1) ans = ans * x % MOD;
x = x * x % MOD, y >>= 1;
}
return ans;
}
inline ll inv(ll x) { return _p(x, MO... | cpp |
1296 | C | C. Yet Another Walking Robottime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a robot on a coordinate plane. Initially; the robot is located at the point (0,0)(0,0). Its path is described as a string ss of length nn consisting of characters 'L', 'R', 'U', 'D'.... | [
"data structures",
"implementation"
] | /*████████████████████████████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████████████████████████████████
███████████████████████████▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓███████████████████████
███████████████████████████▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓... | cpp |
1288 | E | E. Messenger Simulatortime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is a frequent user of the very popular messenger. He's chatting with his friends all the time. He has nn friends, numbered from 11 to nn.Recall that a permutation of size nn is an array o... | [
"data structures"
] | #include <bits/stdc++.h>
using namespace std;
const int N=310000, NN=710000;
int n, m, bit[NN]={0}, a, mn[N], mx[N], now[N]={0}, cur;
void update(int i, int x){
for(;i<NN;i+=i&(-i))bit[i]+=x;
}
int query(int i){
int res=0;
for(;i>0;i-=i&(-i))res+=bit[i];
return res;}
int main(){
ios_base::sy... | cpp |
1304 | F1 | F1. Animal Observation (easy version)time limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is the constraint on kk.Gildong loves observing animals, so he bought two cameras to take videos of wild animals in a forest. The ... | [
"data structures",
"dp"
] | // Author: yukito8069
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define int long long
typedef long long ll;
typedef double dd;
typedef pair<int, int> pii;
int f[55][20010];
int n... | cpp |
1141 | F1 | F1. Same Sum Blocks (Easy)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is given in two editions; which differ exclusively in the constraints on the number nn.You are given an array of integers a[1],a[2],…,a[n].a[1],a[2],…,a[n]. A block is a sequence ... | [
"greedy"
] | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
enum{N=1600};
map<ll,vector<pair<int,int>>>mp;
ll a[N],p[N];
void solve(){
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],p[i]=p[i-1]+a[i];
for(int i=1;i<=n;i++)for(int j=1;j<=i;j++)
if(mp[p[i]-p[j-1]].empty())mp[p[i]-p[j-1]].push_back({j,i});
else if(mp... | cpp |
1310 | D | D. Tourismtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMasha lives in a country with nn cities numbered from 11 to nn. She lives in the city number 11. There is a direct train route between each pair of distinct cities ii and jj, where i≠ji≠j. In total there are ... | [
"dp",
"graphs",
"probabilities"
] | // LUOGU_RID: 90587440
#include<bits/stdc++.h>
using namespace std;
const int N=90,K=20,INF=1e9+10;
int n,k,ans=INF,rand_cnt;
int g[N][N];
int col[N],f[K][N];
inline void get_rand()
{
for(int i=1;i<=n;i++) col[i]=rand()%2;
return ;
}
int solve()
{
memset(f,0x3f,sizeof f);
f[0][1]=0;
for(int i=0;i... | cpp |
1295 | C | C. Obtain The Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings ss and tt consisting of lowercase Latin letters. Also you have a string zz which is initially empty. You want string zz to be equal to string tt. You can perform the followi... | [
"dp",
"greedy",
"strings"
] | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
auto solve() {
string s, t;
cin >> s >> t;
s = "_" + s;
int n = (int)s.length();
vector<int> mp(26, n);
for (int i = 1; i < n; ++i) {
mp[s[i] - 'a'] = min(mp[s[i] - 'a'], i);
}
for (auto j : t) {
if (mp[j - 'a'] == ... | cpp |
1303 | E | E. Erase Subsequencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string ss. You can build new string pp from ss using the following operation no more than two times: choose any subsequence si1,si2,…,siksi1,si2,…,sik where 1≤i1<i2<⋯<ik≤|s|1≤i1<i... | [
"dp",
"strings"
] | #include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define mp make_pair
constexpr int N = (int)1e5 + 111;
constexpr int INF = (int)1e9 + 11;
constexpr int md = (int)1e9+7;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,p... | cpp |
1316 | A | A. Grade Allocationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputnn students are taking an exam. The highest possible score at this exam is mm. Let aiai be the score of the ii-th student. You have access to the school database which stores the results of all studen... | [
"implementation"
] | #include <stdio.h>
int main(){
int t,n,m,sum,temp;
scanf("%d",&t);
while(t--){
temp=0;
sum=0;
scanf("%d%d",&n,&m);
while(n--){
scanf("%d",&temp);
sum+=temp;
}
if(sum<m)
printf("%d\n",sum);
else
printf("%d\n",m);
}
return 0;
}
| cpp |
1292 | D | D. Chaotic V.time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputÆsir - CHAOS Æsir - V."Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.The time right now...... 00:01:12......It's time."The emotion samples are now suffici... | [
"dp",
"graphs",
"greedy",
"math",
"number theory",
"trees"
] | #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define per(i, a, b) for(int i = (a); i >= (b); i --)
#define Ede(i, u) for(int i = head[u]; i; i = e[i].nxt)
using namespace std;
inline int read() {
int x = 0, f = 1; char c =... | cpp |
1312 | D | D. Count the Arraystime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYour task is to calculate the number of arrays such that: each array contains nn elements; each element is an integer from 11 to mm; for each array, there is exactly one pair of equal elements; f... | [
"combinatorics",
"math"
] | #include<bits/stdc++.h>
using namespace std;
const int MOD=998244353;
int main()
{
int n, m, k; long long t, u = 1;
if (cin >> n >> m, k = n-2, k == 0)
cout << 0, exit(0);
for (t = k; k > 1; --k)
t <<= 1, t %= MOD;
for (k = m-n+1; m > k; --m)
t *= m, t %= MOD;
for (k = 2; k < n; ++k)
u *= k, u %= MOD;
for (k = MOD-... | cpp |
1301 | E | E. Nanosofttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWarawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building.The logo of Nanosoft can be des... | [
"binary search",
"data structures",
"dp",
"implementation"
] | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<pair<int, int>, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define AboT... | cpp |
1299 | A | A. Anu Has a Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnu has created her own function ff: f(x,y)=(x|y)−yf(x,y)=(x|y)−y where || denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9f(11,6)=(11|6)−6=15−6=9. It can be proved that for an... | [
"brute force",
"greedy",
"math"
] | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#pragma GCC optimization("g", on)
//#pragma GCC optimization("03")
////#pragma comment(linker, "/stack:200000000")
////#pragma GCC optimize("Ofast")
//#pra... | cpp |
1141 | E | E. Superhero Battletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA superhero fights with a monster. The battle consists of rounds; each of which lasts exactly nn minutes. After a round ends, the next round starts immediately. This is repeated over and over again.E... | [
"math"
] | #include <bits/stdc++.h>
using namespace std;
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define clr(d, v) memset(d,v,sizeof(d))
#define ll long long
void file() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
int main() {
file();
ll h;
... | cpp |
1304 | C | C. Air Conditionertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGildong owns a bulgogi restaurant. The restaurant has a lot of customers; so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memor... | [
"dp",
"greedy",
"implementation",
"sortings",
"two pointers"
] | #include<bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef pair<ll,ll> pi;
const int N=2e5+10;
pi isinter(pi a,pi b) {
if (a.first > b.first)swap(a, b);
if (a.first == b.first && b.second >= a.second)swap(a, b);
// nested
if (a.second >= b.second) {
ret... | cpp |
1284 | D | D. New Year and Conferencetime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputFilled with optimism; Hyunuk will host a conference about how great this new year will be!The conference will have nn lectures. Hyunuk has two candidate venues aa and bb. For each of the nn l... | [
"binary search",
"data structures",
"hashing",
"sortings"
] | #include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define xs(a) cout<<setiosflags(ios::fixed)<<setprecision(a);
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define mem(a,b) memset(a,b,sizeof(a));
u... | cpp |
1287 | A | A. Angry Studentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's a walking tour day in SIS.Winter; so tt groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.Initially, some students are an... | [
"greedy",
"implementation"
] | /*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒▒▒▒▒▒▒▒▒▒▀██████▄
░███▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████ █▒▒▐▌
░░░... | cpp |
1290 | F | F. Making Shapestime limit per test5 secondsmemory limit per test768 megabytesinputstandard inputoutputstandard outputYou are given nn pairwise non-collinear two-dimensional vectors. You can make shapes in the two-dimensional plane with these vectors in the following fashion: Start at the origin (0,0)(0,0). Choose a ve... | [
"dp"
] | #include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0' or ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0' and ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
void write(int x){
if(x<0) putchar('-'),x=-x;
if(x>=... | cpp |
1316 | E | E. Team Buildingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice; the president of club FCB, wants to build a team for the new volleyball tournament. The team should consist of pp players playing in pp different positions. She also recognizes the importance of ... | [
"bitmasks",
"dp",
"greedy",
"sortings"
] | #include<bits/stdc++.h>
#define ll long long
#define el '\n'
#define all(a) a.begin(),a.end()
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_orde... | cpp |
1324 | E | E. Sleeping Scheduletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVova had a pretty weird sleeping schedule. There are hh hours in a day. Vova will sleep exactly nn times. The ii-th time he will sleep exactly after aiai hours from the time he woke up. You can assu... | [
"dp",
"implementation"
] | #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//---------------------------------------------------------------------------------
#define ll long long
#define fixed(n) cout << fixed << setprecision(n)
#define sz(x) int(x.size())
#define TC int t; cin >> t; ... | cpp |
1316 | F | F. Battalion Strengthtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn officers in the Army of Byteland. Each officer has some power associated with him. The power of the ii-th officer is denoted by pipi. As the war is fast approaching, the General would ... | [
"data structures",
"divide and conquer",
"probabilities"
] | #include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <cassert>
#include <numeric>
#include <type_traits>
#ifdef _MSC_VER
#incl... | cpp |
1293 | B | B. JOE is on TV!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output3R2 - Standby for ActionOur dear Cafe's owner; JOE Miller, will soon take part in a new game TV-show "1 vs. nn"!The game goes in rounds, where in each round the host asks JOE and his opponents a common q... | [
"combinatorics",
"greedy",
"math"
] | #include<bits/stdc++.h>
using namespace std;
#define N 200001
#define ll long long
int main(){
ll n;
cin>>n;
//maximum possible value that i can get is 2
double x=0.00000;
while(n>0){
x+=(double)1/n;
n--;
}
cout<<x<<endl;
return 0;
} | cpp |
1311 | D | D. Three Integerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers a≤b≤ca≤b≤c.In one move, you can add +1+1 or −1−1 to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero)... | [
"brute force",
"math"
] | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int too=1e9;
int x,y,z;
cin>>x>>y>>z;
int px,py,pz;
for(int i=1; i<=10000; i++)
{
for(int j=i; j<=10000*2; j+=i)
{
for(int l=j; l<=10000*3; l+=j)
{
if(abs(x-i)+abs(y-j)+abs(z-l)<too)
{
too=abs(x-i)+abs(y-j)+abs(z-l);
px=i;
py=j;
pz=l... | cpp |
1295 | B | B. Infinite Prefixestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given string ss of length nn consisting of 0-s and 1-s. You build an infinite string tt as a concatenation of an infinite number of strings ss, or t=ssss…t=ssss… For example, if s=s= 10010, ... | [
"math",
"strings"
] | /// endless ?
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pii pair<int, int>
#define all(x... | cpp |
1305 | C | C. Kuroni and Impossible Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo become the king of Codeforces; Kuroni has to solve the following problem.He is given nn numbers a1,a2,…,ana1,a2,…,an. Help Kuroni to calculate ∏1≤i<j≤n|ai−aj|∏1≤i<j≤n|ai−aj|. As re... | [
"brute force",
"combinatorics",
"math",
"number theory"
] | #include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define all(x) x.begin(), x.end()
#define ull unsigned long long
#define pii pair < int , int >... | cpp |
1288 | F | F. Red-Blue Graphtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a bipartite graph: the first part of this graph contains n1n1 vertices, the second part contains n2n2 vertices, and there are mm edges. The graph can contain multiple edges.Initially, each... | [
"constructive algorithms",
"flows"
] | // LUOGU_RID: 101592253
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
using namespace std;
inline int read() {
int x = 0; bool op = 0;
c... | cpp |
1288 | F | F. Red-Blue Graphtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a bipartite graph: the first part of this graph contains n1n1 vertices, the second part contains n2n2 vertices, and there are mm edges. The graph can contain multiple edges.Initially, each... | [
"constructive algorithms",
"flows"
] | #include<bits/stdc++.h>
using namespace std;
const int N = 443;
int n1, n2, m, r, b;
string s1, s2;
int u[N];
int v[N];
struct edge
{
int y, c, f, cost;
edge() {};
edge(int y, int c, int f, int cost) : y(y), c(c), f(f), cost(cost) {};
};
int bal[N][N];
int s, t, oldS, oldT, V;
vecto... | cpp |
1299 | D | D. Around the Worldtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGuy-Manuel and Thomas are planning 144144 trips around the world.You are given a simple weighted undirected connected graph with nn vertexes and mm edges with the following restriction: there isn't a... | [
"bitmasks",
"combinatorics",
"dfs and similar",
"dp",
"graphs",
"graphs",
"math",
"trees"
] | #include<bits/stdc++.h>
#define I inline
#define ll long long
#define db double
#define lb long db
#define N (100000+5)
#define M (500+5)
#define K (700+5)
#define mod 1000000007
#define Mod (mod-1)
#define eps (1e-5)
#define ui unsigned int
#define ull unsigned ll
#define Gc() getchar()
#define Me(x,y) memset(x,y,size... | cpp |
1291 | B | B. Array Sharpeningtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're given an array a1,…,ana1,…,an of nn non-negative integers.Let's call it sharpened if and only if there exists an integer 1≤k≤n1≤k≤n such that a1<a2<…<aka1<a2<…<ak and ak>ak+1>…>anak>ak+1>…>an. ... | [
"greedy",
"implementation"
] | // CF template, version 3.0
#include <bits/stdc++.h>
using namespace std;
#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define g... | cpp |
1300 | A | A. Non-zerotime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGuy-Manuel and Thomas have an array aa of nn integers [a1,a2,…,ana1,a2,…,an]. In one step they can add 11 to any element of the array. Formally, in one step they can choose any integer index ii (1≤i≤n1≤i≤n) a... | [
"implementation",
"math"
] | #include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0), ios::sync_with_stdio(0);
int t, n, x;
cin >> t;
while (t--) {
cin >> n;
int sum = 0, zeros = 0;
while (n--) {
cin >> x;
if (x == 0) zeros++;
sum += x;
}
cout << (zeros + (sum + zeros ==... | cpp |
1305 | G | G. Kuroni and Antihypetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKuroni isn't good at economics. So he decided to found a new financial pyramid called Antihype. It has the following rules: You can join the pyramid for free and get 00 coins. If you are already... | [
"bitmasks",
"brute force",
"dp",
"dsu",
"graphs"
] | #include <bits/stdc++.h>
#define sz(v) (int) (v).size()
#define all(v) begin(v), end(v)
#define view(v, l, r) begin(v) + l, begin(v) + r + 1
#define dbg(fmt...) fprintf(stderr, fmt)
#define fi first
#define se second
using namespace std;
using i64 = long long;
using i128 = __int128_t;
using u32 = unsigned;
u... | cpp |
1141 | D | D. Colored Bootstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn left boots and nn right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings ll and rr, both of length nn. The... | [
"greedy",
"implementation"
] | #include<iostream>
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std;
//using L = __int128;
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define nd "\n"
... | cpp |
1313 | A | A. Fast Food Restauranttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTired of boring office work; Denis decided to open a fast food restaurant.On the first day he made aa portions of dumplings, bb portions of cranberry juice and cc pancakes with condensed milk.The ... | [
"brute force",
"greedy",
"implementation"
] | //Dhiraj's Template
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define testcase int t;cin>>t;while(t--)
#define forloop(start,size) for(int i=start;i<size;i++)
#define all(v) v.begin(),v.end()
#define foreachx(v) for(auto&x:v)
#define maxofvec(v) *max_element(v.begin(),v.end())
#defi... | cpp |
1288 | C | C. Two Arraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers nn and mm. Calculate the number of pairs of arrays (a,b)(a,b) such that: the length of both arrays is equal to mm; each element of each array is an integer between 11 and nn (in... | [
"combinatorics",
"dp"
] | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define vec vector
#define ar array
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define dbg(...) [](const auto&...x){ char c=... | cpp |
1305 | C | C. Kuroni and Impossible Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo become the king of Codeforces; Kuroni has to solve the following problem.He is given nn numbers a1,a2,…,ana1,a2,…,an. Help Kuroni to calculate ∏1≤i<j≤n|ai−aj|∏1≤i<j≤n|ai−aj|. As re... | [
"brute force",
"combinatorics",
"math",
"number theory"
] | #pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,avx2,fma,mmx,sse2,sse3,sse4")
#pragma GCC optimization("unroll-loops")
///for pragma could get a runtime/tle too
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back... | cpp |
1310 | A | A. Recommendationstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputVK news recommendation system daily selects interesting publications of one of nn disjoint categories for each user. Each publication belongs to exactly one category. For each category ii batch algori... | [
"data structures",
"greedy",
"sortings"
] | #include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define multiordered_set tree<int, null_type,less_equal<int>, rb_... | cpp |
1286 | A | A. Garlandtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVadim loves decorating the Christmas tree; so he got a beautiful garland as a present. It consists of nn light bulbs in a single row. Each bulb has a number from 11 to nn (in arbitrary order), such that all th... | [
"dp",
"greedy",
"sortings"
] | // ඞ
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include "debug.h"
#define dbg(...) debug_out(splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...)
#endif
#defin... | cpp |
1315 | A | A. Dead Pixeltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputScreen resolution of Polycarp's monitor is a×ba×b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x,y)(x,y) (0≤x<a,0≤y<b0≤x<a,0≤y<b). You can consider columns of pixels to ... | [
"implementation"
] | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int T,a,b,c,d,a1,a2;
string s;
#define ios std::ios::sync_with_stdio(false),cin.tie(0), cout.tie(0)
int main() {
ios;
cin >> T;
while (T--)
{
cin >> a >> b >> c >> d;
c++;
d++;
a1 = max((c-1) * b,(a-c) *b);
a2 = max((d-1)*a,(b-d)*a);
... | cpp |
1292 | F | F. Nora's Toy Boxestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSIHanatsuka - EMber SIHanatsuka - ATONEMENTBack in time; the seven-year-old Nora used to play lots of games with her creation ROBO_Head-02, both to have fun and enhance his abilities.One day, Nora's a... | [
"bitmasks",
"combinatorics",
"dp"
] | #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define per(i, a, b) for(int i = (a); i >= (b); i --)
#define Ede(i, u) for(int i = head[u]; i; i = e[i].nxt)
using namespace std;
#define eb emplace_back
const int P = 1e9 + 7... | cpp |
1286 | B | B. Numbers on Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEvlampiy was gifted a rooted tree. The vertices of the tree are numbered from 11 to nn. Each of its vertices also has an integer aiai written on it. For each vertex ii, Evlampiy calculated cici — the n... | [
"constructive algorithms",
"data structures",
"dfs and similar",
"graphs",
"greedy",
"trees"
] | #include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep3(i,m,n) for(int i=(m);i<(n);i++)
#define foreach(x,a) for(auto& (x) : (a) )
#define endl '\n'
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ... | cpp |
1320 | A | A. Journey Planningtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTanya wants to go on a journey across the cities of Berland. There are nn cities situated along the main railroad line of Berland, and these cities are numbered from 11 to nn. Tanya plans her journey... | [
"data structures",
"dp",
"greedy",
"math",
"sortings"
] | #include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
using namespace std ;
void solve() {
ll n ;
cin>>n ;
vector<ll>dp(n,0);
map<ll,ll>mp ;
vector<ll>v(n,0);
for(ll i = 0 ; i < n ; i++){
cin>>v[i];
mp[i-v[i]] += v[i] ;
}
... | cpp |
1305 | F | F. Kuroni and the Punishmenttime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKuroni is very angry at the other setters for using him as a theme! As a punishment; he forced them to solve the following problem:You have an array aa consisting of nn positive integers. ... | [
"math",
"number theory",
"probabilities"
] | // #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "complex"
using namespace std;
using namespace __gnu_pbds;
// template <class T>
// using o_set = tree<T, int_type, less<T>, rb_tr... | cpp |
1320 | D | D. Reachable Stringstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem; we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a... | [
"data structures",
"hashing",
"strings"
] | /*
DavitMarg
In a honky-tonk,
Down in Mexico
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <ran... | cpp |
1322 | E | E. Median Mountain Rangetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBerland — is a huge country with diverse geography. One of the most famous natural attractions of Berland is the "Median mountain range". This mountain range is nn mountain peaks, located on one... | [
"data structures"
] | // BEGIN BOILERPLATE CODE
#include <bits/stdc++.h>
using namespace std;
#ifdef KAMIRULEZ
const bool kami_loc = true;
const long long kami_seed = 69420;
#else
const bool kami_loc = false;
const long long kami_seed = chrono::steady_clock::now().time_since_epoch().count();
#endif
const string kami_fi =... | cpp |
1324 | A | A. Yet Another Tetris Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given some Tetris field consisting of nn columns. The initial height of the ii-th column of the field is aiai blocks. On top of these columns you can place only figures of size 2×12... | [
"implementation",
"number theory"
] | #include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int32_t test; cin >> test;
int32_t n, tmp; bool check;
while (test--)
{
cin >> n;
set <int32_t> st;
for (int i = 0; i < n; i++)
... | cpp |
1324 | A | A. Yet Another Tetris Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given some Tetris field consisting of nn columns. The initial height of the ii-th column of the field is aiai blocks. On top of these columns you can place only figures of size 2×12... | [
"implementation",
"number theory"
] | #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<unordered_map>
typedef long long ll;
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int counter=0;
int p;
cin>>p;
for(int i=1;i<n;i++)
{
int q;
cin>>q;
if(abs(p-q)%2!=0)
... | cpp |
1312 | F | F. Attack on Red Kingdomtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe Red Kingdom is attacked by the White King and the Black King!The Kingdom is guarded by nn castles, the ii-th castle is defended by aiai soldiers. To conquer the Red Kingdom, the Kings have t... | [
"games",
"two pointers"
] | #include<bits/stdc++.h>
using namespace std;
long long n , x , y , z , dp [10004][4] , arr [300005];
vector < int > bt [4];
int grundy ( long long x , int y )
{
if ( x < 2e3 ) return dp [x][y];
else
{
int xx = ( x - 1000 ) % bt [y] . size ();
return bt [y][xx];
}
}
int main(... | cpp |
1305 | B | B. Kuroni and Simple Stringstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNow that Kuroni has reached 10 years old; he is a big boy and doesn't like arrays of integers as presents anymore. This year he wants a Bracket sequence as a Birthday present. More specifical... | [
"constructive algorithms",
"greedy",
"strings",
"two pointers"
] | #include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
string brackets;
cin >> brackets;
int length = brackets.length();
int left = 0, right = length - 1;
vector<int> ans;
while (left < right){
while (left < right && ... | cpp |
1295 | E | E. Permutation Separationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p1,p2,…,pnp1,p2,…,pn (an array where each integer from 11 to nn appears exactly once). The weight of the ii-th element of this permutation is aiai.At first, you sepa... | [
"data structures",
"divide and conquer"
] | #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#ifndef ATCODER_INTERNAL_BITOP_HPP
#define ATCODER_INTERNAL_BITOP_HPP 1
#ifdef _MSC_VER
#include <intrin.h>
#include<cassert>
#endif
namespace atcoder {
namespace internal {
int ceil_pow2(int n) {
i... | cpp |
1303 | D | D. Fill The Bagtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a bag of size nn. Also you have mm boxes. The size of ii-th box is aiai, where each aiai is an integer non-negative power of two.You can divide boxes into two parts of equal size. Your goal is t... | [
"bitmasks",
"greedy"
] | #include <bits\stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
vector<unsigned> bs((int)1e5);
vector<unsigned> ps(65, 0);
while (t--)
{
unsigned long long n,k; cin >> n >> k;
long long sum = 0;
... | cpp |
1299 | A | A. Anu Has a Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnu has created her own function ff: f(x,y)=(x|y)−yf(x,y)=(x|y)−y where || denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9f(11,6)=(11|6)−6=15−6=9. It can be proved that for an... | [
"brute force",
"greedy",
"math"
] | #include <bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
int n;
cin >> n;
vector<int> a(n);
for(int i=0;i<n;i++)cin>>a[i];
vector<int> cnt(30, 0);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 30; j++)
{
if (a[i] &... | cpp |
1286 | C1 | C1. Madhouse (Easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is different with hard version only by constraints on total answers lengthIt is an interactive problemVenya joined a tour to the madhouse; in which orderlies play with patients th... | [
"brute force",
"constructive algorithms",
"interactive",
"math"
] | #include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
char an[105];
struct cx{
int len,tn[26];
}sp[105];
int tn[105][26],tn1[26],tn2[26];
bool zqr(cx a1,cx a2)
{
r... | cpp |
1295 | E | E. Permutation Separationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p1,p2,…,pnp1,p2,…,pn (an array where each integer from 11 to nn appears exactly once). The weight of the ii-th element of this permutation is aiai.At first, you sepa... | [
"data structures",
"divide and conquer"
] | // #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/... | cpp |
1296 | C | C. Yet Another Walking Robottime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a robot on a coordinate plane. Initially; the robot is located at the point (0,0)(0,0). Its path is described as a string ss of length nn consisting of characters 'L', 'R', 'U', 'D'.... | [
"data structures",
"implementation"
] | #include <bits/stdc++.h>
using namespace std;
// #define int long long int
void solve()
{
int n;
cin >> n;
string s;
cin >> s;
int u = 0, v = 0;
map<pair<int, int>, int> mp;
int ans = (n + 5);
int l, r;
mp[{0, 0}] = 0;
for (int i = 0; i < n; i++)
{
i... | cpp |
1299 | C | C. Water Balancetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn water tanks in a row, ii-th of them contains aiai liters of water. The tanks are numbered from 11 to nn from left to right.You can perform the following operation: choose some subsegment [l... | [
"data structures",
"geometry",
"greedy"
] | #include<bits/stdc++.h>
using namespace std;
using pl=pair<long long,long long>;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
stack<pl> st;
for(int i=0;i<n;i++){
long long x;
cin >> x;
pl cur={x,1};
while(!st.empty()){
pl tp=st.top();
... | cpp |
1311 | D | D. Three Integerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers a≤b≤ca≤b≤c.In one move, you can add +1+1 or −1−1 to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero)... | [
"brute force",
"math"
] | #include<bits/stdc++.h>
#define nl "\n"
#define fi first
#define se second
#define pi 3.14159
#define ll long long
#define odd(a) (a&1)
#define even(a) !(a&1)
#define Mod 1'000'000'007
#define INF 2'000'000'000
#define sz(x) int(x.size())
#define charToInt(s) (s - '0')
#define ull unsigned long long
#def... | cpp |
13 | A | A. Numberstime limit per test1 secondmemory limit per test64 megabytesinputstdinoutputstdoutLittle Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.Now he wonders what is an average value of ... | [
"implementation",
"math"
] | #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <bits/stdc++.h>
int gcd(int a,int b);
using namespace std;
int main()
{
short a;
cin>>a;
short b=a;
short z=0;
short rem;
short newa;
vector<short>h;
for(short i=2;i<b;i++)
{
... | cpp |
1284 | D | D. New Year and Conferencetime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputFilled with optimism; Hyunuk will host a conference about how great this new year will be!The conference will have nn lectures. Hyunuk has two candidate venues aa and bb. For each of the nn l... | [
"binary search",
"data structures",
"hashing",
"sortings"
] | #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const ll mod = 1e11;
const int mm = 1e5 + 10;
struct node{
int x,f,s,p;
node(){}
node(int x,int f,int s,int p):x(x),f(f),s(s),p(p){}
friend operator <(node a,node b){
return a.x==b.x?a.p>b.p:a.x<b.x;
}
... | cpp |
1141 | F1 | F1. Same Sum Blocks (Easy)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is given in two editions; which differ exclusively in the constraints on the number nn.You are given an array of integers a[1],a[2],…,a[n].a[1],a[2],…,a[n]. A block is a sequence ... | [
"greedy"
] | #include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <deque>
#include <bitset>
#include <unordered_map>
using namespace std;
#define x first
#define y second
#define mest(x,y) memset(x, y, sizeof x)
#defi... | cpp |
1141 | C | C. Polycarp Restores Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn array of integers p1,p2,…,pnp1,p2,…,pn is called a permutation if it contains each number from 11 to nn exactly once. For example, the following arrays are permutations: [3,1,2][3,1,2... | [
"math"
] | #include <bits/stdc++.h>
#define nl << "\n"
#define spc << " " <<
#define pt cout <<
using namespace std;
typedef long long ll;
//#define int long long
#define pii pair<int, int>
int mod = 1e9 + 7;
int MAX = 1e9 + 1;
int MIN = -1e9;
double eps = 1e-7;
bool check(vector<int> arr,int n){
sort(arr.begi... | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.