再来回顾一下2-SAT,把每个点拆点为是和非两个点,如果a能一定推出非b,则a->非b,其他情况同理. 然后跑强连通分量分解,保证a和非a不在同一个分量里面. 这题由于你建完图发现都是双向边,所以用并查集亦可. #include<cstdio> #include<vector> #include<cstring> using namespace std; vector<int>G[200010],rG[200010],vs; bool used[200…
前四题比较水,E我看出是欧拉函数傻逼题,但我傻逼不会,百度了下开始学,最后在加时的时候A掉了 AC:ABCDE Rank:182 Rating:2193+34->2227 终于橙了,不知道能待几天 A.A Serial Killer 题目大意:一开始给你两个字符串,每次给你当前两个串中的一个和一个新的串,用新的串换掉旧的,每次输出当前的串.(次数<=1000) 思路:二逼题 #include<iostream> using namespace std; int main() { s…
A. A Serial Killer time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his power…
Moriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are unlocked at the same time. There are m switches. E…
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim. The killer starts with two potentia…
题目链接:http://codeforces.com/contest/776/problem/D D. The Door Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Moriarty has trapped n people in n distinct rooms in a hotel. Some room…
处理出前缀和,枚举k的幂,然后从前往后枚举,把前面的前缀和都塞进map,可以方便的查询对于某个右端点,有多少个左端点满足该段区间的和为待查询的值. #include<cstdio> #include<map> using namespace std; typedef long long ll; map<ll,int>cnts; int n,m,e; ll a[100010],ans; ll b[1001]; int main() { // freopen("c…
Molly Hooper has n different kinds of chemicals arranged in a line. Each of the chemicals has an affection value, The i-th of them has affection value ai. Molly wants Sherlock to fall in love with her. She intends to do this by mixing a contiguous se…
Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry. He bought n pieces of jewelry. The i-th piece has price equal to i + 1, that is, the prices of the jewelry are 2, 3, 4, ... n + 1. Watson…
感觉自己做有关区间的题目方面的思维异常的差...有时简单题都搞半天还完全没思路,,然后别人提示下立马就明白了...=_= 题意:给一个含有n个元素的数组和k,问存在多少个区间的和值为k的次方数. 题解:先处理出前缀和sum[i].然后扫一遍这个前缀和数组:对于每个sum[i],从k的0次方开始枚举,检查map[ sum[i]-k^m ]是否大于0,,即之前是否出现过和值为sum[i]-k^m的前缀和:如果出现过和值为sum[i]-k^m的前缀和,则说明在前缀i和 前缀和值为sum[i]-k^m的…