A - New Year and Counting Cards

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} int a[]; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
string s;
cin >> s;
int n = s.size();
for (int i = ; i < n; i++) a[s[i]]++;
cout << (a[''] + a[''] + a[''] + a[''] + a[''] + a['a'] + a['e'] + a['i'] + a['o'] + a['u']) << endl;
return ;
}

B - New Year and Buggy Bot

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} string mp[], s;
int d[], op[];
const int dx[] = {-, , , };
const int dy[] = {, , , -}; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
int n, m;
cin >> n >> m;
for (int i = ; i < n; i++) cin >> mp[i];
cin >> s;
int l = s.size();
for (int i = ; i < l; i++) op[i] = s[i] - '';
int sx, sy;
for (int i = ; i < n; i++) {
for (int j = ; j < m; j++) {
if (mp[i][j] == 'S') {
sx = i;
sy = j;
}
}
}
int ans = ;
bool f[];
for (d[] = ; d[] < ; d[]++) {
for (d[] = ; d[] < ; d[]++) {
for (d[] = ; d[] < ; d[]++) {
for (d[] = ; d[] < ; d[]++) {
memset(f, false, sizeof(f));
f[d[]] = true, f[d[]] = true, f[d[]] = true, f[d[]] = true;
if (f[] && f[] && f[] && f[]) {
int x = sx, y = sy, j;
bool ok = false;
for (int i = ; i < l; i++) {
j = d[op[i]];
x += dx[j], y += dy[j];
if (x < || x >= n || y < || y >= m) break;
if (mp[x][y] == '#') break;
if (mp[x][y] == 'E') {
ok = true;
break;
}
}
if (ok) ans++;
}
}
}
}
}
cout << ans << endl;
return ;
}

C - New Year and Curling

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} class SAM {
private:
int Last, sz;
vector<int []> ch;
vector<int> fa, maxlen;
public:
void init() {
sz = ;
ch.clear();
}
void add(int x) {
int np = ++sz, p = Last;
Last = np;
memset(ch[np], , sizeof(ch[np]));
maxlen[np] = maxlen[p] + ;
while (p && !ch[p][x]) ch[p][x] = np, p = fa[p];
if (!p) fa[np] = ;
else {
int q = ch[p][x];
if (maxlen[p] + == maxlen[q]) fa[np] = q;
else {
int nq = ++sz;
memcpy(ch[nq], ch[q], sizeof(ch[q]));
maxlen[nq] = maxlen[p] + ;
fa[nq] = fa[q];
fa[q] = fa[np] = nq;
while (p && ch[p][x] == q) ch[p][x] = nq, p = fa[p];
}
}
}
};
double x[], y[];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
//std::ios::sync_with_stdio(0), cin.tie(0);
int n;
double r, h;
//cin >> n >> r;
scanf("%d%lf", &n, &r);
for (int i = ; i < n; i++) {
//cin >> x[i];
scanf("%lf", &x[i]);
y[i] = r;
for (int j = ; j < i; j++) {
if (fabs(x[i] - x[j]) <= * r) {
h = sqrt( * r * r - (x[i] - x[j]) * (x[i] - x[j])) + y[j];
if (y[i] < h) y[i] = h;
}
}
}
for (int i = ; i < n; i++) printf("%.8lf ", y[i]); //cout << y[i] << ' ';
return ;
}

D - New Year and Arbitrary Arrangement

#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std; const int MOD = * * + ; ll pw(ll a, ll b = MOD - ) {
if (b == ) {
return ;
} ll v = pw(a, b / );
v = (v * v) % MOD; if (b & ) {
v = (v * a) % MOD;
} return v;
} constexpr int MAXN = ; ll f[MAXN][MAXN]; int main() {
#ifdef PAUNSVOKNO
freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(); cout.tie(nullptr); cin.tie(nullptr);
ll k, pa, pb;
cin >> k >> pa >> pb;
ll s = pw(pa + pb);
pa = (pa * s) % MOD;
pb = (pb * s) % MOD; ll ans = ; f[][] = ; ll last = ( - pa + MOD) % MOD;
last = pw(last, MOD - );
last = (last - + MOD) % MOD; for (int i = ; i <= k; ++i) {
for (int j = ; j <= k; ++j) {
if (i + j >= k) {
ll val = j + i + last;
ans = (ans + f[i][j] * val) % MOD;
} else {
f[i + ][j] = (f[i + ][j] + f[i][j] * pa) % MOD;
f[i][j + i] = (f[i][j + i] + f[i][j] * pb) % MOD;
}
}
} cout << ans << "\n";
}

E - New Year and Entity Enumeration

#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std; ll m,n,c[][],f[],b[],x,ans=;
map<ll,ll>mp; int main(){
for (cin>>m>>n;n--;)
for (int i=;i<m;++i)
scanf("%1lld",&x), b[i]|=x<<n;
for (int i=;i<m;++i) ++mp[b[i]];
for (int i=;i<=m;++i)
for (int j=;j<=i;++j)
c[i][j]= j? (c[i-][j-]+c[i-][j])%mod: ;
f[]=f[]=;
for (int i=;i<=m;++i)
for (int j=;j<i;++j)
f[i]=(f[i]+c[i-][j]*f[j])%mod;
for (auto o:mp) ans=(ans*f[o.second])%mod;
cout<<ans;
}

F - New Year and Rainbow Roads

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
int n;
char ch;
lint pb = , pr = , pg = , mr = , mb = , ans = , x;
cin >> n;
for (int i = ; i < n; i++) {
cin >> x >> ch;
if (ch == 'R' || ch == 'G') {
if (pr) {
ans += x - pr;
mr = max(mr, x - pr);
}
pr = x;
}
if (ch == 'B' || ch == 'G') {
if (pb) {
ans += x - pb;
mb = max(mb, x - pb);
}
pb = x;
}
if (ch == 'G') {
if (pg) ans += min(0LL, x - pg - mr - mb);
pg = x;
mr = mb = ;
}
}
cout << ans << endl;
return ;
}

G - New Year and Original Order

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} const int mod = ;
lint dp[][][][];
string s; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
cin >> s;
int n = s.size();
reverse(s.begin(), s.end());
memset(dp, , sizeof(dp));
for (int i = ; i < ; i++) dp[][][i][] = ;
for (int i = ; i < n; i++) {
for (int j = ; j <= i; j++) {
for (int k = ; k < ; k++) {
for (int l = ; l < ; l++) {
for (int p = ; p < ; p++) {
(dp[i + ][j + (p >= k)][k][(s[i] - '' > p) || (l && (s[i] - '' == p))] += dp[i][j][k][l]) %= mod;
}
}
}
}
}
lint ans = ;
for (int i = ; i < ; i++) {
lint t = ;
for (int j = ; j <= n; j++, t = (t * + ) % mod) ans += dp[n][j][i][] * t, ans %= mod;
}
cout << ans << endl;
return ;
}

H - New Year and Boolean Bridges

#include<bits/stdc++.h>
#define N 50
#define fr(i,n) for(int i=1;i<=n;i++)
using namespace std;
int n,i,j,x,S,an,nv,id,to[N],c[N],b[N],F[N],sz[N];bool v[N][N];
char s[N][N];
int gf(int x){return F[x]==x?x:F[x]=gf(F[x]);}
void uni(int x,int y){
x=gf(x);y=gf(y);
if(x!=y)F[x]=y,sz[y]+=sz[x];
}
int main(){
scanf("%d",&n);
fr(i,n)F[i]=i,sz[i]=;
fr(i,n){
scanf("%s",s[i]+);
fr(j,n)if(i!=j)
if(s[i][j]=='A')uni(i,j);
}
fr(i,n)if(gf(i)==i&&sz[i]>)to[i]=++id;
fr(i,n)fr(j,n)if(gf(i)==gf(j)&&s[i][j]=='X')return puts("-1"),;
fr(i,n)fr(j,n)if(s[i][j]=='X')v[to[gf(i)]][to[gf(j)]]=;
fr(i,id)b[i]=i;an=n;
fr(T,){
random_shuffle(b+,b+id+);nv=;
fr(i,id){
x=b[i];S=;
fr(j,id)if(v[x][j])S|=<<c[j];
for(j=;;j++)if(!(S>>j&)){
c[x]=j;
break;
}
nv=max(nv,c[x]);
}
fr(i,id)c[i]=;
an=min(an,nv);
}
printf("%d\n",n-+an);
}

[Codeforces]Good Bye 2017的更多相关文章

  1. Codeforces Good Bye 2017 908F F. New Year and Rainbow Roads

    题 OvO http://codeforces.com/contest/908/problem/F CF 908F 解 需要注意细节的模拟题. 如果三种颜色都存在,则记每两个相邻的G组成一个段,对每个 ...

  2. codeforces Good bye 2016 E 线段树维护dp区间合并

    codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问 ...

  3. Good Bye 2017 A B C

    Good Bye 2017 A New Year and Counting Cards 题目链接: http://codeforces.com/contest/908/problem/A 思路: 如果 ...

  4. Good Bye 2017(送命场)

    9815人数场,9500+围观神仙打架...断断续续打Codeforces也快有一年啦,第一次打Good Bye场,满怀前排膜tourist的心愿参加了这场送命场,虽然没看到tourist.不过还是得 ...

  5. Codeforces:Good Bye 2018(题解)

    Good Bye 2018! 题目链接:https://codeforces.com/contest/1091 A. New Year and the Christmas Ornament 题意: 给 ...

  6. codeforces Good Bye 2015 B. New Year and Old Property

    题目链接:http://codeforces.com/problemset/problem/611/B 题目意思:就是在 [a, b] 这个范围内(1 ≤ a ≤ b ≤ 10^18)统计出符合二进制 ...

  7. Codeforces Good Bye 2015 D. New Year and Ancient Prophecy 后缀数组 树状数组 dp

    D. New Year and Ancient Prophecy 题目连接: http://www.codeforces.com/contest/611/problem/C Description L ...

  8. Codeforces Good Bye 2015 C. New Year and Domino 前缀和

    C. New Year and Domino 题目连接: http://www.codeforces.com/contest/611/problem/C Description They say &q ...

  9. Codeforces Good bye 2015 B. New Year and Old Property dfs 数位DP

    B. New Year and Old Property 题目连接: http://www.codeforces.com/contest/611/problem/B Description The y ...

随机推荐

  1. javaee字符文件的复制

    package Zy; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWrit ...

  2. UI Testing

    UI Test能帮助我们去验证一些UI元素的属性和状态.Apple 在 Xcode 7 中新加入了一套 UI Testing 的工具,其目的就是解决自动化UI测试这个问题.新的 UI Testing ...

  3. python 疑难杂症

    1.getpass模块    :Pycharm不支持getpass模块,使用terminal可运行,但是getpass中文提示显示乱码?

  4. 单行函数、表连接(day02)

    回顾: 1.数据库介绍 sql: dql: select dml: insert delete update ddl: create drop alter tcl: commit rollback s ...

  5. HDU2866 Special Prime

    题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=2866 题意:在区间[2,L]内,有多少个素数p,满足方程有解. 分析: 原方程变为: n^(b-1) ...

  6. java实现根据高德地图API接口进行地址位置解析,将地址转化为经纬度

    原创文章,转载请注明,欢迎评论和更改. 1,所需额外ar包,import net.sf.json.JSONObject; 2,完整源代码代码 package com.travel.util; impo ...

  7. JS移动客户端--触屏滑动事件及js手机拖拽效果

    移动端触屏滑动的效果其实就是图片轮播,在PC的页面上很好实现,绑定click和mouseover等事件来完成.但是在移动设备上,要实现这种轮播的效果,就需要用到核心的touch事件.处理touch事件 ...

  8. PHP统计当前在线用户数实例

    HTML 我们在页面上放置一个显示当前在线人数的div#total以及一个用于展示访客地区分布的列表#onlinelist,默认我们在列表中放置一张与加载动画图片,后面我们用jQuery控制当鼠标滑向 ...

  9. 5、SpringBoot+MyBaits+Maven+Idea+pagehelper分页插件

    1.为了我们平时方便开发,我们可以在同一个idea窗口创建多个项目模块,创建方式如下 2.项目中pom.xm文件的内容如下 <?xml version="1.0" encod ...

  10. 邓_ Phpcms·二次开发

    PHPCMS V9产品介绍 PHPCMS V9(简称V9)采用PHP5+MYSQL做为技术基础进行开发.V9采用OOP(面向对象)方式进行基础运行框架搭建.模块化开发方式做为功能开发形式.框架易于功能 ...