自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 代码模板——图论

图论

2022-08-04 16:22:53 147 2

原创 第三天 C. Mind Control

You and your n−1 friends have found an array of integers a1,a2,…,an. You have decided to share it in the following way: All nof you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the las

2022-01-16 03:11:02 83

原创 第三天 B. Rubik‘s Cube Coloring (easy version)

It is the easy version of the problem. The difference is that in this version, there are no nodes with already chosen colors.Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you hel

2022-01-16 03:07:58 120

原创 第三天 A. Social Network (easy version)

The only difference between easy and hard versions are constraints on nand k.You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most kmost recent conversations with your friends. Initially, the scre

2022-01-16 03:04:30 108

原创 第二天 、D. Minimize The Integer

传送门思路如下:奇偶性不同的两个数可以交换位置,求使得这个数最小的情况。由于只能交换相邻奇偶的数,所以奇偶数字的相对位置一定不变,把他们分别存在两个数组里,按大小输出即可代码如下:int T = 1; cin >> T; while(T --){ string s; cin >> s; int c1 = 0, c2 = 0; a[1] = 10, b[1] = 10; rep(i, 0, s.size()

2022-01-13 16:47:03 171

原创 第二天 C. Phoenix and Distribution

传送门思路如下:把一个字符串分成k 份,使最大的字典序最小。先把字符串sort,然后分类讨论1.如果前k - 1个一样1.1 如果第k 个和最后一个一样,均分剩余字符串,输出最长的1.2 如果不一样,把后面所有的接到第一个后面输出2.如果前k - 1个不一样,直接输出第k - 1 个代码如下: int T = 1; cin >> T; while(T --){ int n, k, cat; cin >> n >>

2022-01-13 16:44:03 76

原创 第二天 B. Everyone is a Winner

传送门思路如下:寻找一个数n可以被哪些数整除,其实只需要从1寻找到根号n,然后用set去重,别忘记补0。代码如下: int T = 1; cin >> T; while(T --){ int n; cin >> n; set<int> s; rep(i, 1, sqrt(n)){ s.insert(i); s.insert(n/i); }

2022-01-13 16:37:38 50

原创 第二天 A. Make it Divisible by 25

传送门思路如下:寻找一个数字使他可以被25整除,需要删掉多少位。一个数字可以被25整除,只需要判断最后两位:00,50,25,75代码如下: int T = 1; cin >> T; while(T --){ string s; cin >> s; int cnt = 0; bool f1 = false, f2 = false; per(i, s.size() - 1, 0){

2022-01-13 16:15:11 159

原创 第一天 D. Building a Fence

You want to build a fence that will consist of n equal sections. All sections have a width equal to 1 and height equal to k. You will place all sections in one line side by side.Unfortunately, the ground beneath the fence is not flat. For simplicity, you

2022-01-12 00:49:44 154

原创 第一天 C. Chocolate Bunny

This is an interactive problem.We hid from you a permutation pof length n, consisting of the elements from 1 to n. You want to guess it. To do that, you can give us 2 different indices i and j, and we will reply with pimodpj (remainder of division pi by

2022-01-11 23:33:08 436

原创 第一天 B. Diverse Matrix

Let a be a matrix of size r×c containing positive integers, not necessarily distinct. Rows of the matrix are numbered from 1 to r, columns are numbered from 1 to c. We can construct an array b consisting of r+c integers as follows: for each i∈[1,r], let bi

2022-01-11 20:26:04 52

原创 第一天 A. Good ol‘ Numbers Coloring

Consider the set of all nonnegative integers: 0,1,2,…. Given two integers a and b (1≤a,b≤104). We paint all the numbers in increasing number first we paint 0, then we paint 1, then 2and so on.Each number is painted white or black. We paint a number iacc

2022-01-11 19:57:54 296

原创 2021 - 10 - 14多项式求值

#include<bits/stdc++.h>#define rep(i, a, b) for(int i = a; i <= b ; i ++ )#define per(i, a, b) for(int i = a; i >= b ; i -- )const int maxn = 1e4 + 10;typedef struct myStack{ int data[maxn]; int top;}mystack;typedef struct charStack

2021-10-14 16:08:31 51

原创 2021-10 - 09 栈

#include<iostream>#define rep(i, a, b) for(int i = a; i <= b; ++ i)#define per(i, a, b) for(int i = a; i >= b; -- i)using namespace std;const int maxn = 5;typedef struct Stack{ int data[maxn]; int top;}stack;void initStack(stack * s

2021-10-09 15:34:47 61

原创 2021-09-29 多项式加乘

乘法我偷懒了,直接用了map,如果需要排序,在map里嵌套一个vector就可以,但是我也很懒的没有写#include<bits/stdc++.h>#define rep(i, a, b) for(int i = a; i <= b; i ++ )#define per(i, a, b) for(int i = a; i >= b; i -- )using namespace std;typedef struct Node{ int xs, zs; Node * ne

2021-09-29 22:24:39 88 2

原创 2021-09-27 双向循环链表

#include<bits/stdc++.h>#define rep(i, a, b) for(int i = a; i <= b; i ++)#define per(i, a, b) for(int i = a; i >= b; i --)using namespace std;typedef struct DLNode{ int data; DLNode * next, * prior;} * DBLNode;int n;void InitDLNode(D

2021-09-29 17:36:40 95 1

原创 0916 - 线性表

两杯奶茶#include<stdio.h>#include<malloc.h>#include<stdbool.h>#define rep(i, aa, bb) for(i = aa; i <= bb; i ++)#define per(i, aaa, bbb) for(i = aaa; i >= bbb; i --)const int maxn = 1e6 + 10;using namespace std;int n, i, j;typ

2021-09-16 16:08:12 104

原创 2021-09-13 线性表基本操作

#include<bits/stdc++.h>#define rep(i, aa, bb) for(int i = aa; i <= bb; i ++)#define per(i, aaa, bbb) for(int i = aaa; i <= bbb; i ++)#define long long intconst int maxn = 1e2 + 10;using namespace std;int n;typedef struct { int *arr

2021-09-14 16:56:11 121

原创 2021 - 09 - 18 数组的操作

关于数组的一点操作实现,完成一下作业#include<bits/stdc++.h>#define rep(i, aa, bb) for(int i = aa; i <= bb; i ++)#define per(i, aa, bb) for(int i = aa; i >= bb; i --)#define int long longtypedef long long ll;using namespace std;const int maxn = 1e5 + 10;i

2021-09-08 18:20:16 69

原创 2021-09-03 D. Zero Quantity Maximization

You are given two arrays a and b, each contains n integers.You want to create a new array c as follows: choose some real (i.e. not necessarily integer) number d, and then for every i∈[1,n] let ci:=d⋅ai+bi.Your goal is to maximize the number of zeroes in

2021-09-04 10:32:31 80

原创 2021 - 09 - 02 Anu Has a Function

A. Anu Has a Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnu has created her own function f: f(x,y)=(x|y)−y where | denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9

2021-09-02 22:28:30 65

原创 2021-08-18 B. Box Fitting

You are given n rectangles, each of height 1. Each rectangle’s width is a power of 2 (i. e. it can be represented as 2x for some non-negative integer x).You are also given a two-dimensional box of width W. Note that W may or may not be a power of 2. Moreo

2021-08-18 14:48:39 97

原创 2021 - 8 - 12 Codeforces C. Binary String Reconstruction

Consider the following process. You have a binary string (a string where each character is either 0 or 1) w of length n and an integer x. You build a new binary string s consisting of n characters. The i-th character of s is chosen as follows:if the chara

2021-08-12 20:57:13 72

原创 2021-08-12 CodeForce C - Balanced Bitstring

A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k2 of each).You are given an integer k and a string s which is co

2021-08-12 16:39:52 128 1

原创 2021-08-12

Codeforce C. Mere Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a1,a2,…,an where all ai are integers and greater than 0.In one operation, you can choose two different

2021-08-12 11:32:22 96

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除