博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #438 868A/B/C
阅读量:6984 次
发布时间:2019-06-27

本文共 2532 字,大约阅读时间需要 8 分钟。


A.

time limit per test: 2 seconds

题意:

先给出一个长度是2的字符串作为密码,在给出n个长度是2字符串,判断这些字符串的组合可不可以组成密码。

思路:

先处理给出的字符串中是否含有密码,然后两个两个的判断。注意每个字符串可以多次利用。

#include "bits/stdc++.h"using namespace std;const int maxn = 120;char s[maxn][3];int main(int argc, char const *argv[]){    scanf("%s", s[0]);    int n;    scanf("%d", &n);    for (int i = 1; i <= n ;i++) {        scanf("%s", s[i]);    }    bool flag = false;    for (int i = 1; i <= n; i++) {        if (strcmp(s[0], s[i]) == 0) flag = true;        for (int j = 1; j <= n; j++) {            if (flag) break;            if (s[0][0] == s[i][1] && s[0][1] == s[j][0]) flag = true;        }        if (flag) break;    }    printf("%s\n", flag?"YES": "NO");    return 0;}

B.

time limit per test: 2 seconds

题意:

给出现在钟表的时刻,判断从t1到t2是否可以不夸过指针。

思路:

判断每个指针是否在都在t1和t2的同一夹角里。

#include "bits/stdc++.h"using namespace std;const double pc = 1e-3;double arct2, arct1, t;bool judge(double h, double m, double s) {    bool flag1 = true, flag2 = true;    if (h>arct1&&h
arct1&&m
=arct1&&s<=arct2) flag1 = false; if (h
0||m
0||s
=0) flag2 = false; if (h>arct2&&h<360||m>arct2&&m<360||s>arct2&&s<=360) flag2 = false; // printf("%d %d\n", flag1, flag2); return flag1||flag2;}int main(int argc, char const *argv[]){ int h, m, s, t1, t2; scanf("%d%d%d%d%d", &h, &m, &s, &t1, &t2); if (h == 12) h = 0; arct1 = t1*360/12; arct2 = t2*360/12; double arcs = s*360/60; double arcm = ((double)m + (double)s/60)*360.0/60; double arch = ((double)h + (double)s/60)*360.0/12; if (arct1 > arct2) { t = arct1; arct1 = arct2; arct2 = t;} if (judge(arch, arcm, arcs)) printf("YES\n"); else printf("NO\n"); return 0;}

C.

time limit per test: 2 seconds

题意:

Snark and Philip 要出一套题,但是每个队伍都会都做过这些题里的某些题,为了让比赛更有意思,他们要找出题,使得每个队至少有一半的题没有做过。给出n个题,k个队伍,一个矩阵表示每个队伍对每道题的状态。

思路:

其实只要考虑找到两道题,使得每个队做过1个或者没有做过。把每个题的状态进行状压,然后枚举其中的一道题,二分判断是否有另一种可行的状态。

#include "bits/stdc++.h"using namespace std;const int maxn = 1e5 + 10;bool flag;int N, K;int r[maxn];void judge(int x) {    int ans = 0;    int ub = N, lb = 0;    while (ub >= lb) {        int mid = (ub + lb)/2;        if (r[mid] >= x) {            ans = mid;            ub = mid - 1;        }           else lb = mid + 1;    }    if (r[ans] == x)  flag = true;}void dfs(int x, int t) {    if (t == K) {judge(x);}    else {        if ((x>>t)&1)  dfs(x^(1<

D题读了读题,然后跑路去刷数分了,以后再补题。。。。。( •̀ ω •́ )✧

转载于:https://www.cnblogs.com/cniwoq/p/7629851.html

你可能感兴趣的文章
Eclipse 一直Building Workspace 的解决办法
查看>>
ThinkPHP笔记——完全配置参考手册
查看>>
BZOJ1503[NOI2004]郁闷的出纳员——treap
查看>>
asp.net mvc的初学
查看>>
关于DEBUG的一点体会
查看>>
PE格式详细讲解11 - 系统篇11|解密系列
查看>>
Poj 3126 Prime Path
查看>>
专门用来显示大量数据的视图:AdapterView(1)
查看>>
SDUT OJ 数据结构实验之链表四:有序链表的归并
查看>>
UVA11825: Hackers' Crackdown (状压dp)
查看>>
[解决]Win7 操作系统不能安装VMware
查看>>
js想不通的地方
查看>>
刘若英《爱情限量版》摘录
查看>>
Requests请求库
查看>>
request.setCharacterEncoding("utf-8");
查看>>
Svn安装成功后的操作
查看>>
自定义EL函数、自定义JSTL标签
查看>>
多线程与网络之NSURLConnection发送请求
查看>>
走的最急的,都是最美的风景
查看>>
【后缀数组】【poj2774】【 Long Long Message】
查看>>