C - 2D Plane 2N Points

把能连边的点找到然后跑二分图匹配即可

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define mp make_pair
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
res = 0;char c = getchar();T f = 1;
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {putchar('-');x = -x;}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int g[105][105];
int a[105],b[105],c[105],d[105],N,matk[105];
bool vis[105];
bool match(int u) {
for(int i = 1 ; i <= 100 ; ++i) {
if(g[u][i] && !vis[i]) {
vis[i] = 1;
if(!matk[i] || match(matk[i])) {
matk[i] = u;
return true;
}
}
}
return false;
}
void Solve() {
read(N);
for(int i = 1 ; i <= N ; ++i) {read(a[i]);read(b[i]);}
for(int i = 1 ; i <= N ; ++i) {read(c[i]);read(d[i]);}
for(int i = 1 ; i <= N ; ++i) {
for(int j = 1 ; j <= N ; ++j) {
if(a[i] < c[j] && b[i] < d[j]) g[i][j] = 1;
}
}
int ans = 0;
for(int i = 1 ; i <= N ; ++i) {
memset(vis,0,sizeof(vis));
if(match(i)) ++ans;
}
out(ans);enter;
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}

D - Two Sequences

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define mp make_pair
#define MAXN 200005
#define pb push_back
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
res = 0;char c = getchar();T f = 1;
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {putchar('-');x = -x;}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int N;
int a[MAXN],b[MAXN];
int val[2][MAXN],len[2];
bool check(int p) {
len[0] = len[1] = 0;
for(int i = 1 ; i <= N ; ++i) {
if(a[i] & (1 << p)) val[1][++len[1]] = a[i] & (1 << p) - 1;
else val[0][++len[0]] = a[i] & (1 << p) - 1;
}
sort(val[1] + 1,val[1] + len[1] + 1);
sort(val[0] + 1,val[0] + len[0] + 1);
int64 res = 0;
for(int i = 1 ; i <= N ; ++i) {
int t = (1 << p) - (b[i] & (1 << p) - 1);
int p0,p1;
p0 = lower_bound(val[0] + 1,val[0] + len[0] + 1,t) - val[0] - 1;
p1 = lower_bound(val[1] + 1,val[1] + len[1] + 1,t) - val[1] - 1;
if(b[i] & (1 << p)) {res += p0;res += len[1] - p1;}
else {res += p1;res += len[0] - p0;}
}
return res & 1;
}
void Solve() {
read(N);
for(int i = 1 ; i <= N ; ++i) {read(a[i]);}
for(int i = 1 ; i <= N ; ++i) {read(b[i]);}
int ans = 0;
for(int i = 28 ; i >= 0 ; --i) {
if(check(i)) ans |= (1 << i);
}
out(ans);enter;
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}

E - Both Sides Merger

显然是只能从\(f[i] = max(f[i - 2k] + a[i])\)转移过来

记录一下前一个从哪里转移过来,删一段区间的时候从中间开始删

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 1005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
res = 0;char c = getchar();T f = 1;
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int N;
int64 a[MAXN],dp[MAXN];
int fr[MAXN];
int op[MAXN],tot; void Solve() {
read(N);
for(int i = 1 ; i <= N ; ++i) read(a[i]);
int64 ans = a[1];
for(int i = 1 ; i <= N ; ++i) {
dp[i] = a[i];fr[i] = 0;
for(int j = 2 ; j <= i ; j += 2) {
if(dp[i - j] + a[i] > dp[i]) {
dp[i] = dp[i - j] + a[i];
fr[i] = i - j;
}
}
ans = max(ans,dp[i]);
}
out(ans);enter;
int a = N;
for(int i = N ; i >= 1 ; --i) {
if(dp[i] == ans) {
for(int j = N ; j > i ; --j) {op[++tot] = j;--a;}
int t = i,c = 0;
while(fr[t]) {
++c;
int mid = (fr[t] + 1 + a - c) >> 1;
for(int j = mid ; j > fr[t] ; --j) {op[++tot] = j;}
a -= (a - c - fr[t]);
t = fr[t];
}
for(int j = 1 ; j < t ; ++j) op[++tot] = 1;
break;
}
}
out(tot);enter;
for(int i = 1 ; i <= tot ; ++i) {
out(op[i]);enter;
}
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}

F - Two Faced Edges

mdzz,我不会卡常,走了

生气了

【AtCoder】ARC092的更多相关文章

  1. 【AtCoder】ARC092 D - Two Sequences

    [题目]AtCoder Regular Contest 092 D - Two Sequences [题意]给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1<=i,j<=n ...

  2. 【Atcoder】CODE FESTIVAL 2017 qual A D - Four Coloring

    [题意]给定h,w,d,要求构造矩阵h*w满足任意两个曼哈顿距离为d的点都不同色,染四色. [算法]结论+矩阵变换 [题解] 曼哈顿距离是一个立着的正方形,不方便处理.d=|xi-xj|+|yi-yj ...

  3. 【AtCoder】ARC 081 E - Don't Be a Subsequence

    [题意]给定长度为n(<=2*10^5)的字符串,求最短的字典序最小的非子序列字符串. http://arc081.contest.atcoder.jp/tasks/arc081_c [算法]字 ...

  4. 【AtCoder】AGC022 F - Leftmost Ball 计数DP

    [题目]F - Leftmost Ball [题意]给定n种颜色的球各k个,每次以任意顺序排列所有球并将每种颜色最左端的球染成颜色0,求有多少种不同的颜色排列.n,k<=2000. [算法]计数 ...

  5. 【AtCoder】AGC005 F - Many Easy Problems 排列组合+NTT

    [题目]F - Many Easy Problems [题意]给定n个点的树,定义S为大小为k的点集,则f(S)为最小的包含点集S的连通块大小,求k=1~n时的所有点集f(S)的和取模92484403 ...

  6. 【AtCoder】ARC067 F - Yakiniku Restaurants 单调栈+矩阵差分

    [题目]F - Yakiniku Restaurants [题意]给定n和m,有n个饭店和m张票,给出Ai表示从饭店i到i+1的距离,给出矩阵B(i,j)表示在第i家饭店使用票j的收益,求任选起点和终 ...

  7. 【AtCoder】ARC095 E - Symmetric Grid 模拟

    [题目]E - Symmetric Grid [题意]给定n*m的小写字母矩阵,求是否能通过若干行互换和列互换使得矩阵中心对称.n,m<=12. [算法]模拟 [题解]首先行列操作独立,如果已确 ...

  8. 【Atcoder】AGC022 C - Remainder Game 搜索

    [题目]C - Remainder Game [题意]给定n个数字的序列A,每次可以选择一个数字k并选择一些数字对k取模,花费2^k的代价.要求最终变成序列B,求最小代价或无解.n<=50,0& ...

  9. 【Atcoder】AGC 020 B - Ice Rink Game 递推

    [题意]n个人进行游戏,每轮只保留最大的a[i]倍数的人,最后一轮过后剩余2人,求最小和最大的n,或-1.n<=10^5. [算法]递推||二分 [题解]令L(i),R(i)表示第i轮过后的最小 ...

随机推荐

  1. hdwiki 前后台版权信息在哪修改

    hdwiki 前台copyright 信息在 view/default/footer.htm 搜索footer-phdwiki 后台copyright 信息在 view/default/admin_m ...

  2. 【刷题】BZOJ 3944 Sum

    Description Input 一共T+1行 第1行为数据组数T(T<=10) 第2~T+1行每行一个非负整数N,代表一组询问 Output 一共T行,每行两个用空格分隔的数ans1,ans ...

  3. 前端学习 -- Css -- 样式的继承

    像儿子可以继承父亲的遗产一样,在CSS中,祖先元素上的样式,也会被他的后代元素所继承, 利用继承,可以将一些基本的样式设置给祖先元素,这样所有的后代元素将会自动继承这些样式. 但是并不是所有的样式都会 ...

  4. Codeforces Round #541

    因为这次难得不在十点半(或是更晚),大家都在打,然后我又双叒叕垫底了=.= 自己对时间的分配,做题的方法和心态还是太蒻了,写的时候经常写一半推倒重来.还有也许不是自己写不出来,而是在开始写之前就觉得自 ...

  5. 解题:HAOI 2015 按位或

    题面 Min-Max容斥:对于集合S $min(S)=\sum_{s∈S}(-1)^{|s|+1}max(s)$ $max(S)=\sum_{s∈S}(-1)^{|s|+1}min(s)$ 那么这个题 ...

  6. 洛谷P2469 星际竞速

    上下界费用流比较无脑,提供一种更巧妙的费用流,无需上下界. #include <cstdio> #include <algorithm> #include <queue& ...

  7. windows2008设置IIS服务器定时自动重启的方法

    我们在使用windows2008下IIS服务器时会经常出现资源耗尽的现象,运行一段时间下来就会出现访问服务器上的网站时提示数据库连接出错,重启IIS后网站又能正常访问了,这个问题可能困扰了很多站长朋友 ...

  8. C++并发编程实战---阅读笔记

    1. 当把函数对象传入到线程构造函数中时,需要避免“最令人头痛的语法解析”.如果传递了一个临时变量,而不是一个命名的变量:C++编译器会将其解析为函数声明,而不是类型对象的定义. 例如: class ...

  9. shell中exec命令

    1.find中的-exec参数 在当前目录下(包含子目录),查找所有txt文件并找出含有字符串"bin"的行 find ./ -name "*.txt" -ex ...

  10. Linux quotacheck失败

    我找了多少个帖子才发现解决这个问题的啊...最终还是靠FQ找的这位大佬的文章  http://www.2daygeek.com/quotacheck-error/# 当我在执行quotacheck - ...