Codeforces Round #459 (Div. 2) AB

A. Eleven

Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters.

Her friend suggested that her name should only consist of uppercase and lowercase letters ‘O‘. More precisely, they suggested that the i-th letter of her name should be ‘O‘ (uppercase) if i is a member of Fibonacci sequence, and ‘o‘ (lowercase) otherwise. The letters in the name are numbered from 1 to n. Fibonacci sequence is the sequence f where

  • f1 = 1,
  • f2 = 1,
  • fn = fn - 2 + fn - 1 (n > 2).

As her friends are too young to know what Fibonacci sequence is, they asked you to help Eleven determine her new name.

Input

The first and only line of input contains an integer n (1 ≤ n ≤ 1000).

Output

Print Eleven‘s new name on the first and only line of output.

Examples

input

8

output

OOOoOooO

input

15

output

OOOoOooOooooOoo

是斐波拉契数就是‘O’否则就是‘o’

 1 n = int(input())
 2
 3 vis = []
 4 a ,b = 1, 1
 5 for i in range(55):
 6     vis.append(b)
 7     a,b = b,a+b
 8 s = ""
 9 for i in range(n):
10     if vis.count(i+1):
11         s += ‘O‘
12     else :
13         s += ‘o‘
14 print(s)

B. Radio Station

As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin‘s task was to add comments to nginx configuration for school‘s website. The school has n servers. Each server has a name and an ip (names aren‘t necessarily unique, but ips are). Dustin knows the ip and name of each server. For simplicity, we‘ll assume that an nginx command is of form "command ip;" where command is a string consisting of English lowercase letter only, and ip is the ip of one of school servers.

Each ip is of form "a.b.c.d" where abc and d are non-negative integers less than or equal to 255 (with no leading zeros). The nginx configuration file Dustin has to add comments to has m commands. Nobody ever memorizes the ips of servers, so to understand the configuration better, Dustin has to comment the name of server that the ip belongs to at the end of each line (after each command). More formally, if a line is "command ip;" Dustin has to replace it with "command ip; #name" where name is the name of the server with ip equal to ip.

Dustin doesn‘t know anything about nginx, so he panicked again and his friends asked you to do his task for him.

Input

The first line of input contains two integers n and m (1 ≤ n, m ≤ 1000).

The next n lines contain the names and ips of the servers. Each line contains a string name, name of the server and a string ip, ip of the server, separated by space (1 ≤ |name| ≤ 10, name only consists of English lowercase letters). It is guaranteed that all ip are distinct.

The next m lines contain the commands in the configuration file. Each line is of form "command ip;" (1 ≤ |command| ≤ 10, commandonly consists of English lowercase letters). It is guaranteed that ip belongs to one of the n school servers.

Output

Print m lines, the commands in the configuration file after Dustin did his task.

Examples

input

2 2main 192.168.0.2replica 192.168.0.1block 192.168.0.1;proxy 192.168.0.2;

output

block 192.168.0.1; #replicaproxy 192.168.0.2; #main

input

3 5google 8.8.8.8codeforces 212.193.33.27server 138.197.64.57redirect 138.197.64.57;block 8.8.8.8;cf 212.193.33.27;unblock 8.8.8.8;check 138.197.64.57;

output

redirect 138.197.64.57; #serverblock 8.8.8.8; #googlecf 212.193.33.27; #codeforcesunblock 8.8.8.8; #googlecheck 138.197.64.57; #server

有n台服务器,m条命令,求每个命令的名字指向的服务器ip在n台服务器中原来的名字是什么。

n,m = map(int,input().split())
di = {}
for i in range(n+m):
    s,s1 = input().split()
    if s1[-1] == ‘;‘:
        s1 = s1[:-1]
    if s1 in di:
        print(s+‘ ‘+s1+‘; #‘+di[s1])
    else:
        di[s1] = s;

原文地址:https://www.cnblogs.com/xingkongyihao/p/8387687.html

时间: 2024-07-31 19:31:11

Codeforces Round #459 (Div. 2) AB的相关文章

Codeforces Round #459 (Div. 2) C 思维,贪心 D 记忆化dp

Codeforces Round #459 (Div. 2) C. The Monster 题意:定义正确的括号串,是能够全部匹配的左右括号串. 给出一个字符串,有 (.). ? 三种字符, ? 可以当作 ( 可 ) . 问这个字符串有多少个子串是正确的括号串. tags:好考思维,想不到.. 预处理出每个字符向左向右最多可以匹配到哪里,再 O(n*n) 枚举所有区间,看是否符合条件. // C #include<bits/stdc++.h> using namespace std; #pra

Codeforces Round #459 (Div. 2)题解

补题 codeforces 918C 题意 给定一个含有通配符?和()的字符串,问有多少子串是括号匹配的 解题思路 首先考虑不用栈求括号匹配的方法: bool solve(char* s) { int top=0; for (int i=0;i<strlen(s);i++) { if(s[i]=='(') top++; else top--; if(top<0) return false; } return top==0; } 由于在使用栈的括号匹配算法中,栈内是不存在)的,所以不难证明这个算

【Codeforces Round #459 (Div. 2) B】 Radio Station

[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map模拟一下映射就好了. [代码] #include <bits/stdc++.h> using namespace std; int n,m; map<string,string> dic; int main(){ #ifdef LOCAL_DEFINE freopen("rush_in.txt", "r", stdin); #endif ios::sync_with_

【Codeforces Round #459 (Div. 2) C】The Monster

[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 左括号看成1 右括号看成-1 设置l,r表示前i个数的和的上下界 遇到 左括号 l和r同时加1 遇到右括号 同时减1 遇到问号 因为问号可以为1或-1所以l减1而r加1 如果在某个时刻r小于0了 就说明再也不能继续了 因为说明左括号和问号比右括号来得少了 如果l<0则把l置为0,因为不允许和出现<0的情况 否则如果l等于0就说明有一种方法能让前i个数的和为0 当然当前枚举的序列长度要为偶数 [代码] #include <

Codeforces Round #459 (Div. 2)The Monster[匹配问题]

题意 给一个序列,包含(,),?,?可以被当做(或者),问你这个序列有多少合法的子序列. 分析 n^2枚举每一个子序列,暂时将每个?都当做右括号,在枚举右端点的时候同时记录两个信息:当前左括号多余多少个(top),已经将多少个?变成了右括号(cnt). 如果当前是(,top++. 如果当前是),top--. 如果当前是?,top--,cnt++; 如果top<0,我们需要判断一下当前还有没有之前被当做右括号的?,如果有的话,我们将其变为左括号,如果没有的话,意味着可以跳出循环了,之后都不会再合法

Codeforces Round #315 (Div. 1)

A. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and un

Codeforces Round #261 (Div. 2) 459B. Pashmak and Flowers(数学题,组合)

题目链接:http://codeforces.com/problemset/problem/459/B B. Pashmak and Flowers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak decided to give Parmida a pair of flowers from the garden.

Codeforces Round #261 (Div. 2)459A. Pashmak and Garden(数学题)

题目链接:http://codeforces.com/problemset/problem/459/A A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak has fallen in love with an attractive girl called Parmida s

CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))

题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发  问s1 出发的能不能先打到f 思路:最短路. 首先检测能不能赢 在更新的时候  如果对于一条边 a->b  如果dis1[a] <dis2[a]  那么选择这条边就选择   l  因为这条边对于s1有利 如果两个起点都选择了这条边  则说明s1 赢定了,所以要让他们尽量走这条,所以边权越小越好.跑完之后检测 如果  dis1[f]<dis2[f] 那么 就赢了. 接下来判断能不能平局