- 博客(13)
- 收藏
- 关注
原创 Median
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { int n, m; cin >> n >> m; assert(m >= 1 && m <= n &&am...
2021-08-17 20:26:13
73
原创 Decomposition
#include <bits/stdc++.h> using namespace std; void solve() { int n, t, ptr = 0; scanf("%d%d", &n, &t); vector<int> euler(1, n-1); for(int i = 0; i < n/2; ++i) { int sgn = 1, ct = i; for(int d = 1; d < n; ++d) { ...
2021-08-17 20:23:27
145
原创 Yes, Prime Minister
Mr. Hacker’s Department of Administrative Affffairs (DAA) has infifinite civil servants. Every integer is used as an id number by exactly one civil servant. Mr. Hacker is keen on reducing overmanning in civil service, so he will only keep people with c
2021-08-17 18:25:25
223
原创 Array
Given an integer array a[1..n]. Count how many subsegment [L, R] satisfying R − L + 1 ≥ 1 and there is a kind of integer whose number of occurrences is strictly greater than the sum of others in a[L..R] Input The fifirst line contains an integer T(
2021-08-17 18:23:11
76
原创 2021-08-17
Defifine the distance between two strings of the same length as the numbers of the positions where the characters diffffer in these two strings. If two strings of the same length has a distance of no more than k, we call these two string satisfy ...
2021-08-17 18:21:32
49
原创 Lawn of the Dead
One day, a zombie came to the Lawn of the Dead, which can be seen as an n × m grid. Initially, he stood on the top-left cell, which is (1, 1). Because the brain of the zombie was broken, he didn’t have a good sense of direction. He could only move down fro
2021-08-07 21:57:57
208
原创 Display Substring
When we display a string on a LED screen, there may be different energy consumptions for displaying different characters. Given a string S with length n consisting of lowercase English letters and the energy consumption of each letter. Assume that t...
2021-08-07 21:51:33
113
原创 Rise in Price
There are n × n cells on a grid, the top-left cell is at (1, 1) while the bottom-right cell is at (n, n). You start at (1, 1) and move to (n, n). At any cell (i, j), you can move to (i + 1, j) or (i, j + 1), provided that you don’t move out of the grid. Cl
2021-08-07 21:48:09
63
原创 Forgiving Matching
Little Q is now checking whether string A matches B. Two strings are considered matched if they have the same length, and there is no position i that Ai is different from Bi . However, Little Q is a kind man, he forgives every person who hurt him. What’s m
2021-08-07 21:42:31
84
原创 I love permutation
#include<iostream> using namespace std; #define LL long long #define LD long double #define ull unsigned long long const LL N=5e5+10; const LL INF=1e18; LL a,P,b; int cnt=0; void init(){ return; } void add(LL &x,LL y){ x+=y;if(x>=P)x-=...
2021-07-27 22:39:41
123
原创 I love max and multiply
#include<iostream> using namespace std; #define LL long long #define LD long double #define ull unsigned long long const int N=(1<<20)+10; const int INF=2e9; const LL inf=1e18; const LL P=998244353; void init() { return; } LL qpow(LL x,LL ...
2021-07-27 22:35:22
72
原创 KD-Graph
Problem Description Let’s call a weighted connected undirected graph ofnvertices and m edges KD-Graph, if the following conditions fulfill: *nvertices are strictly divided intoKgroups, each group contains at least one vertice * if verticespandq(...
2021-07-26 22:01:01
86
原创 Minimum spanning tree
Problem Description Given n-1 points, numbered from 2 to n, the edge weight between the two points a and b is lcm(a, b). Please find the minimum spanning tree formed by them. A minimum spanning tree is a subset of the edges of a connected, edge-weighted u
2021-07-26 21:53:23
60
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人