Codeforces 918C/917A - The Monster】的更多相关文章

传送门:http://codeforces.com/contest/918/problem/C 一个括弧串由字符‘(’和‘)’组成.一个正确的串可被递归地定义,定义如下: ①空串e是一个正确的串: ②若串s是一个正确的串,则串(s)也是一个正确的串: ③若串s.t均是正确的串,则串st也是一个正确的串. 对于一个由字符‘(’.‘)’和‘?’组成的串s,考虑其子串s.substr(i,j):将这个子串的符号‘?’置换为‘(’或‘)’,若置换后的串是一个正确的串,则原来的子串是一个完美的串.试统计串…
918C - The Monster 思路1: 右键在新窗口打开图片 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset(a,b,sizeof(a)) int main(){ ios::sync_with_stdio(false); cin.tie(); string s; cin>>s; ; ;i<…
题目链接:http://codeforces.com/contest/918/problem/C 题目大意:给你一串字符串,其中有'('.')'.'?'三种字符'?'可以当成'('或者')'来用,问该字符串中有多少子串符合括号匹配的规则. 解题思路:根据括号匹配原始版进行改进,设置high和low分别表示未匹配左括号数的上限和下限,当遇到'('时low++,high++,遇到')'时low--,high--,遇到'?'时由于既可以表示'('又可以表示')',所以high++,low--. 原始版…
As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside D…
[题目链接]:http://codeforces.com/contest/787/problem/A [题意] 把b一直加a->得到x 把d一直加c->得到y 然后问你x和y可不可能有相同的值. 有的话,输出那个最小的; [题解] 等价于 令t=(b+u*a-d)%c==0 u为整数 这里如果b< d就swap(a,c),swap(b,d)就好; 然后如果t遇到了重复的值,就结束,往后都不可能了; 如果t中途变成0了,就输出那个u; [完整代码] #include <bits/st…
Fight the Monster time limit per test             1 second                                   memory limit per test       256 megabytes                                   input                               standard input                               …
题意:打怪兽.可增加自己的属性,怎样在能打倒怪兽的情况下花费最少? 这题关键要找好二分的量.一开始我觉得,只要攻击到101,防御到100,就能必胜,于是我对自己的三个属性的和二分(0到201),内部三层循环(最多到不了200*200*200).1秒内能过.不过发现如果生命值很便宜,防御很贵的话,买生命值合算.10100点生命值就能必赢,于是上界调为10100,超时. 后来就想,二分攻击(记为i)和防御(记为j)的和mid,内部二重循环列出i+j=mid的所有情况.再单独二分生命值k,如果ijk的…
[链接]:CF Examples inputCopy ((?)) outputCopy 4 inputCopy ??()?? outputCopy 7 说明 For the first sample testcase, the pretty substrings of s s are: "(?" which can be transformed to "()". "?)" which can be transformed to "()&…
链接 大意:给定字符串, 只含'(',')','?', 其中'?'可以替换为'('或')', 求有多少个子串可以的括号可以匹配 (不同子串之间独立) 记$s_($为'('个数, $s_)$为')'个数. 一个括号串匹配等价于长度为偶数, 且任意一个前缀中$s_( \ge s_)$,任意一个后缀中$s_) \ge s_($. 对前缀后缀分别暴力判断即可 #include <iostream> #include <algorithm> #include <cstdio> #…
A. Fight the Monster Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/problem/A Description A monster is attacking the Cyberland! Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attr…