这种凌晨场真的折寿

就过了四题,8wa结尾心态炸裂,求别被hack,再hack就要爬了

A2   B8   C38(1)   E1:58(7)

D题感觉可以写,但是没有时间看了。幸好E最后发现了自己的错误。

A题:看到题的时候感觉好温馨,算时间,感动到了

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
const int maxn=1e5+;
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n,m;
cin>>n>>m;
int sum=-m+(-n)*;
printf("%d\n",sum);
}
return ;
}

B题:看到题的那一刻,又感动到了

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
const int maxn=1e5+;
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n,m;
cin>>n>>m;
int zx=n/m,ge=m/;
int sheng=n-zx*m;
if(sheng>=ge){
printf("%d\n",zx*m+ge);
}
else{
printf("%d\n",zx*m+sheng);
}
}
return ;
}

C题:这题是hack最多的 QAQ求求求了别注意到我

题意:给n个数字,0或者1~n之间,把0替换成1~n中没出现过的,同时满足不等于它所在的位置下标

思路:暴力……?感觉自己要被hack的……但算了算复杂度没超

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
const int maxn=2e5+;
int a[maxn],pos[maxn]={},p[maxn];
int main()
{
int n;
queue<int>q;
scanf("%d",&n);
int t=;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
if(!a[i]){
p[t++]=i;
}
else{
pos[a[i]]=;
}
}
for(int i=;i<=n;i++){
if(!pos[i]){q.push(i);}
}
for(int i=;i<t-;i++){
int wei=q.front();q.pop();
if(wei!=p[i]){
a[p[i]]=wei;
}
else{
q.push(wei);
wei=q.front();q.pop();
a[p[i]]=wei;
}
}
int wei=q.front();q.pop();int wei2=q.front();
if(p[t-]!=wei && p[t-]!=wei2){
a[p[t-]]=wei;a[p[t-]]=wei2;
}
else{
a[p[t-]]=wei;a[p[t-]]=wei2;
}
for(int i=;i<=n;i++){
printf(i==n?"%d\n":"%d ",a[i]);
}
return ;
}

E题:这是我wa最多,花时间找错误最多的

题意:给一个n,输入n个数(1~n),代表人所在的房子序号,人可以左右移动一格或者不动,但只能移动一次。问最小,最多的可以住不同的房子

思路:缩小,扩大,扩大考虑房子序号出现次数1次,2次,大于等于3次,优先考了右边,然后是不动,再是左边。缩小,遇到房子序号出现次数为0的跳过,遇到不是0的,考虑111,101,110,100四种情况即可。

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
const int maxn=2e5+;
int a[maxn]={},vis[maxn]={},pos[maxn]={},k;
int main()
{
int n;
int sum=,ans=;
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&k);
pos[k]++;
vis[k]++;
}
for(int i=;i<=n;i++){
if(pos[i]==){
if(!a[i-]){a[i-]=;}
else if(!a[i]){a[i]=;}
else if(!a[i+]){a[i+]=;}
}
else if(pos[i]==){
if(!a[i-]){
a[i-]=;
if(!a[i]){a[i]=;}
else if(!a[i+]){a[i+]=;}
}
else{
a[i]=;
a[i+]=;
}
}
else if(pos[i]>=){
a[i]=;a[i-]=;a[i+]=;
}
}
for(int i=;i<=n+;i++){if(a[i]){sum++;}}
for(int i=;i<=n;i++){
if(vis[i] && vis[i+] && vis[i+]){
ans++;i=i+;
}
else if(vis[i] && vis[i+] && !vis[i+]){
ans++;i=i+;
}
else if(vis[i] && !vis[i+] && vis[i+]){
ans++;i=i+;
}
else if(vis[i] && !vis[i+] && !vis[i+]){
ans++;i=i+;
} }
printf("%d %d\n",ans,sum);
return ;
}

D和F等期末考完再补吧。希望期末全过啊

upd

补题D题:

题意:给n个树的位置,求m个人离树最小的距离之和

思路:往外扩,bfs

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
const int maxn=2e5+;
struct node{
int n,m;
node(){}
node(int nn,int mm):n(nn),m(mm){}
};
map<int,bool>vis;
queue<node>q;
int pos[maxn],t=,n,m,k;
ll bfs(){
ll ans=;
while(m> && !q.empty()){
node tk=q.front();q.pop();
if(!vis[tk.n]){
ans+=(ll)tk.m;pos[t++]=tk.n;m--;vis[tk.n]=;
q.push(node(tk.n+,tk.m+));
q.push(node(tk.n-,tk.m+));
}
}
return ans;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<n;i++){
scanf("%d",&k);
vis[k]=;q.push(node(k+,));q.push(node(k-,));
}
printf("%lld\n",bfs());
for(int i=;i<t;i++){
printf(i==t-?"%d\n":"%d ",pos[i]);
}
return ;
}

前几天一直练搜索题……比赛时候搜索题题目都没看……

F题的题意有点难懂

就是给n个1~n的点,第i个点的价值是2^i(0<i<n+1),每个点链接的线,有一个主点和副点,主点的价值等于主点的价值加上其所有的副点价值(包含副点的副点价值等等)

给n-1个数字a,代表价值从大到小的主点位置,求线段两点的价值从大到小的位置

题解,感觉有点像拓扑排序,入度点,并且要求小的先出,所以用优先队列

还是看了别人的题解写的,呜呜呜,题意根本没读懂

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<queue>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
const int maxn=2e5+;
int vis[maxn],du[maxn],a[maxn];
vector<pair<int,int> > v;
priority_queue<int,vector<int>,greater<int> >q;
int n;
int main()
{
cin>>n;
for(int i=;i<n;i++){
cin>>a[i];
vis[a[i]]=,du[a[i]]++;
}
for(int i=;i<=n;i++){
if(!vis[i]){q.push(i);}
}
for(int i=n-;i;i--){
int t=q.top();q.pop();
du[a[i]]--;
v.push_back(make_pair(t,a[i]));
if(!du[a[i]]){q.push(a[i]);}
}
printf("%d\n",a[]);
for(int i=n-;i>=;i--){
printf("%d %d\n",v[i].first,v[i].second);
}
return ;
}

codeforces Round #611的更多相关文章

  1. Codeforces Round #611 (Div. 3) A-F简要题解

    contest链接:https://codeforces.com/contest/1283 A. Minutes Before the New Year 题意:给一个当前时间,输出离第二天差多少分钟 ...

  2. Codeforces Round #611 (Div. 3)

    原题面:https://codeforces.com/contest/1283 A.Minutes Before the New Year 题目大意:给定时间,问距离零点零分还有多久? 分析:注意一下 ...

  3. Codeforces Round #611 (Div. 3) E

    Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past ...

  4. Codeforces Round #611 (Div. 3) C

    There are nn friends who want to give gifts for the New Year to each other. Each friend should give ...

  5. Codeforces Round #611 (Div. 3) D

    There are nn Christmas trees on an infinite number line. The ii -th tree grows at the position xixi ...

  6. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. 每天进步一点点------Allegro 手工布线时控制面板各选项说明

    在进行手工布线过程中,最重要的就是对控制面板中的各个选项进行设置,因此首先介绍控制面板中各个选项的含义. 手工布线的命令为Route->connect,执行命令后,右侧控制面板如图8.14所示. ...

  2. es6模块化设计

    //导出 //方式一 export const name = 'hello' export let addr = 'chengdu' export var list = [1,2,3] //方式二 c ...

  3. android 使用系统级别权限

    java.lang.SecurityException: Neither user 10027 nor current process has android.permission.MODIFY_PH ...

  4. 【网易官方】极客战记(codecombat)攻略-地牢-焰中舞动

    关卡连接: https://codecombat.163.com/play/level/fire-dancing 用循环节省输入并拯救英雄! 简介: 左 右 起舞,避开火球. 使用 while tru ...

  5. [Vue源码]一起来学Vue双向绑定原理-数据劫持和发布订阅

    有一段时间没有更新技术博文了,因为这段时间埋下头来看Vue源码了.本文我们一起通过学习双向绑定原理来分析Vue源码.预计接下来会围绕Vue源码来整理一些文章,如下. 一起来学Vue双向绑定原理-数据劫 ...

  6. CentOS 7 下挂载NTFS盘及开机自动挂载

    一.工具 NTFS-3G 二.安装2种安装方式 2.1.yum安装 yum install NTFS* 2.2.编译安装 下载 解压 wget https://tuxera.com/opensourc ...

  7. JQuery/JS插件 jsTree加载树,预先加载,初始化时加载前三级节点,当展开第三级节点时 就加载该节点下的所有子节点

    jsTree加载树, 初始化时 加载前三级节点, 当展开第三级节点时 就加载该节点下的所有子节点 html: <!DOCTYPE html> <html> <head&g ...

  8. golang采坑记录

    安装golang,引入第三方库,采坑 1.获取安装包 go语言中文网:https://studygolang.com/dl 官网地址:https://studygolang.com/dl 2.下载 选 ...

  9. Codeforces Round #598 (Div. 3) D. Binary String Minimizing

    You are given a binary string of length nn (i. e. a string consisting of nn characters '0' and '1'). ...

  10. 概率dp poj 3071

    题目首先给出一个n,表示比赛一共进行n轮,那么队伍就有2^n只队伍输入一个2^n*2^n的矩阵,p[i][j]代表队伍i打败队伍j的概率dp[i][j]代表第i轮比赛的时候,队伍j赢的概率首先初始化时 ...