Codeforces Round #459 (Div. 2)总结
2018-01-29 15:59
405 查看
争取一场上蓝(flag)!
flag炸了,不仅没上蓝,还掉分了。
Codeforces Round #459 (Div. 2)
A:傻逼模拟
AC代码:
B:傻逼模拟
AC代码:
C:看到觉得是DP,写了个记忆化,炸了。
后来发现看错题了,求的是区间。所以大框架肯定是O(n^2),然后用奇怪的技巧算能否匹配。看起来有点像区间DP,但我还是不会orz
D:CF居然有博弈。我看完了题,先想了想博弈搜索,发现不会先,又觉得是记忆化。结果样例过不了orz。这题感觉有点像“传纸条”。看了题解真的是记忆化!思路也是对的。我的码力真是太差了orz。考后终于调出来。
AC代码
flag炸了,不仅没上蓝,还掉分了。
Codeforces Round #459 (Div. 2)
A:傻逼模拟
AC代码:
#include <iostream> #include <cstdio> #include <map> const int MAXN = 100000 ; using namespace std ; inline int read ( ) { int x = 0 , w = 1 ; char c = ' ' ; while ( c < '0' || c > '9' ) { c = getchar ( ) ; if ( c == '-' ) w = -1 ; } while ( c >= '0' && c <= '9' ) x = ( x << 1 ) + ( x << 3 ) + ( c ^ 48 ) , c = getchar ( ) ; return x * w ; } map < int , bool > H ; int f[MAXN + 5] ; int main ( ) { int n = read ( ) ; f[1] = 1 , f[2] = 1 ; H[1] = true ; int i = 3 ; while ( f[i - 1 ] <= 1000 ) f[i] = f[i - 1] + f[i - 2] , H[f[i]] = true , ++i ; for ( int i = 1 ; i <= n ; ++i ) if ( H[i] ) cout << 'O' ; else cout << 'o' ; return 0 ; }
B:傻逼模拟
AC代码:
#include <iostream> #include <cstdio> #include <map> const int MAXN = 100000 ; using namespace std ; inline int read ( ) { int x = 0 , w = 1 ; char c = ' ' ; while ( c < '0' || c > '9' ) { c = getchar ( ) ; if ( c == '-' ) w = -1 ; } while ( c >= '0' && c <= '9' ) x = ( x << 1 ) + ( x << 3 ) + ( c ^ 48 ) , c = getchar ( ) ; return x * w ; } map < string , string > H ; int main ( ) { int n = read ( ) , m = read ( ) ; for ( int i = 1 ; i <= n ; ++i ) { string str , ip ; cin >> str >> ip ; ip += ";" ; H[ip] = str ; } for ( int i = 1 ; i <= m ; ++i ) { string str , ip ; cin >> str >> ip ; cout << str << ' ' << ip << " #" << H[ip] << endl ; } return 0 ; }
C:看到觉得是DP,写了个记忆化,炸了。
后来发现看错题了,求的是区间。所以大框架肯定是O(n^2),然后用奇怪的技巧算能否匹配。看起来有点像区间DP,但我还是不会orz
D:CF居然有博弈。我看完了题,先想了想博弈搜索,发现不会先,又觉得是记忆化。结果样例过不了orz。这题感觉有点像“传纸条”。看了题解真的是记忆化!思路也是对的。我的码力真是太差了orz。考后终于调出来。
AC代码
#include <iostream> #include <cstdio> #include <cstring> const int MAXN = 100 ; const int INF = 0x3f3f3f3f ; using namespace std ; inline int read ( ) { int x = 0 , w = 1 ; char c = ' ' ; while ( c < '0' || c > '9' ) { c = getchar ( ) ; if ( c == '-' ) w = -1 ; } while ( c >= '0' && c <= '9' ) x = ( x << 1 ) + ( x << 3 ) + ( c ^ 48 ) , c = getchar ( ) ; return x * w ; } struct Node { int to , w , nxt ; } edge[MAXN * MAXN + 5] ; bool flag ; class Graph { public : Graph ( ) { memset ( head , -1 , sizeof ( head ) ) , tot = 0 ; memset ( dp , -1 , sizeof ( dp ) ) ; } void add ( int u , int v , int w ) ; bool dfs ( int x , int y , int turn , int last ) ; private : int tot , head[MAXN + 5] , dp[MAXN + 5][MAXN + 5][3][27] ; } G ; void Graph :: add ( int u , int v , int w ) { edge[tot] = ( Node ) { v , w , head[u] } , head[u] = tot++ ; } bool Graph :: dfs ( int x , int y , int turn , int last ) { if ( dp[x][y][turn][last] != -1 ) return dp[x][y][turn][last] ; int flag = false ; if ( !turn ) for ( int i = head[x] ; ~i ; i = edge[i].nxt ) { int v = edge[i].to , w = edge[i].w ; if ( w >= last ) flag |= !dfs ( v , y , !turn , w ) ; } else for ( int i = head[y] ; ~i ; i = edge[i].nxt ) { int v = edge[i].to , w = edge[i].w ; if ( w >= last ) flag |= !dfs ( x , v , !turn , w ) ; } dp[x][y][turn][last] = flag ; return dp[x][y][turn][last] ; } int main ( ) { int n = read ( ) , e = read ( ) ; for ( int i = 1 ; i <= e ; ++i ) { int u = read ( ) , v = read ( ) ; char c ; cin >> c ; G.add ( u , v , c - 'a' ) ; } for ( int i = 1 ; i <= n ; ++i ) { for ( int j = 1 ; j <= n ; ++j ) { flag = G.dfs ( i , j , 0 , -1 ) ; if ( flag ) cout << 'A' ; else cout << 'B' ; } cout << endl ; } return 0 ; }
相关文章推荐
- Codeforces Round #172 (Div. 2)总结
- Codeforces Round #459 (Div. 2) C-The Monster (贪心)
- Codeforces round 440 div2 总结&&题解
- Codeforces Round #430 (Div. 2) 总结
- Codeforces Round #151 (Div. 2)总结
- Codeforces Round #261 (Div. 2)459D. Pashmak and Parmida's problem(求逆序数对)
- Codeforces Round #190 (Div. 2) 总结
- Codeforces Round #444 (Div. 2) 总结
- Codeforces Round #459 (Div. 2)
- Codeforces Round #109 (Div. 2) 总结
- Codeforces Round #154 (Div. 2) 总结
- Codeforces Round #102 (Div. 2)总结(如何处理A*B*C==n!!!)
- Codeforces Round #162 (Div. 2)总结
- Codeforces Round #432 (Div. 2) 总结
- Codeforces Round #459 (Div. 2)-D(dfs暴力)
- Codeforces Round #335 (Div. 2) 总结
- Codeforces Round #194 (Div. 2)总结
- Codeforces Round #459 (Div. 2) B. Radio Station STL map的使用
- Codeforces Round #436 (Div. 2) 做题总结
- Codeforces Round #256 (Div. 2)总结