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 |
|---|---|---|---|---|---|
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"
] | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
/*CPPCode*/
using namespace std;
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vs vector<string>
#define vpi vector<pair<int,int>>
#define pi pair<int,int>
#define ff ... | 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"
] | #include<bits/stdc++.h>
#define eb emplace_back
#define ep emplace
static const int N = 500005;
int n, m, res;
int a[N], b[N], d[N], ans[N];
std::vector<int> c[N];
std::set<int> s1, s2;
void insert(int x) {
if (x > 1 && !d[x - 1]) s1.erase(x - 1); else s1.insert(x - 1);
if (x < n && !d[x + 1]) s1.eras... | 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>
#include <ext/pb_ds/assoc_container.hpp>
//#include<boost/algorithm/string.hpp>
//pragmas
#pragma GCC optimize("O3")
//types
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ull unsigned long long int
#define vec vector<... | cpp |
13 | C | C. Sequencetime limit per test1 secondmemory limit per test64 megabytesinputstdinoutputstdoutLittle Petya likes to play very much. And most of all he likes to play the following game:He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. ... | [
"dp",
"sortings"
] | // Problem: Sequence
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/CF13C
// Memory Limit: 62 MB
// Time Limit: 1000 ms
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;
const int MAX = 5E3 + 7;
ll n;
ll a[MAX], b[MAX];
ll S[MAX] = {1 << 30}... | cpp |
1325 | B | B. CopyCopyCopyCopyCopytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEhab has an array aa of length nn. He has just enough free time to make a new array consisting of nn copies of the old array, written back-to-back. What will be the length of the new array's longe... | [
"greedy",
"implementation"
] | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <stack>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define MAX 100001
#include <map>
const int MOD = 1e9 + 7;
const ll MaxVal ... | 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"
] | ///Moba8ta gya mn el 2alb
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#... | cpp |
1296 | D | D. Fight with Monsterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn monsters standing in a row numbered from 11 to nn. The ii-th monster has hihi health points (hp). You have your attack power equal to aa hp and your opponent has his attack power equal... | [
"greedy",
"sortings"
] | /*
"THE STONE THAT THE BUILDERS REJECTED HAS BECOME THE CORNERSTONE.
THIS IS THE LORD'S DOING , THIS IS MARVELOUS IN OUR EYES ." (118 :22-23 ) ❤
Dear online judge:
I have not failed. I've just found 10,000 ways that won't work.
_Thomas A. Edison
"لكن بالنسبة لكَ كُن قويًا ولا تستسلم لأنَّ ع... | cpp |
1288 | B | B. Yet Another Meme Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers AA and BB, calculate the number of pairs (a,b)(a,b) such that 1≤a≤A1≤a≤A, 1≤b≤B1≤b≤B, and the equation a⋅b+a+b=conc(a,b)a⋅b+a+b=conc(a,b) is true; conc(a,b)conc(a,b)... | [
"math"
] | #include <bits/stdc++.h>
using namespace std;
#define sz(a) ((int) (a).size())
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define endl '\n'
#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int N=2e5;
ll gcd (ll a, ... | 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 ll long long int
#define lb long double
#define pb push_back
#define f first
#define s second
const int mod=1e9+7;
const int mod1=998244353;
void burn ()
{
int n,p;
cin >> n;
while(n--)
cin>>p;
return;
}
void reveal ()
{
... | 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<bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <set>
#include <map>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <string.h>
#include <string>
#include <sstream>
using namespace std;
//#define int long long int
#define FIO ios_base::sync_with_stdio(false);c... | 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>
#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 |
1285 | B | B. Just Eat It!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday; Yasser and Adel are at the shop buying cupcakes. There are nn cupcake types, arranged from 11 to nn on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type ii i... | [
"dp",
"greedy",
"implementation"
] | #pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int x, int y) {return (rng() % (y-x +1)) + x;};
#define ll long long
#define pb p... | cpp |
13 | C | C. Sequencetime limit per test1 secondmemory limit per test64 megabytesinputstdinoutputstdoutLittle Petya likes to play very much. And most of all he likes to play the following game:He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. ... | [
"dp",
"sortings"
] | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
int main()
{
ll n,ans=0,arr[5005];
priority_queue<ll> pq;
cin >> n;
for(ll i=1;i<=n;i++)
{
cin >> arr[i];
if(!pq.empty()&&pq.top()>arr[i])
{
ans=ans+pq.top()-arr[i];
pq.pop();
pq.push(arr[i]);
}
pq.push(arr[i])... | cpp |
1294 | E | E. Obtain a Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangular matrix of size n×mn×m consisting of integers from 11 to 2⋅1052⋅105.In one move, you can: choose any element of the matrix and change its value to any integer between ... | [
"greedy",
"implementation",
"math"
] | #include <bits/stdc++.h>
using namespace std;
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define all(_) _.begin(), _.end()
#define rall(_) _.rbegin(), _.rend()
#define sz(_) (int)_.size()
#define fs first
#define se second
#define Odd(_x) ((_x) & 1)
using i64 = long long;
using ll = ... | cpp |
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;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define ln "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653... | cpp |
1300 | B | B. Assigning to Classestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputReminder: the median of the array [a1,a2,…,a2k+1][a1,a2,…,a2k+1] of odd number of elements is defined as follows: let [b1,b2,…,b2k+1][b1,b2,…,b2k+1] be the elements of the array in the sorted ord... | [
"greedy",
"implementation",
"sortings"
] | #include<bits/stdc++.h>
using namespace std;
int main(){
int t;cin>>t;
while(t--){
int n;cin>>n;
vector<int>v(2*n);
for(int i=0;i<(2*n);i++){
cin>>v[i];
}
sort(v.begin(),v.end());
cout<<(v[n]-v[n-1])<<"\n";
}
return 0;
} | 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 <bits/stdc++.h>
using namespace std;
// clang-format off
namespace { enum operand_type_enum : uint32_t { RAW = 0, COMPOSED = 1 << 1, REQUIRE_PARAM = 1 << 2, }; template <class T> concept has_operand_type = requires() { { T::operand_type } -> convertible_to<uint32_t>; }; template <class T> class operand_type... | cpp |
1312 | C | C. Adding Powerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you are performing the following algorithm. There is an array v1,v2,…,vnv1,v2,…,vn filled with zeroes at start. The following operation is applied to the array several times — at ii-th step (00-... | [
"bitmasks",
"greedy",
"implementation",
"math",
"number theory",
"ternary search"
] | #include <bits/stdc++.h>
using namespace std;
#define int long long int
int bs(int k, int x)
{
int l = 0, h;
int p = 1;
for (int i = 1; i < 60; i++)
{
if (p * k < 0)
break;
h = i;
p = p * k;
}
int ans = -1;
while (l <= h)
{
i... | 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"
] | /******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
************************************... | cpp |
1316 | D | D. Nash Matrixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNash designed an interesting yet simple board game where a player is simply required to follow instructions written on the cell where the player currently stands. This board game is played on the n×nn×n b... | [
"constructive algorithms",
"dfs and similar",
"graphs",
"implementation"
] | /**
* Author: Richw818
* Created: 01.25.2023 23:09:49
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string dir = "ULDR";
int n; cin >> n;
ve... | cpp |
1299 | E | E. So Meantime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is interactive.We have hidden a permutation p1,p2,…,pnp1,p2,…,pn of numbers from 11 to nn from you, where nn is even. You can try to guess it using the following queries:?? kk a1a1 a2a2 …… akak.I... | [
"interactive",
"math"
] | #include<bits/stdc++.h>
#define vi std::vector<int>
#define N 805
int n;
vi V[N<<2];
int a[N<<2];
inline int qry1(int i,int l,int r,int x,int y){
printf("? %d ",(r-l+1)<<1);
for(int j=l;j<=r;j++) if(j!=i)
printf("%d %d ",V[j][0],V[j][1]);
printf("%d %d\n",x,y),fflush(stdout);
int res;
scanf("%d... | cpp |
1284 | F | F. New Year and Social Networktime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputDonghyun's new social network service (SNS) contains nn users numbered 1,2,…,n1,2,…,n. Internally, their network is a tree graph, so there are n−1n−1 direct connections between each user.... | [
"data structures",
"graph matchings",
"graphs",
"math",
"trees"
] | // LUOGU_RID: 99128720
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0; bool f = 0; char ch = getchar();
while (!isdigit(ch)) f |= ch == '-', ch = getchar();
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
void write(int x) {
if (x ... | cpp |
1301 | F | F. Super Jabertime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJaber is a superhero in a large country that can be described as a grid with nn rows and mm columns, where every cell in that grid contains a different city.Jaber gave every city in that country a specifi... | [
"dfs and similar",
"graphs",
"implementation",
"shortest paths"
] | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mpp make_pair
#define ve ve... | cpp |
1304 | E | E. 1-Trees and Queriestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGildong was hiking a mountain; walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?Then... | [
"data structures",
"dfs and similar",
"shortest paths",
"trees"
] | #include<bits/stdc++.h>
using namespace std;
//#define int long long
vector <int> h;
vector <vector <int> > g, pred;
vector <int> tin, tout;
int timer = 0;
void dfs(int v, int p = -1)
{
tin[v] = timer++;
for(int i = 0; i < g[v].size(); i++)
{
if(g[v][i] != p)
{
h[g[v][i]] = h[v] + 1;
pred... | cpp |
1310 | B | B. Double Eliminationtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe biggest event of the year – Cota 2 world championship "The Innernational" is right around the corner. 2n2n teams will compete in a double-elimination format (please, carefully read problem stat... | [
"dp",
"implementation"
] | #include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
using LL = long long;
const int maxn = 1e6 + 5;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
... | cpp |
1313 | C2 | C2. Skyscrapers (hard version)time limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is a harder version of the problem. In this version n≤500000n≤500000The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the constru... | [
"data structures",
"dp",
"greedy"
] | #include<bits/stdc++.h>
using namespace std;
long long n,k,a[500005],lef[500005],righ[500005],ansr[5000005],ansl[500005],i,ans,ind;
int main(){
cin>>n;
for(k=1;k<=n;k++)
cin>>a[k];
for(k=1;k<=n;k++){
i=k-1;
while(i>0 && a[i]>a[k]){
i=lef[i];
}
lef[k]=i;
ansl[k]=ansl[i]+(k-i)*a[k];
}
for(k=n;k>=1;k--){
i=k+1;
while(i<... | cpp |
1291 | F | F. Coffee Varieties (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. You can find the hard version in the Div. 1 contest. Both versions only differ in the number of times you can ask your friend to taste coffee.Th... | [
"graphs",
"interactive"
] | // LUOGU_RID: 101859300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 1100
ll n,k;
inline bool gt(ll x){
cout<<"? "<<x<<'\n';
char tem;
cout.flush();cin>>tem;
if(tem=='N')return 0;
return 1;
}
inline void clear(){
cout<<'R'<<'\n';
return ;
}
ll an[N];
int main()
{
... | 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>
#include <bit>
#include <bitset>
#include <cstdint>
#define all(v) v.begin() ,v.end()
#define ll long long
using namespace std ;
ll dp[100005][(1<<7)+5] ;
vector<pair <int , int>>all ;
int n, p , k ;
int s[100005][7] ;
ll solve (int idx , int msk){
int cnt = idx-__builtin_... | cpp |
1294 | D | D. MEX maximizingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array [0,0,1,0,2][0,0,1,0,2] MEX equals to 33 because numbers 0,10,1 and 22 are prese... | [
"data structures",
"greedy",
"implementation",
"math"
] | #include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N=4e5+3;
int a[N];
void solve() {
int q,x;
cin>>q>>x;
map<int ,int >mp;
int ans=0;
while(q--) {
int k;
cin>>k;
mp[k%x]++; //转化为1~x-1
while(mp[ans%x]){ // 可以转为为ans
mp[an... | 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"
] | #ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define sz(s) ((int)s.size())
#define all(v) begin(v), end(v)
typedef long double ld;
const int MOD = 1000000007;
#define ff first
#define ss second
mt19937 rnd(chrono::steady_clock::now().... | cpp |
1299 | B | B. Aerodynamictime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGuy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon PP which is defined by coordinates of its vertices. Define P(x,y)P... | [
"geometry"
] | #include<bits/stdc++.h>
#define ll long long
#define rep(i, x, y) for(int i = (x), stOyny = (y); i <= stOyny; ++i)
#define irep(i, x, y) for(int i = (x), stOyny = (y); i >= stOyny; --i)
#define pb emplace_back
#define pii pair<int, int>
#define vint vector<int>
#define fi first
#define se second
#define let co... | cpp |
1284 | F | F. New Year and Social Networktime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputDonghyun's new social network service (SNS) contains nn users numbered 1,2,…,n1,2,…,n. Internally, their network is a tree graph, so there are n−1n−1 direct connections between each user.... | [
"data structures",
"graph matchings",
"graphs",
"math",
"trees"
] | #include <bits/stdc++.h>
using namespace std;
constexpr int N = 2.5e5 + 9, L = 20;
int n, pos[N], dfn[N], tot;
vector<int> es[2][N];
int fa[N][L], dph[N], f[N];
int findf(int x) { return f[x] == x ? x : f[x] = findf(f[x]); }
void add(int u, int v, int id) {
es[id][u].push_back(v), es[id][v].push_back(u);
}
... | 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>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define ll long long
#define mod 1000000007
// #define mod 998244353
#define fastIO \
ios_base... | cpp |
1325 | E | E. Ehab's REAL Number Theory Problemtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array aa of length nn that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this... | [
"brute force",
"dfs and similar",
"graphs",
"number theory",
"shortest paths"
] | #include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+10;
const int maxn=1e5+10;
vector<int>e[N];
int d[1000010];
set<int>s;
vector<int>ans;
queue<pair<int,int>>q;
signed main()
{
ios::sync_with_stdio(false),cin.tie(0);
int n;
cin>>n;
for(int i=1;i<=n;i++){
int x;
cin>>x;
int p1=1,p2=1;
f... | cpp |
1307 | A | A. Cow and Haybalestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of nn haybale piles on the farm. The ii-th pile contains aiai haybales. However, Farmer John has just left for vac... | [
"greedy",
"implementation"
] | #include<bits/stdc++.h>
using namespace std;
int a[1010];
int main(){
int n;
int x;
cin>>x;
while(x--){
int k=0;
cin>>n>>k;
int s=0;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=k;i++){
for(int j=2;j<=n;j++){
if(a[j]>0){
a[j]--;
... | 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 int long long
int ans = 1;
vector<int> pr;
vector<int> val, w, sz;
vector<vector<int>> e;
void dfs(int u)
{
if (w[u] >= val.size())
{
ans = 0;
return;
}
pr[u] = val[w[u]];
val.erase(val.begin() + w[u]);
for (int v : e[u]) dfs(v);
}
voi... | cpp |
1301 | C | C. Ayoub's functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAyoub thinks that he is a very smart person; so he created a function f(s)f(s), where ss is a binary string (a string which contains only symbols "0" and "1"). The function f(s)f(s) is equal to the nu... | [
"binary search",
"combinatorics",
"greedy",
"math",
"strings"
] | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int t;
ll n,m;
inline ll cal(ll x)
{
return x * (x+1) / 2;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld",&n,&m);
n -= m;
ll k = n/(m+1),r = n % (m+1);
ll ans = cal(n+m) - cal(k+1) * r - cal(k) *(m+1-r);
prin... | cpp |
1292 | E | E. Rin and The Unknown Flowertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMisoilePunch♪ - 彩This is an interactive problem!On a normal day at the hidden office in A.R.C. Markland-N; Rin received an artifact, given to her by the exploration captain Sagar.After much... | [
"constructive algorithms",
"greedy",
"interactive",
"math"
] | // LUOGU_RID: 100771511
#define poj
//#define zcz
#ifdef poj
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<stack>
#include<map>
#inclu... | cpp |
1312 | E | E. Array Shrinkingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a1,a2,…,ana1,a2,…,an. You can perform the following operation any number of times: Choose a pair of two neighboring equal elements ai=ai+1ai=ai+1 (if there is at least one such... | [
"dp",
"greedy"
] | #include<iostream>
using namespace std;
#include <cmath>
#include <algorithm>
#define ll long long
#define fi first
#define se second
#define sst string
#define pb push_back
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <cli... | cpp |
1325 | E | E. Ehab's REAL Number Theory Problemtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array aa of length nn that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this... | [
"brute force",
"dfs and similar",
"graphs",
"number theory",
"shortest paths"
] |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
#define pb push_back
const int MN=8e4;
int N, at=170, ans = MN; bool pvis[1001], vis[MN]; pi dist[MN];
set<int> start; vector<int> prime, vals, adj[MN]; queue<pi> q;
unordered_map<int, int> ind; // (value, index it maps to)
void bfs(int... | cpp |
1307 | B | B. Cow and Friendtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! More specifically; he wants to get from (0,0)(0,0) to (x,0)(x,0) by... | [
"geometry",
"greedy",
"math"
] | #include <map>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 1e5 + 5;
int n , x , a[MAXN];
map <int , int> M;
int main() {
int T;
scanf("%d" , &T);
while(T -- > 0) {
M.clear();
scanf("%d %d" , &n , &x);
for (int i = 1; i <= n; ++i) {
scanf("%... | 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"
] | #pragma GCC optimization("Ofast")
#include <bits/stdc++.h>
using namespace std;
int Tc = 1;
void solve() {
int n, check = 0;
cin >> n;
vector<int> a(n);
for (auto& e : a)
cin >> e;
sort(a.begin(), a.end());
a.erase(unique(a.begin(), a.end()), a.end());
long long ans = 0;
for (int i = a.size() - 1; i >= 0; --i) {
if (i ... | 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;
// clang-format off
namespace { enum operand_type_enum : uint32_t { RAW = 0, COMPOSED = 1 << 1, REQUIRE_PARAM = 1 << 2, }; template <class T> concept has_operand_type = requires() { { T::operand_type } -> convertible_to<uint32_t>; }; template <class T> class operand_type... | 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;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>... | cpp |
1323 | B | B. Count Subrectanglestime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array aa of length nn and array bb of length mm both consisting of only integers 00 and 11. Consider a matrix cc of size n×mn×m formed by following rule: ci,j=ai⋅bjci,j=ai⋅bj (i.e.... | [
"binary search",
"greedy",
"implementation"
] | #include<iostream>
using namespace std;
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sst string
#define pb push_back
#define maxco 100000+5
#define lld long double
#define cha ios_base::sync_with_stdio(false);
#define ... | cpp |
1294 | D | D. MEX maximizingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array [0,0,1,0,2][0,0,1,0,2] MEX equals to 33 because numbers 0,10,1 and 22 are prese... | [
"data structures",
"greedy",
"implementation",
"math"
] | #include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#define forin(i,a,n) for(int i=a;i<=n;i++)
#define forni(i,n,a) for(int i=n;i>=a;i--)
#define f... | 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<vector>
#include<stack>
#include<deque>
using namespace std;
typedef long long ll;
void solve() {
int n;
cin >> n;
vector<ll> a(n + 1), b(n + 1), c(n + 1);
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
vector<ll> res(n + 1);
int idx;
ll ans = -1;
for (int j = 1; j <= n; j++) {
... | cpp |
1312 | C | C. Adding Powerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you are performing the following algorithm. There is an array v1,v2,…,vnv1,v2,…,vn filled with zeroes at start. The following operation is applied to the array several times — at ii-th step (00-... | [
"bitmasks",
"greedy",
"implementation",
"math",
"number theory",
"ternary search"
] | #include <iostream>
#include <algorithm>
#include<vector>
#include<map>
#include<set>
#include <cmath>
typedef long long ll;
#define pb push_back
#define R return
#define B break
#define C continue
#define lop(i, n) for (int i = 0; i < n; i++)
#define lopp(r, n) for (int r = 1; r < n; r++)
using namespace ... | cpp |
1288 | A | A. Deadlinetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAdilbek was assigned to a special project. For Adilbek it means that he has nn days to run a special program and provide its results. But there is a problem: the program needs to run for dd days to calculate... | [
"binary search",
"brute force",
"math",
"ternary search"
] | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
#define ff first
#define ss second
#define oo 1000000000
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
int n,d; cin >> n >> d;
int l=0,r=n;
... | cpp |
1325 | A | A. EhAb AnD gCdtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer xx. Find any such 22 positive integers aa and bb such that GCD(a,b)+LCM(a,b)=xGCD(a,b)+LCM(a,b)=x.As a reminder, GCD(a,b)GCD(a,b) is the greatest integer that divides both... | [
"constructive algorithms",
"greedy",
"number theory"
] | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using lui = long unsigned int ;
#define pass (void)0
int main()
{
ll t ;
cin >> t ;
while (t--)
{
ll n ;
cin >> n ;
cout << 1 << " " << n-1 << endl ;
}
ret... | cpp |
1301 | D | D. Time to Runtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Bashar is going... | [
"constructive algorithms",
"graphs",
"implementation"
] | #include <bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
using namespace std;
void cutExcessMoves(vector<pair<string, int>>& path, int k) {
int tot = 0, idx = 0;
for (auto& instr : path) {
if (instr.second + tot >= k) {
instr.second = k - tot;
idx++;
b... | cpp |
1310 | F | F. Bad Cryptographytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn modern cryptography much is tied to the algorithmic complexity of solving several problems. One of such problems is a discrete logarithm problem. It is formulated as follows: Let's fix a finite f... | [
"math",
"number theory"
] | #include<bits/stdc++.h>
using namespace std;
typedef __int128 I;
typedef pair<I,I> Pair;
typedef unsigned long long ull;
const ull P=18446744073709551615ull;
ull val[70][70],res[9][9][260][260],x,y;
int q,Log[300],vis[70][70];
I a[8]={0,3,5,17,257,641,65537,6700417},b[8],m[8];
unordered_map<ull,int> Map;
... | cpp |
1313 | E | E. Concatenation with intersectiontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputVasya had three strings aa, bb and ss, which consist of lowercase English letters. The lengths of strings aa and bb are equal to nn, the length of the string ss is equal to mm. Vasya d... | [
"data structures",
"hashing",
"strings",
"two pointers"
] | #include <bits/stdc++.h>
using namespace std;
struct Fenwick {
int n;
vector<long long> bit;
Fenwick(int n) : n(n), bit(n + 1, 0) {}
void add(int i, long long delta) {
for (i++; i <= n; i += i & -i) {
bit[i] += delta;
}
}
long long sum(int i) {
l... | cpp |
1311 | E | E. Construct the Binary Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers nn and dd. You need to construct a rooted binary tree consisting of nn vertices with a root at the vertex 11 and the sum of depths of all vertices equals to dd.A t... | [
"brute force",
"constructive algorithms",
"trees"
] | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr int N = int(4e2) + 5;
constexpr int inf = 0x7f7f7f7f;
constexpr int MOD = int(1e9) + 7;
void solve(){
int n, d;
cin >> n >> d;
if(n * (n - 1) / 2 < d){
cout << "NO\n";
return;
}
... | 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"
] | #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
//#include <unordered_set>
#include <deque>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cmath>
#include <ctime>
#include <numeric>
#include <string>
#include <chrono>
#in... | cpp |
1285 | E | E. Delete a Segmenttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn segments on a OxOx axis [l1,r1][l1,r1], [l2,r2][l2,r2], ..., [ln,rn][ln,rn]. Segment [l,r][l,r] covers all points from ll to rr inclusive, so all xx such that l≤x≤rl≤x≤r.Segments can be ... | [
"brute force",
"constructive algorithms",
"data structures",
"dp",
"graphs",
"sortings",
"trees",
"two pointers"
] | #include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
#define int long long
#define ll long long
#define II pair<int, int>
#define fs first
#define sc second
#define endl '\n'
const double PI = 3.141592653589793238;
const long long LINF = 1ll << 60;
const int I... | 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 <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,av... | 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;
void solve()
{
int a , b , p;
cin >> a >> b >> p;
string s;
vector<pair<int , int>> ab;
cin >> s;
long long tcost =0 , cost;
int i = 0;
int n = s.size();
while(i < n-1)
{
tcost += s[i] == 'A' ? a : b;
cost = s[i] == '... | cpp |
1290 | A | A. Mind Controltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou and your n−1n−1 friends have found an array of integers a1,a2,…,ana1,a2,…,an. You have decided to share it in the following way: All nn of you stand in a line in a particular order. Each minute, the p... | [
"brute force",
"data structures",
"implementation"
] | // Akash Singh
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; //Make less_equal for multiset
// find_by_order(k) ... | cpp |
1305 | D | D. Kuroni and the Celebrationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem; Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortun... | [
"constructive algorithms",
"dfs and similar",
"interactive",
"trees"
] | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int main()
{
int n;
cin >> n;
vector<int> deg(n);
vector<vector<int>> adj(n);
for(int i = 0; i < n - 1; i++ ){
int x, y;
cin >> x >> y;
x--;
y... | cpp |
1310 | C | C. Au Pont Rougetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputVK just opened its second HQ in St. Petersburg! Side of its office building has a huge string ss written on its side. This part of the office is supposed to be split into mm meeting rooms in such way th... | [
"binary search",
"dp",
"strings"
] | #include <bits/stdc++.h>
#define GC c=getchar()
#define IG isdigit(c)
template<class T=int>T frd(T x=0,char GC,bool f=1)
{
for(;!IG;GC)f=c!='-';for(;IG;GC)x=x*10+(c^48);return f?x:-x;
}
using namespace std;
typedef long long ll;
const int N(1e3+5);
int n,m,tot,lcp[N+5][N+5];
ll k,dp[N+5][N+5],sum[N+5][N+... | 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 i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n);
std::vector<std::pair<i64, int>> v;
for (int i = 0; i < n; i++) {
std::cin >> a[i];
v.... | cpp |
1305 | D | D. Kuroni and the Celebrationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem; Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortun... | [
"constructive algorithms",
"dfs and similar",
"interactive",
"trees"
] | #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <random>
#include <set>
using namespace std;
#define fi first
#define sc second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int N=1005,oo=1e9,mod=1e9+9;
inline int read(... | 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 <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <stack>
#include <set>
#include <limits.h>
#include <assert.h>
#define ll long long
#define endl '\n'
#define fast \
... | cpp |
1324 | F | F. Maximum White Subtreetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of nn vertices. A tree is a connected undirected graph with n−1n−1 edges. Each vertex vv of this tree has a color assigned to it (av=1av=1 if the vertex vv is whi... | [
"dfs and similar",
"dp",
"graphs",
"trees"
] | /*
ॐ त्र्यम्बकं यजामहे सुगन्धिं पुष्टिवर्धनम् |
उर्वारुकमिव बन्धनान्मृत्योर्मुक्षीय माऽमृतात् ||
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int N = 2e5 + 5;
const int inf = 1e18;
int mod = 1e9 + 7;
int power(int a, int b)
{
int ans = 1;
... | cpp |
1320 | E | E. Treeland and Virusestime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are nn cities in Treeland connected with n−1n−1 bidirectional roads in such that a way that any city is reachable from any other; in other words, the graph of cities and roads is a tree. Tr... | [
"data structures",
"dfs and similar",
"dp",
"shortest paths",
"trees"
] | /**
* Author: LZVSDY
**/
#include <bits/stdc++.h>
using namespace std;
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
/*
freopen("orxor.in", "r", stdin);
*/
typedef long long LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
co... | 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;
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 |
13 | B | B. Letter Atime limit per test1 secondmemory limit per test64 megabytesinputstdinoutputstdoutLittle Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.You are given three segments on the plane. Th... | [
"geometry",
"implementation"
] | #include <bits/stdc++.h>
using namespace std;
using point_t=long long; //全局数据类型,可修改为 long long 等
constexpr point_t eps=0;
constexpr long double PI=3.1415926535897932384l;
// 点与向量
template<typename T> struct point
{
T x,y;
// int id=-1;
bool operator==(const point &a) const {return (abs(x-a.... | cpp |
1311 | A | A. Add Odd or Subtract Eventime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two positive integers aa and bb.In one move, you can change aa in the following way: Choose any positive odd integer xx (x>0x>0) and replace aa with a+xa+x; choose any positiv... | [
"greedy",
"implementation",
"math"
] | #include<iostream>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--) {
int a, b;
cin >> a >> b;
if (a == b) cout << 0 << endl;
else cout << 1 + int((a < b) ^ ((b - a) & 1)) << endl;
}
return 0;
} | 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<bits/stdc++.h>
using namespace std;
int GCD(int m, int n)
{
int r = m % n;
while (r != 0)
{
m = n;
n = r;
r = m % n;
}
return n;
}
int main()
{
int a;
cin>>a;
int X=0, Y=a-2;
for (int i = 2; i < a; ++i)
{
int n=a, partofsum=0;
wh... | cpp |
1307 | G | G. Cow and Exercisetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFarmer John is obsessed with making Bessie exercise more!Bessie is out grazing on the farm; which consists of nn fields connected by mm directed roads. Each road takes some time wiwi to cross. She is ... | [
"flows",
"graphs",
"shortest paths"
] | #pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define INF 1000000007
using namespace __gnu_pbds;
using namespace std;
struct custom_hash {
static uint6... | 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"
] | #include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<cstring>
#include<bitset>
#include<iomanip>
#include<random>
#include<fstream>
#include<complex>
#include<time.h>
#include<stack>
using namespace std;
#define endl "\n"
#define ... | cpp |
1296 | D | D. Fight with Monsterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn monsters standing in a row numbered from 11 to nn. The ii-th monster has hihi health points (hp). You have your attack power equal to aa hp and your opponent has his attack power equal... | [
"greedy",
"sortings"
] | #include <iostream>
#include <ranges>
#include <algorithm>
#include <numeric>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <bit>
#include <sstream>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
typedef long long integerType;
typedef integerType z;
type... | 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>
using namespace std;
int main()
{
int t,a,b,x,y;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d %d",&a,&b,&x,&y);
int s1=a*y;
int s2=b*x;
int s3=a*(b-y-1);
int s4=b*(a-x-1);
int s=max(s1,max(s2,max(s3,s4)));
printf("%d\n",s);
}
}
| cpp |
1288 | D | D. Minimax Problemtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given nn arrays a1a1, a2a2, ..., anan; each array consists of exactly mm integers. We denote the yy-th element of the xx-th array as ax,yax,y.You have to choose two arrays aiai and ajaj (1≤i,j... | [
"binary search",
"bitmasks",
"dp"
] |
/*
1-> One day I will be 6* at Codechef and CandidateMaster at CodeForces
2-> Journey is not going to be so easy, sometimes shitty thoughts will rain on me
but that should not be the end, prevent self giving up at that moment.
CP is not a fight, it is Love.
3-> Dont panic about rating, rating t... | cpp |
1303 | B | B. National Projecttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour company was appointed to lay new asphalt on the highway of length nn. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip... | [
"math"
] | #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 lbit(a) (__builtin_ffsll(a))
#define ubit(a) (64-__builtin_clzll(a))
#define FOR(i, a, b) for (ll (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for ... | 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;
using ll=long long;
const ll maxN=2e5+10;
#define pb push_back
#define int ll
#define pli pair<ll,ll>
#define fi first
#define se second
#define task "danang"
#define plii pair<ll,pli>
ll ct[maxN];
bool check(ll x)
{
ll s=x;
for(int i=2;i*i<=x;i++)
... | cpp |
1290 | C | C. Prefix Enlightenmenttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn lamps on a line, numbered from 11 to nn. Each one has an initial state off (00) or on (11).You're given kk subsets A1,…,AkA1,…,Ak of {1,2,…,n}{1,2,…,n}, such that the intersection of... | [
"dfs and similar",
"dsu",
"graphs"
] | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N (ll)(3e5+5)
#define fi first
#define se second
ll n, k, p[N], mn[N], col[N], ans, o[N];
bool s[N];
vector<ll> v[N], g[2][N];
inline void merge(ll x, ll y, bool st) {
if (p[x] == p[y]) return;
if (g[0][p[x]].size() + g[1][p[x]].siz... | 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 endl "\n"
using namespace std;
#define mod 1000000007
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
... | cpp |
1307 | A | A. Cow and Haybalestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of nn haybale piles on the farm. The ii-th pile contains aiai haybales. However, Farmer John has just left for vac... | [
"greedy",
"implementation"
] | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define x first
#define y second
const int N=1e5+10;
int a[N];
void solve()
{
int n,d;
cin>>n>>d;
for(int i=0;i<n;i++)
cin>>a[i];
int res=a[0];
for(int i=1;i<n&&d>=i;i++)
{
if(d>a[i]*i)
res+... | cpp |
1320 | E | E. Treeland and Virusestime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are nn cities in Treeland connected with n−1n−1 bidirectional roads in such that a way that any city is reachable from any other; in other words, the graph of cities and roads is a tree. Tr... | [
"data structures",
"dfs and similar",
"dp",
"shortest paths",
"trees"
] | #include <bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
using namespace std;
typed... | cpp |
1296 | E1 | E1. String Coloring (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an easy 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 ... | [
"constructive algorithms",
"dp",
"graphs",
"greedy",
"sortings"
] | #include <bits/stdc++.h>
#define N 100005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
using namespace std;
int p[N];
int main ()
{
ios::sync_with_stdio(fals... | cpp |
1290 | C | C. Prefix Enlightenmenttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn lamps on a line, numbered from 11 to nn. Each one has an initial state off (00) or on (11).You're given kk subsets A1,…,AkA1,…,Ak of {1,2,…,n}{1,2,…,n}, such that the intersection of... | [
"dfs and similar",
"dsu",
"graphs"
] | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <ty... | cpp |
1304 | A | A. Two Rabbitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBeing tired of participating in too many Codeforces rounds; Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller ... | [
"math"
] | /*
النجاح الساحق خير انتقام
Youssef Elnagar
* */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(c) (c).begin(),(c).end()
#define allr(c) (c).rbegin(),(c).rend()
#define srt(c) sort(all(c))
#define srtv(c) sort(allr(c))
#define rep(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#de... | 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"
] | #include <iostream>
using namespace std;
const int N = 2 * 100 * 1000 +10;
int n, q;
string s;
int dp_l[N], dp_r[N];
int r = 3127;
int mod1 = 1000 * 1000 * 1000 + 7;
int mod2 = 1000 * 1000 * 1000 + 9;
int h[3][N], pw[3][N], cnt[N];
pair<int, int> get_hash(int l, int r)
{
pair<int, int> ret;
... | cpp |
1299 | E | E. So Meantime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is interactive.We have hidden a permutation p1,p2,…,pnp1,p2,…,pn of numbers from 11 to nn from you, where nn is even. You can try to guess it using the following queries:?? kk a1a1 a2a2 …… akak.I... | [
"interactive",
"math"
] | #include<bits/stdc++.h>
#define ll long long
#define rep(i, x, y) for(int i = (x), stOyny = (y); i <= stOyny; ++i)
#define irep(i, x, y) for(int i = (x), stOyny = (y); i >= stOyny; --i)
#define pb emplace_back
#define pii pair<int, int>
#define vint vector<int>
#define fi first
#define se second
#define let co... | 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"
] | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int t ;
cin>>t;
while(t--){
string a;
int k=0 ;
cin>>a;
for(int i=a.find('1') ;i<a.find_last_of('1');i++){
if(a[i]=='0'){
k++;
}
}
... | cpp |
1310 | C | C. Au Pont Rougetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputVK just opened its second HQ in St. Petersburg! Side of its office building has a huge string ss written on its side. This part of the office is supposed to be split into mm meeting rooms in such way th... | [
"binary search",
"dp",
"strings"
] | // LUOGU_RID: 99431188
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int n,m,lcp[N][N],rmin[N];
long long k;
char s[N];
vector<int>g[N];
long long sum[N][N],dp[N][N];
int main()
{
scanf("%d%d%lld",&n,&m,&k);
vector<pair<int,int>>v;
for (int i=1;i<=n;i++)
for (int j=i;j<=n;j++)
... | 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>
using namespace std;
#define int long long
#define endl '\n'
const int M = 1e6+7, MOD = 1e9;
int dist[M], n, par[M];
vector<int> node[M];
void bfs(vector<int> s) {
for (int i = 1; i <= n; i++) dist[i] = INT_MAX;
for (int i:s) dist[i] = 0;
queue<int> q;
for (int i:s) q.push... | cpp |
1313 | B | B. Different Rulestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNikolay has only recently started in competitive programming; but already qualified to the finals of one prestigious olympiad. There going to be nn participants, one of whom is Nikolay. Like any good o... | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | #include<bits/stdc++.h>
#define eps 1e-9
#define emailam ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define MAX 200010
#define pb push_back
#define all(a) a.begin(),a.end()
#define pf push_front
#define ... | cpp |
1299 | E | E. So Meantime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is interactive.We have hidden a permutation p1,p2,…,pnp1,p2,…,pn of numbers from 11 to nn from you, where nn is even. You can try to guess it using the following queries:?? kk a1a1 a2a2 …… akak.I... | [
"interactive",
"math"
] | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <queue>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef long do... | 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;
#include <iostream>
#include <cmath>
#include <algorithm>
#define ll long long
#define fi first
#define se second
#define sst string
#define pb push_back
#define maxco 100000+5
#define lld long double
#define cha ios_base::sync_with_stdio(false);
#define ffl cout.flush();
#d... | 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<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
cin >> n;
int a[n]; // robo_coder robot
int b[n]; // bionic_solver robot
for(int i=0;i<n;i++){
cin >> a[i];
}
for(int k=0;k<n;k++){
cin>>b[k];
}
float sa=0;
float sb=0;
... | 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<iostream>
#define int long long
using namespace std;
int t[300000];
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int H,n;
cin>>H>>n;
int minn=1e9;
for(int i=1;i<=n;i++)
cin>>t[i];
int suma=0;
int gdzie=0;
for(int i=1;i<=... | cpp |
13 | B | B. Letter Atime limit per test1 secondmemory limit per test64 megabytesinputstdinoutputstdoutLittle Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.You are given three segments on the plane. Th... | [
"geometry",
"implementation"
] | #include <bits/stdc++.h>
#define int long long
using namespace std;
struct point{
int x,y;
};
struct line{
point p1,p2;
}a[4];
int len_line_pow(line a){//求线段长度的平方
return (a.p1.x-a.p2.x)*(a.p1.x-a.p2.x)+(a.p1.y-a.p2.y)*(a.p1.y-a.p2.y);
}
bool check_same_point(point p1,point p2){//判断两点是否... | cpp |
1303 | G | G. Sum of Prefix Sumstime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe define the sum of prefix sums of an array [s1,s2,…,sk][s1,s2,…,sk] as s1+(s1+s2)+(s1+s2+s3)+⋯+(s1+s2+⋯+sk)s1+(s1+s2)+(s1+s2+s3)+⋯+(s1+s2+⋯+sk).You are given a tree consisting of nn vertices. Eac... | [
"data structures",
"divide and conquer",
"geometry",
"trees"
] | // LUOGU_RID: 98578627
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pair;
const int N=2e5+5;
#define F first
#define S second
#define ls now<<1
#define rs now<<1|1
int vis[N<<2],tag[N<<2]; Pair tr[N<<2];
int dep[N],used[N],siz[N],a[N]; ll su[N],sd[N],val[N];
int n,to... | cpp |
1316 | B | B. String Modificationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has a string ss of length nn. He decides to make the following modification to the string: Pick an integer kk, (1≤k≤n1≤k≤n). For ii from 11 to n−k+1n−k+1, reverse the substring s[i:i+k−1]s... | [
"brute force",
"constructive algorithms",
"implementation",
"sortings",
"strings"
] | #include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#define forin(i,a,n) for(int i=a;i<=n;i++)
#define forni(i,n,a) for(int i=n;i>=a;... | cpp |
1301 | C | C. Ayoub's functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAyoub thinks that he is a very smart person; so he created a function f(s)f(s), where ss is a binary string (a string which contains only symbols "0" and "1"). The function f(s)f(s) is equal to the nu... | [
"binary search",
"combinatorics",
"greedy",
"math",
"strings"
] | #include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 1010;
void solve()
{
int n, m;
cin>>n>>m;
long long ans = (long long)n * (long long)(n + 1) / 2LL;
int z = n - m;
int k = z / (m + 1);
ans -= (long long)(m + 1) * (long long)k *... | 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<bits/stdc++.h>
using namespace std;
#define int int64_t
int32_t main() {
string s;
cin >> s;
map<int, int> cnt;
map<int, int> freq;
int ans = 0;
for (char &c: s) {
int d = c - 'a';
for (auto[cc, f]: freq) {
int key = d * 26 + (cc - 'a');
... | 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"
] | #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const ll mod = 998244353;
const int mm = 3e5 + 10;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int t;
cin>>t;
while(t--){
int k;
cin>>k;
string a;
cin>>a... | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.