【LGR-062】洛谷10月月赛 III div.2 (A-C)
前言
100+100+46+0=246pts 300多名
以后每次比赛都要有进步哦!qwq
小D与笔试
水题
Code
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
inline int read() {
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
return x * f;
}
int n,q;
map<string,string> s;
int main()
{
n = read(), q = read();
for(int i=1;i<=n;++i) {
string a,b;
cin>>a>>b; s[a] = b;
}
for(int i=1;i<=q;++i) {
string a,b,c,d,e;
cin>>e>>a>>b>>c>>d;
if(s[e] == a) cout<<"A"<<endl;
if(s[e] == b) cout<<"B"<<endl;
if(s[e] == c) cout<<"C"<<endl;
if(s[e] == d) cout<<"D"<<endl;
}
return 0;
}
/*
3 4
decoak yes
duliuchutiren nonono
csps noiptg
decoak yes no qwq qaq
csps noiptg noippj noi cspj
decoak qwq qaq yesyes yes
duliuchutiren yes no nono nonono
A
A
D
D
*/
小E与美食
水题。但是卡精度
Code
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#define int long long
using namespace std;
inline int read() {
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
return x * f;
}
const int N = 3e5+7;
int n;
int a[N];
bool cmp(int x,int y) {
return x > y;
}
signed main()
{
int n = read();
for(int i=1;i<=n;++i)
a[i] = read();
sort(a+1, a+1+n, cmp);
double maxx = 0.0; double sum = 0.0;
for(int i=1;i<=n;++i) {
sum += a[i];
double ss = sum*sum;
double tmp = (double)(ss*1.0/i*1.0);
maxx = max(maxx,tmp);
}
printf("%.8lf\n",maxx);
return 0;
}
/*
2
2 1
4.50
*/
小C与桌游
拓扑排序 + 贪心
但是贪心要考虑全面,在求ans2(就是第二问的时候),要将能去的点(now<last)全部走一遍,这样再找出来的最大值才是最优走法
实力不足,码力有限。冷静分析,考虑全面。
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
inline int read() {
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
return x * f;
}
const int N = 5e5+7;
int n,m,ans1,ans2;
int du1[N],du2[N];
bool vis[N];
vector<int> E[N];
struct Node {
int x,y; //×??o£??ù×ó
};
priority_queue<int,vector<int>,greater<int> > q1; //??¨¢? |ìY?? ?á???¨?
queue<int> q3;
priority_queue<int> A;
void topo() {
for(int i=1;i<=n;++i)
if(!du1[i]) q1.push(i), A.push(i);
int last = 0;
while(!q1.empty()) { //?¨°|ì??á??¨¤?á?
int u = q1.top(); q1.pop();
if(u > last) ans1++, last = u;
for(int i=0;i<E[u].size();++i) {
int v = E[u][i]; du1[v]--;
if(!du1[v]) q1.push(v);
}
}
last = 0;
while(!A.empty()) {
while(!A.empty()) {
int now = A.top(); A.pop();
if(now > last) {
last = now; ++ans2;
}
q3.push(now);
}
while(!q3.empty()) {
int now = q3.front(); q3.pop();
// printf("now = %d\n",now);
for(int i=0;i<E[now].size();++i) {
int to = E[now][i]; --du2[to];
if(!du2[to]) {
if(to < last) q3.push(to);
else A.push(to);
}
}
}
// printf("Atop = %d\n",A.top());
}
}
int main()
{
n = read(), m = read();
for(int i=1,u,v;i<=m;++i) {
u = read(), v = read();
E[u].push_back(v); du1[v]++; du2[v]++;
}
topo();
ans1 = min(ans1,1919810);
ans2 = min(ans2,1919810);
printf("%d\n%d\n",ans1,ans2);
return 0;
}
/*
3 2
1 2
1 3
3
2
*/
【LGR-062】洛谷10月月赛 III div.2 (A-C)的更多相关文章
- 【LGR-060】洛谷10月月赛 I div.1&div.2
Preface 一边打一边写作文打的像shit,T2失智严重特判错了233 Orz Div1 Rank2的foreverlastnig聚聚,顺便说一句显然Luogu的比赛质量比以往显著提高了啊 以下题 ...
- 【LGR-065】洛谷11月月赛 III Div.2
临近$CSP$...... 下午打了一发月赛,感觉很爽. 非常菜的我只做了前两题......然而听说前两题人均过...... 写法不优秀被卡到$#1067$...... T1:基础字符串练习题: 前缀 ...
- 【LGR-054】洛谷10月月赛II
[LGR-054]洛谷10月月赛II luogu 成功咕掉Codeforces Round #517的后果就是,我\(\mbox{T4}\)依旧没有写出来.\(\mbox{GG}\) . 浏览器 \( ...
- 洛谷10月月赛II题解
[咻咻咻] (https://www.luogu.org/contestnew/show/11616) 令人窒息的洛谷月赛,即将参加NOIp的我竟然只会一道题(也可以说一道也不会),最终145的我只能 ...
- 洛谷10月月赛Round.3
Rank11:260=60+100+100 P2409 Y的积木 题目背景 Y是个大建筑师,他总能用最简单的积木拼出最有创意的造型. 题目描述 Y手上有n盒积木,每个积木有个重量.现在他想从每盒积木中 ...
- 洛谷10月月赛Round.1| P3398 仓鼠找sugar[LCA]
题目描述 小仓鼠的和他的基(mei)友(zi)sugar住在地下洞穴中,每个节点的编号为1~n.地下洞穴是一个树形结构.这一天小仓鼠打算从从他的卧室(a)到餐厅(b),而他的基友同时要从他的卧室(c) ...
- 洛谷10月月赛Round.1| P3400 仓鼠窝[单调栈]
题目描述 萌萌哒的Created equal是一只小仓鼠,小仓鼠自然有仓鼠窝啦. 仓鼠窝是一个由n*m个格子组成的行数为n.列数为m的矩阵.小仓鼠现在想要知道,这个矩阵中有多少个子矩阵!(实际上就是有 ...
- 洛谷10月月赛Round.1| P3399 丝绸之路 [DP]
题目背景 张骞于公元前138年曾历尽艰险出使过西域.加强了汉朝与西域各国的友好往来.从那以后,一队队骆驼商队在这漫长的商贸大道上行进,他们越过崇山峻岭,将中国的先进技术带向中亚.西亚和欧洲,将那里的香 ...
- 洛谷10月月赛R2·浴谷八连测R3题解
早上打一半就回家了... T1傻逼题不说了...而且我的写法比题解要傻逼很多T T T2可以发现,我们强制最大值所在的块是以左上为边界的倒三角,然后旋转4次就可以遍历所有的情况.所以二分极差,把最大值 ...
随机推荐
- windows 下的定时任务 (原)
linux 下的定时任务是crontab 以前都是linux的定时任务,这次在windows做了定时任务,简单记录一下(win8 跟 win10为例) windows 2008下的定时任务配置: 控制 ...
- Codeforces Round #369 (Div. 2) B. Chris and Magic Square (暴力)
Chris and Magic Square 题目链接: http://codeforces.com/contest/711/problem/B Description ZS the Coder an ...
- Hash算法原理以及HashCode深入理解
Java中的Collection有两类,一类是List,一类是Set.List内的元素是有序的,元素可以重复.Set元素无序,但元素不可重复.要想保证元素不重复,两个元素是否重复应该依据什么来判断呢? ...
- nginx 和 php
sudo apt-get install nginx sudo groupadd www sudo useradd -g www www /etc/nginx/nginx.conf service n ...
- codeforces 722F - Cyclic Cipher
题目链接:http://codeforces.com/problemset/problem/722/F ------------------------------------------------ ...
- vundle的安装笔记-20160721
vundle是一个vim管理插件, 而bundle是命令, 用来操作vundle的. bundle 英[ˈbʌndəl] 美[ˈbʌndəl] n. 捆,束,包:大量:一大笔钱:极度 v. 归拢:捆: ...
- redux源码浅入浅出
运用redux有一段时间了,包括redux-thunk和redux-saga处理异步action都有一定的涉及,现在技术栈转向阿里的dva+antd,好用得不要不要的,但是需要知己知彼要对react家 ...
- 测开之路九十八:js变量和语句
这里为了方便调试,在jsbin网站上面编写js脚本:https://jsbin.com/?js,console 可以点击增加/减少对应展示分页,Console为控制台部分,Output为页面部分 变量 ...
- list、tuple、dict加*星号
*相当于解压的作用,当list中只有一个元素时,利用*作用相当于直接去[],去[]后的数据类型是字符串. _list = [1,2,3] _tuple = (1,2,3) _dict = {1:'a' ...
- [转载]OpenSSL中文手册之命令行详解(未完待续)
声明:OpenSSL之命令行详解是根据卢队长发布在https://blog.csdn.net/as3luyuan123/article/details/16105475的系列文章整理修改而成,我自己 ...