A Very Very Primitive Game


int main()
{
int a, b, c;
cin >> a >> b >> c;
if(c == 0)
{
if(a <= b) puts("Aoki");
else puts("Takahashi");
}
if(c == 1)
{
if(b <= a) puts("Takahashi");
else puts("Aoki");
}
return 0;
}

B Magic 3


int main()
{
int n, s, d;
scanf("%d%d%d", &n, &s, &d);
int flag = 0;
for(int i = 1; i <= n; ++ i)
{
int x, y;
scanf("%d%d", &x, &y);
if(x < s && y > d) flag = 1;
}
puts(flag ? "Yes" : "No");
return 0;
}

C Bowls and Dishes


int n, m, k;
int a[N], b[N];
int c[N], d[N];
int st[N];
int ans; void check()
{
int res = 0;
for(int i = 1; i <= m; ++ i)
if(st[a[i]] && st[b[i]]) res ++;
ans = max(ans, res);
} void dfs(int t)
{
if(t == k + 1) check();
else
{
st[d[t]] ++;
dfs(t + 1);
st[d[t]] --;
st[c[t]] ++;
dfs(t + 1);
st[c[t]] --;
}
} int main()
{
scanf("%d%d", &n, &m);
for(int i = 1; i <= m; ++ i) scanf("%d%d", &a[i], &b[i]);
scanf("%d", &k);
for(int i = 1; i <= k; ++ i) scanf("%d%d", &c[i], &d[i]);
dfs(1);
printf("%d\n", ans);
return 0;
}

D Staircase Sequences


LL n; int main()
{
IOS;
cin >> n;
LL res = 0;
n *= 2;
for(LL i = 1; i <= n / i; ++ i)
{
if(n % i == 0)
{
LL a = i, b = n / i;
if(a % 2 != b % 2) res ++;
}
}
cout << res * 2 << endl;
return 0;
}

E Magical Ornament


const int N = 2e5 + 10;
const int M = 17; int n, m, k;
struct Edge
{
int to, nxt;
}line[N];
int fist[N], idx;
int c[N], d[N];
int f[1 << M][M];
int w[M][M]; void add(int x, int y)
{
line[idx] = {y, fist[x]};
fist[x] = idx ++;
} void bfs(int x)
{
queue > q;
q.push({x, 0});
while(!q.empty())
{
auto u = q.front(); q.pop();
for(int i = fist[u.first]; i != -1; i = line[i].nxt)
{
int v = line[i].to;
if(d[v] == -1)
{
d[v] = u.second + 1;
q.push({v, d[v]});
}
}
}
} int main()
{
memset(fist, -1, sizeof fist);
scanf("%d%d", &n, &m);
for(int i = 1; i <= m; ++ i)
{
int a, b;
scanf("%d%d", &a, &b);
add(a, b), add(b, a);
}
scanf("%d", &k);
for(int i = 0; i < k; ++ i) scanf("%d", &c[i]);
for(int i = 0; i < k; ++ i)
{
for(int j = 1; j <= n; ++ j) d[j] = -1;
d[c[i]] = 0;
bfs(c[i]);
for(int j = 0; j < k; ++ j)
w[i][j] = (d[c[j]] == -1) ? INF : d[c[j]];
}
// for(int i = 0; i < k; ++ i)
// {
// for(int j = 0; j < k; ++ j)
// printf("%d ", w[i][j]);
// puts("");
// }
memset(f, 0x3f, sizeof f);
for(int i = 0; i < k; ++ i) f[1 << i][i] = 1; for(int i = 1; i < (1 << k); ++ i)
for(int j = 0; j < k; ++ j) if(i >> j & 1)
for(int t = 0; t < k; ++ t) if((i ^ 1 << j) >> t & 1)
f[i][j] = min(f[i][j], f[i ^ 1 << j][t] + w[t][j]);
int res = INF;
for(int i = 0; i < k; ++ i) res = min(res, f[(1 << k) - 1][i]);
if(res >= INF) puts("-1");
else printf("%d\n", res);
return 0;
}

F Shift and Inversions


int n;
int tr[N];
int a[N]; int lowbit(int x) { return x & -x; }
void add(int x, int v) { for(int i = x; i <= n; i += lowbit(i)) tr[i] += v; }
int sum(int x) { int res = 0; for(int i = x; i; i -= lowbit(i)) res += tr[i]; return res; } int main()
{
scanf("%d", &n);
for(int i = 1; i <= n; ++ i) { scanf("%d", &a[i]); a[i] ++; }
LL res = 0;
for(int i = 1; i <= n; ++ i)
{
res += sum(n) - sum(a[i]);;
add(a[i], 1);
}
printf("%lld\n", res);
for(int i = 1; i < n; ++ i)
{
res -= sum(a[i] - 1);
res += sum(n) - sum(a[i]);
printf("%lld\n", res);
}
return 0;
}

2021.2.2

AtCoder Beginner Contest 190的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  7. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  8. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

随机推荐

  1. SSM框架整合(Spring + SpringMVC + MyBatis)

    搭建环境 使用Spring(业务层)整合其他的框架SpringMVC(表现层)和MyBatis(持久层) Spring框架 创建数据库表 CREATE DATABASE ssm; USE ssm; C ...

  2. Kubernets二进制安装(17)之安装部署Dashboard

    1.下载dashboard镜像 在运维主机(mfyxw50.mfyxw.com)上执行命令 [root@mfyxw50 ~]# docker pull registry.cn-hangzhou.ali ...

  3. Django分页APP_django-pure-pagination

    一.App说明 该App用户Django的数据分页功能 二.安装 pip install django-pure-pagination 三.使用方法 (1)settings注册 INSTALLED_A ...

  4. redis持久化-AOF

    1.aof文件写入与同步 2.aof重写 重写的目的是为了减小aof文件的体积,redis服务器可以创建一个新的aof文件来代替现有的aof文件,新文件不会有冗余的命令. BGREWRITEAOF:遍 ...

  5. 基于vue3.0+electron新开窗口|Electron多开窗体|父子模态窗口

    最近一直在折腾Vue3+Electron技术结合的实践,今天就来分享一些vue3.x和electron实现开启多窗口功能. 开始本文之前,先来介绍下如何使用vue3和electron来快速搭建项目. ...

  6. Bash on Ubuntu on Windows ( Windows Subsystem for Linux)

    1 #  Bash on ubuntu on Windows http://www.cnblogs.com/anonymous-ufo/p/6143480.html 1 1 如何启用Bash on u ...

  7. how to use brew install gpg

    how to use brew install gpg https://formulae.brew.sh/formula/gnupg $ brew install gnupg https://gith ...

  8. free website generator by google

    free website generator by google https://sites.google.com/view/webgeeker-xyz/首页 https://sites.google ...

  9. Python Learning Paths

    Python Learning Paths Python Expert Python in Action Syntax Python objects Scalar types Operators St ...

  10. Microsoft Solitaire Collection

    Microsoft Solitaire Collection game https://zone.msn.com/gameplayer/gameplayerHTML.aspx?game=mssolit ...