1. C - Scc Puzzle

计算scc的个数,先判断s个数需要多少个cc,多的cc,每四个可以组成一个scc。注意数据范围,使用long long.

 #include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + ;
void solve() {
ll x, y;
while(cin >> x >> y) {
ll res = ;
if(y >= * x) {
res = x + (y - * x) / ;
} else {
res = y / ;
}
cout << res << endl;
}
}
int main() {
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
solve();
return ;
}

2. D - Menagerie

读完题目,感觉是无从下手,3 <= n <= 1e5,暴力判断每一个字符串,肯定会tle,然后就要想其他方法了。

然后突然想到:固定前2个数,然后其他的位置可以推导出来,最后判断第一个和最后一个位置是否合法就可以了。

我写的又长又臭,哎,先这样吧,慢慢改进。

 #include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + ;
int n;
vector<bool> res;
bool work(const string &s) {
for (int i = ; i < n - ; i++) {
if(s[i] == 'o') {
if(res[i]) {
res[i + ] = !res[i - ];
} else {
res[i + ] = res[i - ];
}
} else {
if(res[i]) {
res[i + ] = res[i - ];
} else {
res[i + ] = !res[i - ];
}
}
}
bool f1, f2;
f1 = f2 = ;
if(s[n - ] == 'o') {
if(res[n - ]) {
f1 = res[n - ] != res[];
} else {
f1 = res[n - ] == res[];
}
} else {
if(res[n - ]) {
f1 = res[n - ] == res[];
} else {
f1 = res[n - ] != res[];
}
} if(s[] == 'o') {
if(res[]) {
f2 = res[n - ] != res[];
} else {
f2 = res[n - ] == res[];
}
} else {
if(res[]) {
f2 = res[n - ] == res[];
} else {
f2 = res[n - ] != res[];
}
}
return f1 && f2;
}
void pr() {
for (int i = ; i < n; i++) {
if(res[i]) cout << 'W';
else cout << 'S';
}
cout << endl;
}
void solve() {
string s;
while(cin >> n) {
cin >> s;
res.clear();
res.resize(n);
res[] = res[] = ;
bool f = work(s);
if(f) {
pr();
continue;
}
res[] = res[] = ;
f = work(s);
if(f) {
pr();
continue;
}
res[] = ; res[] = ;
f = work(s);
if(f) {
pr();
continue;
}
res[] = ; res[] = ;
f = work(s);
if(f) {
pr();
continue;
}
cout << - << endl;
}
}
int main() {
// freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
solve();
return ;
}

3. E - Frequency

1<=n<=1e5,1<=a<=1e9,数据范围很大,不可能一个一个的模拟。注意结果可能需要long long来保存。

考虑最大的数,然后递减到次大的数,然后每次维护一下这些数的index的最小值,依次统计,最后输出。

使用set来维护数的顺序,同时记录index.

 #include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + ;
int a[maxn];
set<int> se;
map<int, vector<int>> tag;
map<int, int> sz;
ll res[maxn];
int n;
void solve() {
cin >> n;
for (int i = ; i < n; i++) {
cin >> a[i];
se.insert(a[i]);
sz[a[i] ]++;
tag[a[i] ].pb(i + );
}
while(se.size() > ) {
int t = *se.rbegin();
se.erase(t);
int nt = *se.rbegin();
int mi = tag[t][];
for (int x : tag[t]) {
mi = min(mi, x);
}
tag[nt].pb(mi);
res[mi] += 1ll * (t - nt) * sz[t];
sz[nt] += sz[t];
}
int t = *se.begin();
int mi = tag[t][];
for (int x : tag[t]) mi = min(mi, x);
res[mi] += 1ll * t * sz[t];
for (int i = ; i <= n; i++)
cout << res[i] << endl;
}
int main() {
// freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio();
cin.tie(); cout.tie();
solve();
return ;
}

4。 F - Flags

题目很简短,不知道怎么做。官方题解只有日语的,没有进一步用翻译去看,有时间,搞一下。

AtCoder Regular Contest 069的更多相关文章

  1. AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图

    AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图 链接 AtCoder 大意 在数轴上放上n个点,点i可能的位置有\(x_i\)或者\(y_i\ ...

  2. AtCoder Regular Contest 069 D

    D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...

  3. AtCoder Regular Contest 069 D - Menagerie 枚举起点 模拟递推

    arc069.contest.atcoder.jp/tasks/arc069_b 题意:一堆不明身份的动物排成一圈,身份可能是羊或狼,羊一定说实话,狼一定说假话.大家各自报自己的两边是同类还是不同类, ...

  4. AtCoder Regular Contest 069 F - Flags

    题意: 有n个点需要摆在一个数轴上,每个点需要摆在ai这个位置或者bi上,问怎么摆能使数轴上相邻两个点之间的距离的最小值最大. 二分答案后显然是个2-sat判定问题,因为边很多而连边的又是一个区间,所 ...

  5. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  6. AtCoder Regular Contest 094 (ARC094) CDE题解

    原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...

  7. AtCoder Regular Contest 092

    AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...

  8. AtCoder Regular Contest 093

    AtCoder Regular Contest 093 C - Traveling Plan 题意: 给定n个点,求出删去i号点时,按顺序从起点到一号点走到n号点最后回到起点所走的路程是多少. \(n ...

  9. AtCoder Regular Contest 094

    AtCoder Regular Contest 094 C - Same Integers 题意: 给定\(a,b,c\)三个数,可以进行两个操作:1.把一个数+2:2.把任意两个数+1.求最少需要几 ...

随机推荐

  1. 三维重建:多点透视cvSolvePNP的替代函数(Code)

           在调试JNI程序时,所有的Shell都已经加载完成,而唯一真正核心的cv::SolvePnP却不能在JNI里面获得通行证,经过反复测试都不能运行,因此只能忍痛舍弃,自行编写一个具有相 ...

  2. Lua的string库函数、lua中string的模式匹配

    --****************Lua的string库函数****************** --1.string.byte --string.byte (s [, i [, j]]) --取出 ...

  3. JS 常用语法

    通常,通过 JavaScript,您需要操作 HTML 元素. 1.通过 id 找到 HTML 元素 2.通过标签名找到 HTML 元素 3.通过类名找到 HTML 元素 提示:通过类名查找 HTML ...

  4. HDU-1134 卡特兰数+java大数模板

    题意: 给你一个n,然后1,2,3...2n-1,2n围一圈,让每个数都能用一条线配对并且线与线之间不能交叉,问有几种方法数. 思路: 1 可以和2,4,6...连接.假如   一共有8个数,1和2连 ...

  5. Linux浅谈磁盘管理及案例

    磁盘管理 MBR原理图 从该图可理解到为什么主分区只能是四个. 可以不分区,但为了统一管理,提高访问效率 设备不同,生成设备名称不同 管理分区命令: lsblk查看块设备 fdisk创建MBR分区 f ...

  6. CSS学习笔记之CSS3新特性

    目录 1.边框 2.背景 3.文本 4.字体 5.转换 6.过渡 7.动画 8.多列 9.自定义尺寸 CSS 用于控制网页的样式和布局,而 CSS3 是最新的 CSS 标准,这篇文章将着重介绍 CSS ...

  7. MyBatis之java.lang.UnsupportedOperationException异常解决方案

    今天在使用MyBatis执行sql语句时,出现如下异常: 执行的sql语句配置信息如下: <select id="getColumnsByTableName" paramet ...

  8. TCP连接之未连接队列的理解

    tcp服务器在TCP/IP协议中,TCP协议提供可靠的连接服务,采用三次握手建立一个连接. 第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SEND状态,等待服务器确认 ...

  9. js setTimeout函数

    最近在看JS DOM编程艺术,在第十章的动画里面有个setTimeout函数的例子中涉及了很多的引号,研究了好大一会才看明白,综合网上各个大神的解释和自己的理解,其原理是这样的: 首先看下程序源代码: ...

  10. kettle 递归循环

    var i = new Number(parent_job.getVariable(; parent_job.setVariable("i",i); true;