熬到半夜打结果前一个小时提交代码的页面根本加载不进去,D题写完还因为小点没判被hack掉了。。。
rating什么的都是身外之物了,于是乎喜闻乐见地又掉回绿名了。

A题:

*题目描述:
Bear看一场90分钟的比赛,有n个有趣的事件的时间点,Bear如果连续15分钟没有看到有趣的事件,那么它就会关掉电视,问Bear最多可以看多长时间的电视?
*题解:
模拟,记得判最后一个点到90分钟的距离。
*代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> #ifdef WIN32
#define LL "%I64d"
#else
#define LL "%lld"
#endif #ifdef CT
#define debug(...) printf(__VA_ARGS__)
#define setfile()
#else
#define debug(...)
#define filename ""
#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout);
#endif #define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
char B[1 << 15], *S = B, *T = B;
inline int FastIn()
{
R char ch; R int cnt = 0; R bool minus = 0;
while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
ch == '-' ? minus = 1 : cnt = ch - '0';
while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
return minus ? -cnt : cnt;
} int main()
{
// setfile();
R int n = FastIn(), last = 0;
for (R int i = 1; i <= n; ++i)
{
R int t = FastIn();
if (t - last > 15) return !printf("%d\n",last + 15 );
last = t;
}
if (90 - last > 15) return !printf("%d\n",last + 15 );
puts("90");
return 0;
}

B题:

*题目描述:
有n个题目和m种关系,每种关系表示两个题目是相似的。求所有的二分图的数量,同时要保证其中一个集合的点的编号都大于另一个集合的点的编号。
*题解:
我的第一反应是图论的题,但是想得非常复杂,然而zzx一眼秒题,把问题转化成区间上的问题。
*代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> #ifdef WIN32
#define LL "%I64d"
#else
#define LL "%lld"
#endif #ifdef CT
#define debug(...) printf(__VA_ARGS__)
#define setfile()
#else
#define debug(...)
#define filename ""
#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout);
#endif #define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
char B[1 << 15], *S = B, *T = B;
inline int FastIn()
{
R char ch; R int cnt = 0; R bool minus = 0;
while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
ch == '-' ? minus = 1 : cnt = ch - '0';
while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
return minus ? -cnt : cnt;
} int main()
{
// setfile();
R int n = FastIn(), m = FastIn();
R int left = 1, right = n;
for (R int i = 1; i <= m; ++i)
{
R int l = FastIn(), r = FastIn();
cmax(left, dmin(l, r));
cmin(right, dmax(l, r));
}
printf("%d\n",dmax(right - left, 0) );
return 0;
}

C题:

*题目描述:
有n个数,每个数代表一种颜色,颜色的范围在1~n之间。问每种颜色在多少个区间内是众数(如果有多个众数则取较小的那个)。
*题解:
直接暴力搞,枚举左端点,每次把出现的数计到一个数组里面,然后用一个变量维护出现次数的最大值。
*代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> #ifdef WIN32
#define LL "%I64d"
#else
#define LL "%lld"
#endif #ifdef CT
#define debug(...) printf(__VA_ARGS__)
#define setfile()
#else
#define debug(...)
#define filename ""
#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout);
#endif #define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
char B[1 << 15], *S = B, *T = B;
inline int FastIn()
{
R char ch; R int cnt = 0; R bool minus = 0;
while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
ch == '-' ? minus = 1 : cnt = ch - '0';
while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
return minus ? -cnt : cnt;
} int main()
{
// setfile();
R int n = FastIn();
for (R int i = 1; i <= n; ++i)
t[i] = FastIn();
for (R int i = 1; i <= n; ++i)
{
R int maxx = 0, node;
for (R int j = 1; j <= n; ++j) cnt[j] = 0;
for (R int j = i; j <= n; ++j)
{
++cnt[t[j]];
maxx < cnt[t[j]] || (maxx == cnt[t[j]] && t[j] < node) ? maxx = cnt[t[j]], node = t[j] : 0;
ans[node]++;
}
}
for (R int i = 1; i <= n; ++i) printf("%d ",ans[i] );
return 0;
}

D题:

*题目描述:
请你构造一幅图,这幅图满足:节点数为n,边数小于等于m,同时,存在一条路径,可以从a经过所有的节点仅一次到达b,也可以从c经过所有的节点仅一次然后到达d。
*题解:
数学构造题。除了a,b,c,d的点先构一条链,然后链的一头连a,c,另一头连b,d,然后再把a和c,b和d连起来(这里建议画一副图来理解)。于是边就变成了n+1条,否则就不成立。(我sb了没有判n=4的情况,即都是无解,结果过了pretest完立马被人x掉,直至比赛结束一直没有调出来)
*代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> #ifdef WIN32
#define LL "%I64d"
#else
#define LL "%lld"
#endif #ifdef CT
#define debug(...) printf(__VA_ARGS__)
#define setfile()
#else
#define debug(...)
#define filename ""
#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout);
#endif #define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
char B[1 << 15], *S = B, *T = B;
inline int FastIn()
{
R char ch; R int cnt = 0; R bool minus = 0;
while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
ch == '-' ? minus = 1 : cnt = ch - '0';
while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
return minus ? -cnt : cnt;
} int main()
{
// setfile();
R int n = FastIn(), m = FastIn();
R int a = FastIn(), b = FastIn(), c = FastIn(), d = FastIn();
if (m < n + 1 || n == 4)
{
puts("-1");
return 0;
}
printf("%d ",a );
printf("%d ",c );
for (R int i = 1; i <= n; ++i) if (i != a && i != b && i != c && i != d) printf("%d ",i );
printf("%d ",d );
printf("%d\n",b ); printf("%d ",c );
printf("%d ",a );
for (R int i = 1; i <= n; ++i) if (i != a && i != b && i != c && i != d) printf("%d ",i );
printf("%d ",b );
printf("%d\n",d );
return 0;
}

Codeforces Round #351(Div 2)的更多相关文章

  1. [Codeforces Round #351 Div. 2] 673A Bear and Game

    A. Bear and Game time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  2. 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 ...

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

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

  4. Codeforces Round #368 (Div. 2)

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

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

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

  6. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  7. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  8. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  9. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

随机推荐

  1. 【Linux开发】V4L2驱动框架分析学习

    Author:CJOK Contact:cjok.liao#gmail.com SinaWeibo:@廖野cjok 1.概述 Video4Linux2是Linux内核中关于视频设备的内核驱动框架,为上 ...

  2. Ubuntu 16.04系统挂载4T硬盘

    问题描述: Ubuntu 16.04系统,系统盘为240G固态硬盘,还有1T机械硬盘,现要再添加一个4T硬盘. 问题分析: 使用GTP对硬盘进行分区并挂载硬盘的方法,一般而言服务器上挂载的硬盘都是比较 ...

  3. 不容错过的 MySQL史上最全

    点击下方链接 http://c.biancheng.net/view/2361.html

  4. urllib库认证,代理,cookie

    认证,代理,cookie 1from urllib.request import HTTPBasicAuthHandler, HTTPPasswordMgrWithDefaultRealm, buil ...

  5. 使用批处理命令注册运行mysql数据库,无需注册mysql服务,可以在任意电脑登录使用

    使用批处理命令初始化和开启mysql服务,移植数据库之后可以直接运行访问,对于学习数据库的人来说特别的方便哦. 我们可以从mysql官网下载官方社区版本的mysql: 这里使用之前下载的8.0.15来 ...

  6. win 10 自带 Ubuntu 系统的文件位置

    win 10 自带 Ubuntu 系统的文件位置 Ubuntu 作为最为流行 Linux 系统中的一种,是用来学习 Linux 相关知识是最好不过的选择.专门搞一个 Ubuntu 系统的电脑不太现实, ...

  7. Java 关于SpringbootJPA分页及排序

    创建Pageable对象 看了网上很多博客,都是在用 new PageRequest的方法创建Pageable对象.可是估计很多同学写了之后才发现原来这个方法作者已经标记为过时了: 替代的方法是不要n ...

  8. ResultEntity

    就是封装的一个map集合  省时省力好用 package com.ujy.utils; import java.util.HashMap; import java.util.Map; public c ...

  9. 3.17内存,进程,rpm和yum,python编译安装

    一.内存 前面说过内存有寄存器.高速缓存和内存条 但在实际情况中有些文件比较大,内存不足以读取其内容,并且大部分内容不是被立即使用,所以有了交换分区,即用硬盘空间临时存储相关部分,当作缓存,这部分就是 ...

  10. 搭建jumperserver堡垒机管理万台服务器-1

    搭建jumperserver堡垒机管理万台服务器-1 1  Jumpserver堡垒机概述-部署Jumpserver运行环境 2  安装Coco组件 3  安装Web-Terminal前端-Luna组 ...