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. layui 下拉框取值

    layui.use('form', function () { var form = layui.form; form.on('select(Status)', function (data) { c ...

  2. js获取当前具体时间

    /** * 获取当前时间 * @param isTime true:显示日期和时间,如:2018-09-20 13:25:12:false:显示日期,如:2018-09-20. * @returns ...

  3. 启动模拟器的qq

    #coding = utf-8from appium import webdriver '''1.手机类型2.版本3.手机的唯一标识 deviceName4.app 包名appPackage5.app ...

  4. swift-UITableView的基本使用

    废话不多说了,直接贴我今天写的代码吧:如果新手有什么不懂的,可以发我邮箱. // //  singleInfo.swift            个人信息 //  Housekeeper // //  ...

  5. HashMap源码分析笔记(一)

    一.结构 HashMap的结构由数组和链表组成,可以说是一个链表类型的数组: 快速定位方式:key值得hash变换作为数组索引快速找到对应数组块,之后通过hash值对比从链表中查找到匹配项. hash ...

  6. CentOS安装新版RabbitMQ解决Erlang 19.3版本依赖

    通过yum等软件仓库都可以直接安装RabbitMQ,但版本一般都较为保守. RabbitMQ官网提供了新版的rpm包(http://www.rabbitmq.com/download.html),但是 ...

  7. 获取元素属性中的[x] 标签: javascript 2016-12-24 22:35 105人阅读 评论(0)

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  8. 使用Vue CLI 3将基于element-ui二次封装的组件发布到npm

    前言:之前在网上找的好多都是基于vue-cli 2.x的,而使用vue-cli 3的文章比较少,Vue CLI 3 中文文档,所以我在自己尝试的时候把几篇文章结合了一下,调出来了我想要的模式,也就是V ...

  9. Java 中 synchronized的用法详解

    Java语言的关键字,当它用来修饰一个方法或者一个代码块的时候,能够保证在同一时刻最多只有一个线程执行该段代码. 1.方法声明时使用,放在范围操作符(public等)之后,返回类型声明(void等)之 ...

  10. SSH框架下单元测试的实现

    SSH框架下单元测试的实现 实现的功能 实现了部门的增删改查 对Action进行了单元测试 对Service 进行了单元测试,通过mock的方式实现. 实现的步骤 一.对Action层的单元测试实现 ...