Codeforces Round #454 (Div. 2, based on Technocup 2018 Elimination Round 4) A-C

来源:互联网 发布:2017年新疆网络管制 编辑:程序博客网 时间:2024/05/29 03:33


这套题有史以来做的最恶心的一套题,没有之一;

A题,讲的不明不白的。到底是区间还是这4个数,没有说明白, 交了7遍 全都是WA on test 4;因为一直认为就是这4个数里面选择 ,恶心, 实际要求是在区间里选定某个值;


暴力枚举!!!!!!!

A:

A. Masha and Bears
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car.

Masha came to test these cars. She could climb into all cars, but she liked only the smallest car.

It's known that a character with size a can climb into some car with size b if and only if a ≤ b, he or she likes it if and only if he can climb into this car and 2a ≥ b.

You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars.

Input

You are given four integers V1V2V3Vm(1 ≤ Vi ≤ 100) — sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3.

Output

Output three integers — sizes of father bear's car, mother bear's car and son bear's car, respectively.

If there are multiple possible solutions, print any.

If there is no solution, print "-1" (without quotes).

Examples
input
50 30 10 10
output
503010
input
100 50 10 21
output
-1
Note

In first test case all conditions for cars' sizes are satisfied.

In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20.



【题意】

公熊,母熊,小熊,玛莎, 

A喜欢B的 条件是,    a<b 并且 2a>b  

玛莎只喜欢最小的  这是一个限定条件;暴力枚举!!!

【代码实现】

#include <iostream>#include <bits/stdc++.h>#include <stdio.h>#include <string.h>using namespace std;int main(){    int a,b,c,d;    cin>>a>>b>>c>>d;    int x,y,z,q;    int flag=1;    for(int i=1;i<=200;i++){        for(int j=1;j<i;j++){            for(int k=1;k<i;k++){                if( a<=i && 2*a>=i && b<=j && 2*b>=j && c<=k && 2*c>=k && d<=k && 2*d>=k && 2*d<j )                {                    cout<<i<<endl;                    cout<<j<<endl;                    cout<<k<<endl;                    return 0;                }            }        }    }    cout<<-1<<endl;    return 0;}



B题要比A题简单,  就是题干又臭又长,   

B:

B. Tic-Tac-Toe
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.

The game is played on the following field.

Players are making moves by turns. At first move a player can put his chip in any cell of any small field. For following moves, there are some restrictions: if during last move the opposite player put his chip to cell with coordinates (xl, yl) in some small field, the next move should be done in one of the cells of the small field with coordinates (xl, yl). For example, if in the first move a player puts his chip to lower left cell of central field, then the second player on his next move should put his chip into some cell of lower left field (pay attention to the first test case). If there are no free cells in the required field, the player can put his chip to any empty cell on any field.

You are given current state of the game and coordinates of cell in which the last move was done. You should find all cells in which the current player can put his chip.

A hare works as a postman in the forest, he likes to foul bears. Sometimes he changes the game field a bit, so the current state of the game could be unreachable. However, after his changes the cell where the last move was done is not empty. You don't need to find if the state is unreachable or not, just output possible next moves according to the rules.

Input

First 11 lines contains descriptions of table with 9 rows and 9 columns which are divided into 9 small fields by spaces and empty lines. Each small field is described by 9 characters without spaces and empty lines. character "x" (ASCII-code 120) means that the cell is occupied with chip of the first player, character "o" (ASCII-code 111) denotes a field occupied with chip of the second player, character "." (ASCII-code 46) describes empty cell.

The line after the table contains two integers x and y (1 ≤ x, y ≤ 9). They describe coordinates of the cell in table where the last move was done. Rows in the table are numbered from up to down and columns are numbered from left to right.

It's guaranteed that cell where the last move was done is filled with "x" or "o". Also, it's guaranteed that there is at least one empty cell. It's not guaranteed that current state of game is reachable.

Output

Output the field in same format with characters "!" (ASCII-code 33) on positions where the current player can put his chip. All other cells should not be modified.

Examples
input
... ... ...... ... ...... ... ...... ... ...... ... ...... x.. ...... ... ...... ... ...... ... ...6 4
output
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... x.. ... !!! ... ... !!! ... ... !!! ... ... 
input
xoo x.. x..ooo ... ...ooo ... ...x.. x.. x..... ... ...... ... ...x.. x.. x..... ... ...... ... ...7 4
output
xoo x!! x!! ooo !!! !!! ooo !!! !!! x!! x!! x!! !!! !!! !!! !!! !!! !!! x!! x!! x!! !!! !!! !!! !!! !!! !!! 
input
o.. ... ...... ... ...... ... ...... xxx ...... xox ...... ooo ...... ... ...... ... ...... ... ...5 5
output
o!! !!! !!! !!! !!! !!! !!! !!! !!! !!! xxx !!! !!! xox !!! !!! ooo !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! 
Note

In the first test case the first player made a move to lower left cell of central field, so the second player can put a chip only to cells of lower left field.

In the second test case the last move was done to upper left cell of lower central field, however all cells in upper left field are occupied, so the second player can put his chip to any empty cell.

In the third test case the last move was done to central cell of central field, so current player can put his chip to any cell of central field, which is already occupied, so he can move anywhere. Pay attention that this state of the game is unreachable.


【题意】

给定九宫格, 输入x,y坐标 确定 x,y 在 小九宫格的哪个位置上, 对应大九宫格的位置全部赋值为!

若没有 。  则 全部都赋值为 !

【思路方法】

先找到,x,y坐标对应小九宫格的位置里 是不是有。  没有。 就全部 赋值!  有的话 对应大九宫格位置 赋值!



【代码实现】

#include <iostream>#include <bits/stdc++.h>#include <stdio.h>#include <string.h>using namespace std;int main(){    char str[100][100];    for(int i=0;i<9;i++)        for(int j=0;j<9;j++)            cin>>str[i][j];    int x,y;    cin>>x>>y;    x--,y--;    x%=3;    y%=3;    x*=3;    y*=3;    int flag=0;    for(int i=x;i<x+3;i++)        for(int j=y;j<y+3;j++)        {            if(str[i][j]=='.')            {                flag=1;                str[i][j]='!';            }        }    if(!flag)    {        for(int i=0;i<9;i++)        {            for(int j=0;j<9;j++)            {                if(str[i][j]=='.')                    str[i][j]='!';            }        }    }    for(int i=0;i<9;i++)    {        for(int j=0;j<9;j++)        {            cout<<str[i][j];            if(j==2||j==5)                cout<<" ";        }        if(i==2||i==5)            cout<<endl;        cout<<endl;    }    return 0;}

C

C. Shockers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly.

Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of actions Valentin did.

The next n lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types:

  1. Valentin pronounced some word and didn't get an electric shock. This action is described by the string ". w" (without quotes), in which "." is a dot (ASCII-code 46), and w is the word that Valentin said.
  2. Valentin pronounced some word and got an electric shock. This action is described by the string "! w" (without quotes), in which "!" is an exclamation mark (ASCII-code 33), and w is the word that Valentin said.
  3. Valentin made a guess about the selected letter. This action is described by the string "? s" (without quotes), in which "?" is a question mark (ASCII-code 63), and s is the guess — a lowercase English letter.

All words consist only of lowercase English letters. The total length of all words does not exceed 105.

It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.

Output

Output a single integer — the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.

Examples
input
5! abc. ad. b! cd? c
output
1
input
8! hello! codeforces? c. o? d? h. l? e
output
2
input
7! ababahalamaha? a? b? a? b? a? h
output
0
Note

In the first test case after the first action it becomes clear that the selected letter is one of the following: a, b, c. After the second action we can note that the selected letter is not a. Valentin tells word "b" and doesn't get a shock. After that it is clear that the selected letter is c, but Valentin pronounces the word cd and gets an excessive electric shock.

In the second test case after the first two electric shocks we understand that the selected letter is e or o. Valentin tries some words consisting of these letters and after the second word it's clear that the selected letter is e, but Valentin makes 3 more actions before he makes a correct hypothesis.

In the third example the selected letter can be uniquely determined only when Valentin guesses it, so he didn't get excessive electric shocks.



【题意】

给定  n种 串; 形式为   '!' '.'  '?"   这三种分别代表  '!'  受罚  '.'不受罚  '?' 猜答案

n行,  每一串字符,

 ? 猜字母是不是这个字母, 

!  这串字母里有这个字母  

。  串里面没有这个字母

最后一次之前 每一个 ? 和 !  都会被罚一次;

然后问  可以避免受罚的 次数是多少, 就是第几次是已经确认找到这个字母后没有必要的操作 是多少次。


【思路】

模拟

最后一次之前;

!  当前串和 可能 字母取交集

。  当前串和可能字母取 差集

? 当前字母 和可能字母 取 差

pos记录可能字母。

【代码实现】

#include <iostream>#include <bits/stdc++.h>#include <stdio.h>#include <string.h>#define SHUT std::ios::sync_with_stdio(false)#define mem(a,b) memset(a,b,sizeof(a))using namespace std;int v[50];int f[50];int main(){    SHUT;    int n;    for(int i = 0; i < 26; i++) v[i] = 1;    string str,temp;    cin>>n;    int ans=0;    int pos=26;    for(int i=1;i<=n;i++)    {          char c;          cin>>c;          if(c=='?')          {            char y;            cin>>y;            if(i!=n)            {                if(pos==1)                    ans++;                if(v[y-'a']==1)                    pos--;                v[y-'a']=0;            }          }          else          {              if(c=='!'&&pos==1)                    ans++;              cin>>str;              mem(f,0);              int len=str.length();              for(int j=0;j<len;j++)              {                  f[str[j]-'a']=1;              }              if(c== '!')              {                for(int j=0;j<26;j++)                    v[j]= (v[j]&f[j]);              }              else              {                  for(int j=0;j<26;j++)                    v[j]= (v[j] & (1- f[j]));              }              pos=0;              for(int j=0;j<26;j++)                if(v[j])                    pos++;          }    }    cout<<ans<<endl;    return 0;}


阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 jiebao比分 比分推荐 完整比分 及时比分007 win比分足球比分即时 zuqiu比分即时比分 球网即时比分 即时篮球比分 篮球实时比分 spbo即时比分 7m.7n即时比分 篮球即时比分 球坛网足球比分 即时蓝球比分 篮球即使比分 qiutan时比分 即时足球比分 win007篮球比分 足球比分188网 足球比分预测 体网足球比分 大羸足球比分 win007足球比分 实时足球比分 90vs篮球比分 球赛比分查询 det007足球比分 排球即时比分 竞猜足球比分 大家赢足球比分 7m足球即时比分 足球比分手机版 90足球比分手机版 90win足球比分 足球现场比分 90篮球即时比分 500万即时比分 即时比分篮球 即时比分皇冠 雪绿园即时比分 足球网即时比分