Codeforces Round #438 868A/B/C
14225 ワード
A.Bark to Unlock
time limit per test: 2 seconds
タイトル:
まず1つの長さが2の文字列をパスワードとして与え,n個の長さが2の文字列を与え,これらの文字列の組合せがパスワードを構成できるか否かを判断する.
考え方:
与えられた文字列にパスワードが含まれているかどうかを処理し、2つの判断を行います.各文字列は複数回利用できることに注意してください.
B.Race Against Time
time limit per test: 2 seconds
タイトル:
時計に現れる時刻を与え、t 1からt 2までポインタを褒めなくてもよいか否かを判断する.
考え方:
各ポインタがt 1とt 2の同じ角度にあるか否かを判断する.
C.Qualification Rounds
time limit per test: 2 seconds
タイトル:
Snark and Philipは1セットの問題を出しますが、どのチームもこれらの問題の中のいくつかの問題をしたことがあります.試合をもっと面白くするために、彼らは出題を探して、各チームの少なくとも半分の問題がしたことがありません.n個の問題,k個の行列を与え,1個の行列は各行列の各問題に対する状態を表す.
考え方:
実は2つの問題を見つけて、チームごとに1つやったことがあるか、やったことがないことを考えています.各問題の状態を状圧し,そのうちの1つを列挙し,別の実行可能な状態があるか否かを二分して判断する.
D问题は読んで问题を読んで、それから道を走って数点をこすって、后で更に问题を补って...( •̀ ω •́ )✧
転載先:https://www.cnblogs.com/cniwoq/p/7629851.html
time limit per test: 2 seconds
タイトル:
まず1つの長さが2の文字列をパスワードとして与え,n個の長さが2の文字列を与え,これらの文字列の組合せがパスワードを構成できるか否かを判断する.
考え方:
与えられた文字列にパスワードが含まれているかどうかを処理し、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
", flag?"YES": "NO");
return 0;
}
B.Race Against Time
time limit per test: 2 seconds
タイトル:
時計に現れる時刻を与え、t 1からt 2までポインタを褒めなくてもよいか否かを判断する.
考え方:
各ポインタがt 1とt 2の同じ角度にあるか否かを判断する.
#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&&harct1&&m=arct1&&s<=arct2) flag1 = false;
if (h0||m0||s=0) flag2 = false;
if (h>arct2&&h<360||m>arct2&&m<360||s>arct2&&s<=360) flag2 = false;
// printf("%d %d
", 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
");
else printf("NO
");
return 0;
}
C.Qualification Rounds
time limit per test: 2 seconds
タイトル:
Snark and Philipは1セットの問題を出しますが、どのチームもこれらの問題の中のいくつかの問題をしたことがあります.試合をもっと面白くするために、彼らは出題を探して、各チームの少なくとも半分の問題がしたことがありません.n個の問題,k個の行列を与え,1個の行列は各行列の各問題に対する状態を表す.
考え方:
実は2つの問題を見つけて、チームごとに1つやったことがあるか、やったことがないことを考えています.各問題の状態を状圧し,そのうちの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<1);
else {
dfs(x, t+1); dfs(x^(1<1);
}
}
}
int main(int argc, char const *argv[])
{
scanf("%d%d", &N, &K);
flag = false;
for (int i = 0; i < N; i++) {
int res = 0;
for (int j = 0; j < K; j++) {
int a; scanf("%d", &a);
if (a == 1) res += 1<<j;
}
if (res == 0) flag = true;
r[i] = res;
}
sort(r, r + N);
for (int i = 0; i < N; i++) dfs(r[i], 0);
printf("%s
", flag?"YES": "NO");
return 0;
}
D问题は読んで问题を読んで、それから道を走って数点をこすって、后で更に问题を补って...( •̀ ω •́ )✧
転載先:https://www.cnblogs.com/cniwoq/p/7629851.html