A

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 2e5 + , MAXM = 2e5 + , N = 2e5 + ;
const int MAXQ = ;
/*int to[MAXM << 1], nxt[MAXM << 1], Head[MAXN], tot = 1;
inline void addedge(int u, int v)
{
to[++tot] = v;
nxt[tot] = Head[u];
Head[u] = tot;
}*/
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
int num[];
int visit[];
int main()
{
int n, k;
read(n), read(k);
for (int i = ; i <= n; i++)
{
read(num[i]);
}
int anser = ;
for (int i = ; i <= n; i++)
{
if (num[i] <= k)
{
visit[i] = ;
anser++;
}
else
{
break;
}
}
for (int i = n; i >= ; i--)
{
if (visit[i])
{
break;
}
if (num[i] <= k)
{
anser++;
}
else
{
break;
}
}
cout << anser << endl;
return ;
}

B

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 2e5 + , MAXM = 2e5 + , N = 2e5 + ;
const int MAXQ = ;
/*int to[MAXM << 1], nxt[MAXM << 1], Head[MAXN], tot = 1;
inline void addedge(int u, int v)
{
to[++tot] = v;
nxt[tot] = Head[u];
Head[u] = tot;
}*/
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
string s;
void doit(int x)
{
for (int i = ; i <= x / - ; i++)
{
swap(s[i], s[x - - i]);
}
}
int main()
{
int n;
read(n);
cin >> s;
for (int i = ; i <= n; i++)
{
if (n % i == )
{
doit(i);
}
}
cout << s << endl;
return ;
}

C

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 2e5 + , MAXM = 2e5 + , N = 2e5 + ;
const int MAXQ = ;
/*int to[MAXM << 1], nxt[MAXM << 1], Head[MAXN], tot = 1;
inline void addedge(int u, int v)
{
to[++tot] = v;
nxt[tot] = Head[u];
Head[u] = tot;
}*/
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
string s;
int visit[];
queue<int> ch[];
int main()
{
int n, k;
read(n), read(k);
cin >> s;
for (int i = ; i < s.size(); i++)
{
ch[s[i] - 'a'].push(i);
//cout<<s[i]-'a'<<" "<<i<<endl;
}
for (int j = ; j <= k; j++)
{
for (int i = ; i <= ; i++)
{
if (ch[i].size() > )
{
visit[ch[i].front()] = ;
ch[i].pop();
break;
}
}
}
for (int i = ; i < s.size(); i++)
{
if(!visit[i])
{
cout<<s[i];
}
}
return ;
}

D

磨了半天 没想到直接暴力也能过

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = ;
int n, m, a[N];
vector<int> c[N];
LL ans;
int main()
{
scanf("%d%d", &n, &m);
for (int i = ; i < n; i++)
{
scanf("%d", &a[i]);
c[a[i] % m].push_back(i);
}
int ptr = ;
int goal = n / m;
for (int i = ; i < m; i++) //从0开始检查比goal大的
{
while ((int)c[i].size() > goal) //如果枚举到的比水平线高
{
ptr = max(ptr, i); //保证找到的要在其后
while ((int)c[ptr % m].size() >= goal) //找到小于水平线的
{
ptr ++;
}
int tk = min((int)c[i].size() - goal, goal - (int)c[ptr % m].size()); //取多出与缺少的最小值
int dlt = ptr - i; //多的和少的之间的距离
while (tk--)
{
ans += dlt;
a[c[i].back()] += dlt;
c[ptr % m].push_back(c[i].back());
c[i].pop_back();
}
}
}
printf("%lld\n", ans);
for (int i = ; i < n; i++)
{
printf("%d%c", a[i], " \n"[i + == n]);
}
}

E

暴力染色即可

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
const int mod = 1e9 + , gakki = + + + + 1e9;
const int MAXN = 5e3 + , MAXM = 5e3 + , N = 2e5 + ;
const int MAXQ = ;
int to[MAXM << ], nxt[MAXM << ], Head[MAXN], tot = ;
inline void addedge(int u, int v)
{
to[++tot] = v;
nxt[tot] = Head[u];
Head[u] = tot;
}
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
int du[MAXN], visit[MAXN];
int visit2[MAXN];
int ans = ;
void dfs(int x, int pre)
{
visit[x] = pre;
visit2[x] = ;
for (int i = Head[x]; i; i = nxt[i])
{
int v = to[i];
if (!visit2[v])
{
dfs(v, pre);
}
}
}
int vis[MAXN];
int main()
{
int n, m, s, u, v;
read(n), read(m), read(s);
for (int i = ; i <= m; i++)
{
read(u), read(v);
addedge(u, v);
du[v]++;
}
for (int i = ; i <= n; i++)
{
if (!visit[i])
{
mem(visit2, );
dfs(i, i);
}
}
mem(visit2,);
dfs(s, s);
for (int i = ; i <= n; i++)
{
if (vis[visit[i]] == )
{
vis[visit[i]] = ;
ans++;
}
}
cout << ans - << endl;
}

tarjan缩点后找入度为0的点 可以O(n+m)的做

F

dp

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = ;
int n, k, c[N], f[N], h[N];
const int K = ;
int dp[ * K];
int cal(int x)
{
if (f[x] == )
{
return ;
}
int atmst = min(f[x] * k, c[x]);
for (int i = ; i <= atmst; i++)
{
dp[i] = ;
}
while (f[x]--)
{
for (int i = atmst; i >= ; i--)
for (int j = ; j <= k and i - j >= ; j++)
{
dp[i] = max(dp[i], dp[i - j] + h[j]);
}
}
return dp[atmst];
}
int main()
{
scanf("%d%d", &n, &k);
for (int i = ; i < n * k; i++)
{
int ci;
scanf("%d", &ci);
c[ci]++;
}
for (int i = ; i < n; i++)
{
int fi;
scanf("%d", &fi);
f[fi]++;
}
for (int i = ; i <= k; i++)
{
scanf("%d", &h[i]);
}
int ans = ;
for (int i = ; i < N; i++)
{
ans += cal(i);
}
cout << ans << endl;
}

Codeforces 999的更多相关文章

  1. codeforces#999 E. Reachability from the Capital(图论加边)

    题目链接: https://codeforces.com/contest/999/problem/E 题意: 在有向图中加边,让$S$点可以到达所有点 数据范围: $ 1 \leq n \leq 50 ...

  2. CodeForces 219B Special Offer! Super Price 999 Bourles!

    Special Offer! Super Price 999 Bourles! Time Limit:1000MS     Memory Limit:262144KB     64bit IO For ...

  3. 构造 Codeforces Round #135 (Div. 2) B. Special Offer! Super Price 999 Bourles!

    题目传送门 /* 构造:从大到小构造,每一次都把最后不是9的变为9,p - p MOD 10^k - 1,直到小于最小值. 另外,最多len-1次循环 */ #include <cstdio&g ...

  4. 【模拟】NEERC15 J Jump(2015-2016 ACM-ICPC)(Codeforces GYM 100851)

    题目链接: http://codeforces.com/gym/100851 题目大意: 系统里生成一个字符串C,一开始告诉你字符串的长度N(偶数).接着你需要在n+500次内猜出这个字符串是什么. ...

  5. Codeforces Round #425 (Div. 2)C

    题目连接:http://codeforces.com/contest/832/problem/C C. Strange Radiation time limit per test 3 seconds ...

  6. Codeforces Round #301 (Div. 2)(A,【模拟】B,【贪心构造】C,【DFS】)

    A. Combination Lock time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...

  7. Codeforces Round #520

    占个坑慢慢填 A ()[http://codeforces.com/contest/1062/problem/A] 题意:现在有一个长度为n的严格上升正整数序列 每个数的取值在[1, 1000] 现在 ...

  8. Codeforces 999F Cards and Joy(二维DP)

    题目链接:http://codeforces.com/problemset/problem/999/F 题目大意:有n个人,n*k张卡牌,每个人会发到k张卡牌,每个人都有一种喜欢的卡牌f[i],当一个 ...

  9. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

随机推荐

  1. linux常用、常见错误

    1.md5加密使用 oppnssl md5 加密字符串的方法 [root@lab3 ~]# openssl //在终端中输入openssl后回车. OpenSSL> md5 //输入md5后回车 ...

  2. nginx 反向代理是url带后缀

    1.后端:http://10.253.149.2/tdsqlpcloud/index.php 2.配置文件 danjan01deiMac:nginx danjan01$ cat /usr/local/ ...

  3. 将对象以json格式写入到文件中

    将 list 对象以json格式写入到文件中 try { ObjectMapper mapper = new ObjectMapper(); String value = mapper.writeVa ...

  4. gulp时发生错误---------const { Math, Object } = primordials;

    [问题描述] 执行完npm install后,对前台页面进行gulp操作时,报如下错误: const { Math, Object } = primordials; [错误日志] ***@**** M ...

  5. C语言|作业07

    一.本周作业头 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 https://i-beta.cnblogs.com/posts/edit;postId=11811545 我在这个课程的 ...

  6. 掌握MyBatis的核心对象

    一.获取SqlSessionFactoryBuilder对象 1.SqlSessionFactoryBuilder的作用 所有的MyBatis应用都是以SqlSessionFactory实例为中心.S ...

  7. FFmpeg4.0笔记:采集系统声音

    Github https://github.com/gongluck/FFmpeg4.0-study/tree/master/Cff // 采集系统声音 void test_systemsound() ...

  8. CentOS 7 关闭Selinux

    临时关闭: [root@localhost ~]# getenforceEnforcing [root@localhost ~]# setenforce 0[root@localhost ~]# ge ...

  9. 数据绑定-@ CookieValue

    测试:

  10. SQL数据库字段数据类型详细说明

    这里先总结数据类型.MySQL中的数据类型大的方面来分,可以分为:日期和时间.数值,以及字符串.下面就分开来进行总结. 日期和时间数据类型 MySQL数据类型 含义 date 3字节,日期,格式:20 ...