熬到半夜打结果前一个小时提交代码的页面根本加载不进去,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. Java课堂疑问解答与思考3

    一. 两对整数明明完全一样,为何一个输出true,一个输出false? 答: 整数在小于127时都可以用常量池,因此第一次比较的的地址是取自同一个地址的数字,而第二次比较的数是创建了两个不同地址的对象 ...

  2. mysql中关于 like ,not like 的用法时不能显示空值的数据(空值不参与判断,直接过滤空值)

    一般在项目中用法是(这种没办法显示空值的数据): select * from 表 where 字段 like %aaa%; 解决空值不显示(除了显示的数据外,空值数据也可以显示): select * ...

  3. centos7 VM虚拟机在主机关机重启后,无法ping通

    解决办法 1.虚拟机的某些网络相关的服务没有启动,打开电脑的服务启动相关服务 2.打开虚拟机的虚拟网络设置,恢复默认设置即可 3.判定虚拟网卡的网关和centos的网关是否一致,如果不一致,改成一致, ...

  4. JavaWeb返回Json格式数据JQuery Ajax无法解析的问题

    今天在写实验室的傻逼Java Web小项目的时候,有一个需要发布内容的地方,因为想做的让用户感觉优雅一点 所以就是用了Ajax来做,本来很简单的一个小玩意,竟然花了半个多小时的时间,主要是将时间花在了 ...

  5. Unix时间戳和Java 的 System.currentTimeMillis()的区别

  6. 使用extract-text-webpack-plugin插件后报错

    如果你使用的webpack是4+版本,那么尝试运行npm install extract-text-webpack-plugin@next ,即可解决问题 然而最好的解决办法是在webpack4+的版 ...

  7. 运用swagger编写api文档

    一.什么是swagger 随着互联网技术的发展,前后端技术在各自的道路上越走越远,他们之间的唯一联系变成了api接口,api接口文档编程了前后端人员的纽带,而swagger就是书写api文档的一款框架 ...

  8. IDEA--错误:找不到或无法加载XXXXX--解决方法--创建javafx或其他项目出现的问题

    今天一上午超厂长在学习javafx的时候,总是创建一个然后运行就会出现 出现错误:找不到或无法加载主类 找了二个小时,都说是jdk或者其他环境配置问题 按照那些改了也没用重新创建一个也提示出现错误:找 ...

  9. 【源码解读】cycleGAN(二) :训练

    源码地址:https://github.com/aitorzip/PyTorch-CycleGAN 训练的代码见于train.py,首先定义好网络,两个生成器A2B, B2A和两个判别器A, B,以及 ...

  10. flask之上下文管理

    简单来说,falsk上下文管理可以分为三个阶段: 1.请求进来时,将请求鞋底的相关数据放入上下文管理中进行管理 2.在视图函数中,要去上下文管理中取值 3.请求响应之后,要将上下文管理中的数据清除 详 ...