Codeforces Round #268 (Div. 2)
首先声明本学渣是绿名........大犇切勿鄙视.........
A. I Wanna Be the Guy
There is a game called "I Wanna Be the Guy", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.
Little X can pass only p levels of the game. And Little Y can pass onlyq levels of the game. You are given the indices of levels Little X can pass and the indices of levels Little Y can pass. Will Little X and Little Y pass the whole game, if they cooperate each other?
The first line contains a single integer n (1 ≤ n ≤ 100).
The next line contains an integer p (0 ≤ p ≤ n) at first, then follows p distinct integers a1, a2, ..., ap(1 ≤ ai ≤ n). These integers denote the indices of levels Little X can pass. The next line contains the levels Little Y can pass in the same format. It's assumed that levels are numbered from 1 to n.
If they can pass all the levels, print "I become the guy.". If it's impossible, print "Oh, my keyboard!" (without the quotes).
4 3 1 2 3 2 2 4
I become the guy.
4 3 1 2 3 2 2 3
Oh, my keyboard!
In the first sample, Little X can pass levels [1 2 3], and Little Y can pass level [2 4], so they can pass all the levels both.
In the second sample, no one can pass level 4.
一:第一题直接开数组存时间,然后判断区间是否填满就行了..........
#include<iostream>
#include<cstring>
using namespace std;
const int M=105;
int n;
int p;
int q;
int s[M];
int main()
{
memset(s, 0, sizeof(s));
cin>>n;
cin>>p;
for (int i=1; i<=p; i++)
{
int k;
cin>>k;
s[k]=1;
}
cin>>q;
for (int i=1; i<=q; i++)
{
int k;
cin>>k;
s[k]=1;
}
bool flag=false;
for (int i=1; i<=n; i++)
{
if (!s[i])
{
flag=true;
break;
}
}
if (!flag) cout<<"I become the guy."<<endl;
else cout<<"Oh, my keyboard!"<<endl;
return 0;
}
--------------------------------------------------------------------------华丽的分割线-------------------------------------------------------------------------------------------------
B. Chat Online
Little X and Little Z are good friends. They always chat online. But both of them have schedules.
Little Z has fixed schedule. He always online at any moment of time between a1 and b1, betweena2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time when he gets up. If he gets up at time0, he will be online at any moment of time between c1 and d1, betweenc2 and d2, ..., between cq and dq (all borders inclusive). But if he gets up at timet, these segments will be shifted by t. They become [ci + t, di + t] (for alli).
If at a moment of time, both Little X and Little Z are online simultaneosly, they can chat online happily. You know that Little X can get up at an integer moment of time betweenl and r (both borders inclusive). Also you know that Little X wants to get up at the moment of time, that is suitable for chatting with Little Z (they must have at least one common moment of time in schedules). How many integer moments of time from the segment [l, r] suit for that?
The first line contains four space-separated integers p, q, l, r (1 ≤ p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000).
Each of the next p lines contains two space-separated integersai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integerscj, dj (0 ≤ cj < dj ≤ 1000).
It's guaranteed that bi < ai + 1 anddj < cj + 1 for all validi and j.
Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.
1 1 0 4 2 3 0 1
3
2 3 0 20 15 17 23 26 1 4 7 11 15 17
20
二:第二题也是简单的数组存放相同的上网时间点.......数据太弱了....直接暴力存储....我是学渣....
#include<iostream>
#include<cstring>
using namespace std;
const int M=5005;
int m[M];
int x[M];
int y[M];
int s[M];
int p, q, l, r;
int main()
{
memset(m, 0, sizeof(m));
memset(s, 0, sizeof(s));
cin>>p>>q>>l>>r;
for (int i=1; i<=p; i++)
{
int a, b;
cin>>a>>b;
for (int j=a; j<=b; j++)
s[j]=1;
}
for (int i=1; i<=q; i++)
{
int a, b;
cin>>a>>b;
x[i]=a;
y[i]=b;
}
int ans=0;
bool flag;
for (int i=l; i<=r; i++)
{
for (int k=1; k<=q; k++)
{
flag=false;
for (int j=x[k]; j<=y[k]; j++)
{
if (s[j+i]) {
ans++;
flag=true;
break;
}
}
if (flag) break;
}
}
cout<<ans<<endl;
return 0;
}
--------------------------------------------------------------------------华丽的分割线-------------------------------------------------------------------------------------------------
C. 24 Game
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game.
Initially you have a sequence of n integers:1, 2, ..., n. In a single step, you can pick two of them, let's denote thema and b, erase them from the sequence, and append to the sequence eithera + b, or a - b, or a × b.
After n - 1 steps there is only one number left. Can you make this number equal to24?
The first line contains a single integer n(1 ≤ n ≤ 105).
If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes).
If there is a way to obtain 24 as the result number, in the followingn - 1 lines print the required operations an operation per line. Each operation should be in form: "aop b =c". Where a andb are the numbers you've picked at this operation;op is either "+", or "-", or "*";c is the result of corresponding operation. Note, that the absolute value ofc mustn't be greater than 1018. The result of the last operation must be equal to24. Separate operator sign and equality sign from numbers with spaces.
If there are multiple valid answers, you may print any of them.
1
NO
8
YES 8 * 7 = 56 6 * 5 = 30 3 - 4 = -1 1 - 2 = -1 30 - -1 = 31 56 - 31 = 25 25 + -1 = 24
第三题差30秒我就能ac了..................就是只差30秒啊................结束后我交了就ac了.........我不服....好吧...渣渣没吐槽的权利。
三:其实这一题看起来很难,实际上脑补一下有什么可以水过就行了,我先打表了前8, 前8已经可以组成0, 和 24, 0乘以任何数等于0, 所以只需要将后面的乘上就行了,
然后最后0+24=24........
#include<iostream>
using namespace std;
int n;
int main()
{
cin>>n;
if (n<=3){
cout<<"NO"<<endl;
return 0;
}
cout<<"YES"<<endl;
if (n==4) cout<<"3 * 4 = 12\n2 * 1 = 2\n12 * 2 = 24\n";
else if (n==5) cout<<"4 * 5 = 20\n2 + 3 = 5\n5 - 1 = 4\n20 + 4 = 24\n" ;
else if (n==6) cout<<"4 * 5 = 20\n2 - 1 = 1\n6 - 3 = 3\n20 + 1 = 21\n21 + 3 = 24\n";
else if (n==7) cout<<"6 * 7 = 42\n4 * 5 = 20\n42 - 20 = 22\n3 - 2 = 1\n22 + 1 = 23\n23 + 1 = 24\n";
else if (n==8) cout<<"8 * 7 = 56\n6 * 5 = 30\n3 - 4 = -1\n1 - 2 = -1\n30 - -1 = 31\n56 - 31 = 25\n25 + -1 = 24\n";
else
{
cout<<"6 + 8 = 14\n";
cout<<"2 * 7 = 14\n";
cout<<"14 - 14 = 0\n";
cout<<"4 * 5 = 20\n";
cout<<"1 + 3 = 4\n";
cout<<"20 + 4 = 24\n";
for (int i=9; i<=n; i++)
{
cout<<i<<" * 0 = 0\n";
}
cout<<"24 + 0 = 24\n";
}
return 0;
}
下面的大犇题,弱渣不会做,就这么多了
--------------By 绿名的弱渣..........