rated

Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game (博弈, sg函数,规律)

匿名 (未验证) 提交于 2019-12-02 23:48:02
D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Who wins if both participants play optimally? Alice and Bob would like to play several games, so you should determine the winner in each game. Input Output For each game, print Alice if Alice wins this game and Bob otherwise. Example inputCopy 4 0 3 3 3 3 4 4 4 outputCopy Bob Alice Bob Alice 题意: 当前在n位置,每一次可以向左走1,2,或者k步,最左的位置是0,不能走到0之后, 二人博弈问题,谁没发走谁输,问先手必赢还是后手必赢。 思路: 首先确定的是 0位置是必数位置,因为 1 2 和k这三个位置可以一步就走到0位置,所以这3个位置是必赢位置,以此规律,我们可以递推出sg函数。 #include <iostream> #include <cstdio>

Educational Codeforces Round 67 (Rated for Div. 2) C

匿名 (未验证) 提交于 2019-12-02 23:45:01
题目大意: 有一个序列但不知道具体的数值,给出一些提示 \(t_i,l_i,r_i\) , \(t_i=0\) 表示区间 \(l_i\) 到 \(r_i\) 有序, \(t_i=1\) 则为无序 思路: 先构造一个全为1的序列,这样可以满足所有 \(t_i=1\) 的情况,然后对每个 \(t_i=0\) 先判断区间是否存在 \(t_i=0\) 的区间包含,如果包含则无法满足.否则用一个标记数组表示该位置元素应该跟后一个元素保持有序,无约束和已经无序.对每个 \(t_i=0\) 在其区间内找到一个无约束的元素将其改变成无序即可(若区间内已经有无序的元素则不需要改变) #include<cstdio> #include<cstring> #include<queue> #include<vector> #include<iostream> #include<algorithm> #include<map> #define ll long long #define FOR(i,n) for(int i =1; i <= n;++i ) #define FOR0(i,n) for(int i =0; i < n;++i ) #define inf 0x3f3f3f3f using namespace std; const int maxn = 1010; int n,m; struct

Educational Codeforces Round 51 (Rated for Div. 2)

匿名 (未验证) 提交于 2019-12-02 22:56:40
做了四个题。。 A. Vasya And Password 直接特判即可,,为啥泥萌都说难写,,,, 这个子串实际上是忽悠人的,因为每次改一个字符就可以 /* */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <map> #include <vector> #include <set> #include <queue> #include <cmath> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/hash_policy.hpp> #define Pair pair < int , int > #define MP ( x , y ) make_pair ( x , y ) #define fi first #define se second #define int long long #define LL long long #define ull unsigned long long #define rg register #define pt ( x ) printf ( "%d " , x ); //#define getchar() (p1 == p2 && (p2

Educational Codeforces Round 74 (Rated for Div. 2)

馋奶兔 提交于 2019-12-02 20:22:48
Educational Codeforces Round 74 (Rated for Div. 2) A. Prime Subtraction 思路:任何大于等于二的数都可以由二和三构成 AC代码 #include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> typedef long long ll; typedef unsigned long long ull; using namespace std; ll mult_mod(ll x, ll y, ll mod){ return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod; } ll pow_mod(ll a, ll b, ll p){ ll res = 1; while (b){ if (b & 1) res = mult_mod(res, a, p); a = mult

Educational Codeforces Round 75 (Rated for Div. 2)

被刻印的时光 ゝ 提交于 2019-12-02 13:27:45
题目链接: https://codeforces.com/contest/1251 A. Broken Keyboard 题意:俩种按键,好的按键按一次出现一个字符C,坏的按一次连续出现俩个相同的字符C,问好的按键有哪些。 思路:出现过连续出现次数为奇数的字符可以认定为好的。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 std::ios::sync_with_stdio(false); 6 int t; 7 cin >> t; 8 while(t--) 9 { 10 char s[1000]; 11 cin >> s; 12 int vis[50] = {0}; 13 int cnt = 1; 14 int n = strlen(s); 15 if(n == 1){ 16 cout << s[0] << endl; 17 continue; 18 } 19 20 for(int i = 1;i <= n;i++){ 21 if(s[i] == s[i - 1]) cnt++; 22 else{ 23 int t = s[i - 1] - 'a'; 24 if(cnt % 2) vis[t] = 1; 25 cnt = 1; 26 } 27 } 28 for(int i = 0;i <= 26

Educational Codeforces Round 75 (Rated for Div. 2)

风格不统一 提交于 2019-12-02 11:21:26
(体验到了胡出一道题但是写锅的绝望呢) A: 送分题。 #include<bits/stdc++.h> #define maxn 100005 #define maxm 500005 #define inf 0x7fffffff #define ll long long using namespace std; bool may[30]; char str[maxn]; inline int read(){ int x=0,f=1; char c=getchar(); for(;!isdigit(c);c=getchar()) if(c=='-') f=-1; for(;isdigit(c);c=getchar()) x=x*10+c-'0'; return x*f; } int main(){ int T=read(); while(T--){ scanf("%s",str+1); int n=strlen(str+1); memset(may,0,sizeof(may)); for(int i=1;i<=n;){ int j=i; while(str[j]==str[j+1]) j++; if((j-i+1)%2) may[str[i]-'a']=1; i=j+1; } for(int i=0;i<26;i++) if(may[i]) printf("%c",(char)(i+

Educational Codeforces Round 62 (Rated for Div. 2)

限于喜欢 提交于 2019-12-02 10:57:42
文章目录 A. Detective Book(思维) B. Good String(思维) C. Playlist() D. Minimum Triangulation() A. Detective Book(思维) 原题链接: http://codeforces.com/contest/1140/problem/A 题意: lvan看一本页数为 n 页的书,每页书可能有秘密,其答案在相对应的页数 a[i],如果当前的所有谜团没有解决的话,lvan就会一直看下去,求出他要多少天看完。 思路: 找出当前所看到谜团的答案的最大页数,如果最大页数正好等于当前看到的页数,那就天数就加1。更精辟的说法就是求从后往前找前缀最大的数和该位置下标相同的有几个。 Code(C++): # include <iostream> using namespace std ; int a [ 10100 ] ; int main ( ) { int n ; cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) cin >> a [ i ] ; int ans = 0 , maxn = - 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( a [ i ] > maxn ) maxn = a [ i ] ; if ( maxn == i

Educational Codeforces Round 75 (Rated for Div. 2) C. Minimize The Integer [思维]

谁说胖子不能爱 提交于 2019-12-02 09:09:53
C. Minimize The Integer https://codeforces.com/contest/1251/problem/C 这题过的太慢了 自己好菜啊 给了你一个排序规则 只能相邻的换 而且 换还需要保证他们的奇偶行不同 这样 哪怕看样例联系到奇偶性 就很快可以看出 同奇偶的数据他们的顺序是不可能边了 但是不同奇偶的 可以随便换 这题就水了 自己想了好久 怎么取找最前面可以换的不同奇偶数 写了好久 慢慢才发现 不需要 # include <bits/stdc++.h> using namespace std ; const int maxn = 106 + 10 ; int cas , n ; string str ; queue < char > o , e ; int main ( ) { cin >> cas ; while ( cas -- ) { cin >> str ; for ( int i = 0 ; i < str . size ( ) ; i ++ ) { if ( ( str [ i ] - '0' ) % 2 == 1 ) o . push ( str [ i ] ) ; else e . push ( str [ i ] ) ; } while ( ! o . empty ( ) || ! e . empty ( ) ) { if ( o

Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code dp(线段树转移) or 最短路计数

自闭症网瘾萝莉.ら 提交于 2019-12-01 17:08:05
题目链接 题意: 有n个俄罗斯套娃 每个套娃有内积in 外积out 空间浪费指的是 多个(或者一个)套娃组合在一起 最大的套娃内部的空气的体积 问有多少种套娃的组合方式(不能再被其他套娃套住 显然套住别人不会是最小答案 ) 使得空间浪费最小 题解: 线段树优化dp 设置dp[i].minn表示第i个套娃作为 最内部套娃 的所有套娃组合 的最小空间浪费 所以显然该状态从 $inj>outi$ 中转移过来 先将n个套娃按照内积排序一遍 方便找到嵌套对象也就是j 首先显然要倒着dp 二分查找最小的j满足 $inj>out$ 所以 j-n 的套娃均满足转移条件 直接搜索最小值 然后在第i个位置插入 $dp[j].minn-(out[i]-in[i]) ,dp[j].num $ 即可 该树状数组用结构体方便很多 而且可以优化push_up 为merge (经过队友提醒 tql !!! ) #include<bits/stdc++.h> using namespace std; const int N=2e5+10; int a[N],num,minn; #define ll long long ll ans; const ll mod=1e9+7; struct node{ll minn,num;}t[N<<2]; node merge(node a,node b) { if(a.minn=

Educational Codeforces Round 74 (Rated for Div. 2) D. AB-string

非 Y 不嫁゛ 提交于 2019-12-01 12:35:57
链接: https://codeforces.com/contest/1238/problem/D 题意: The string t1t2…tk is good if each letter of this string belongs to at least one palindrome of length greater than 1. A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not. Here are some examples of good strings: t = AABBB (letters t1, t2 belong to palindrome t1…t2 and letters t3, t4, t5 belong to palindrome t3…t5); t = ABAA (letters t1, t2, t3 belong to palindrome t1…t3 and letter t4 belongs to palindrome t3…t4); t = AAAAA