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. maven的基本使用

    安装: 1.下载maven http://maven.apache.org/ 2.将maven包解压并放置到安装目录 3.添加环境变量M2_HOME,path当中添加;%M2_HOME%\bin; 4 ...

  2. Winform非UI线程更新UI界面的各种方法小结

    我们知道只有UI线程才能更新UI界面,其他线程访问UI控件被认为是非法的.但是我们在进行异步操作时,经常需要将异步执行的进度报告给用户,让用户知道任务的进度,不至于让用户误认为程序“死掉了”,特别是对 ...

  3. docker 入门 命令

    docker 命令 docker images 镜像列表 docker ps 服务列表 docker 隐藏打包文件 .dockerignore .git node_modules npm-debug. ...

  4. java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents...

    出现这个错误的原因是时区有问题,可以在mysql中执行命令: set global time_zone='+8:00'; 如上是修改为北京时间(GMT+0800). 查看修改: show variab ...

  5. Office之什么是高内聚低耦合

    ---恢复内容开始--- 高内聚低耦合,是软件工程中的概念,是判断设计好坏的标准,主要是面向对象的设计,主要是看类的内聚性是否高,耦合度是否低. 粗劣的说就指的是:单独模块间有着强大的凝聚力,不同的模 ...

  6. flask_migrate 的应用

    怎么查看的命令: python manage.py --help 使用flask_migrate的注意事项:

  7. Java十大bug之——包冲突

    找bug就像破案,有的bug简单,有的bug复杂,还有的bug隐藏的令人难以发现. 一个逻辑上看起来一切都正常,结果确有问题,且怎么分析都感觉自己写的没问题的情况——包冲突 遇到这个bug最开始没有任 ...

  8. RPC基本原理

    RPC非常重要,很多人面试的时候都挂在了这个地方!你要是还不懂RPC是什么?他的基本原理是什么?你一定要把下边的内容记起来!好好研究一下!特别是文中给出的一张关于RPC的基本流程图,重点中的重点,Du ...

  9. Diameter of Binary Tree

    Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a b ...

  10. C++多线程基础学习笔记(八)

    shared_futrue和futrue_status的用法 shared_futrue是一个类模板,类似于futrue,不同的是它的成员函数get()可以使用多次,因为是复制数据,而futrue的g ...