Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only)
http://codeforces.com/contest/92
A
#include<iostream>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 100005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
int i=;
while(i+<=m){
m-=i+;
i++;
if(i==n) i%=n;
}
cout<<m<<endl;
}
B
模拟+找规律
#include<iostream>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define maxn 100005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ /// int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string str;
cin>>str;
if(str==""){
cout<<;
return ;
}
int ans=;
for(int i=str.length()-;i>=;i--){
if(str[i]==''&&i==) break;
if(str[i]==''){
ans+=;
int l=i;
while(l>=&&str[l]==''){
str[l]='';
l--;
}
if(l>=) str[l]='';
}
else{
ans++;
} }
cout<<ans<<endl;
}
C
二分
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ vector<int>ve[];
int book[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string s1,s2;
cin>>s1>>s2;
int ans=;
for(int i=;i<s1.length();i++){
ve[s1[i]-'a'].pb(i);
}
int pos=-;
int x,tmp;
for(int i=;i<s2.length();i++){
x=s2[i]-'a';
if(ve[x].size()==){
cout<<-<<endl;
return ;
}
tmp=lower_bound(ve[x].begin(),ve[x].end(),pos+)-ve[x].begin();
if(tmp!=ve[x].size()){
pos=ve[x][tmp];
}
else{
ans++;
pos=lower_bound(ve[x].begin(),ve[x].end(),)-ve[x].begin();
pos=ve[x][pos];
}
// cout<<tmp<<" "<<pos<<" "<<ans<<endl;
// cout<<pos<<endl;
}
cout<<ans<<endl;
}
D
线段树
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int a[maxn];
int tree[maxn<<];
int n; void push_up(int rt){
tree[rt]=min(tree[rt<<],tree[rt<<|]);
} void build(int l,int r,int rt){
if(l==r){
tree[rt]=a[l];
return;
}
int mid=l+r>>;
build(lson);
build(rson);
push_up(rt);
} int query(int L,int R,int v,int l,int r,int rt){
if(l==r&&L<=l&&R>=r){
return l;
}
int mid=l+r>>;
if(L<=mid&&tree[rt<<]<v){
return query(L,R,v,lson);
}
else if(R>mid&&tree[rt<<|]<v){
return query(L,R,v,rson);
}
return -;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
for(int i=n;i>=;i--) cin>>a[i];
build(,n,);
int pos;
vector<int>ans;
for(int i=;i<=n;i++){
pos=query(,i,a[i],,n,);
if(pos==-) ans.pb(pos);
else ans.pb(i-pos-);
}
reverse(ans.begin(),ans.end());
for(int i=;i<ans.size();i++) cout<<ans[i]<<" ";
}
E
并查集
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 100005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int n,m;
int fa[]; int Find(int x){
int r=x,y;
while(x!=fa[x]) x=fa[x];
while(r!=x){
y=fa[r];
fa[r]=x;
r=y;
}
return x;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m;
int x,y,xx,yy;
ll ans=;
for(int i=;i<=n;i++) fa[i]=i;
for(int i=;i<m;i++){
cin>>x>>y;
xx=Find(x),yy=Find(y);
if(xx==yy){
ans=(ans+ans)%MOD;
}
else fa[xx]=yy;
cout<<ans-<<endl;
} }
Codeforces Beta Round #75 (Div. 2 Only)的更多相关文章
- Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树+二分
B. Queue Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/91/B Descrip ...
- Codeforces Beta Round #75 (Div. 1 Only) B. Queue 二分
B. Queue Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/91/B Descrip ...
- Codeforces Beta Round #67 (Div. 2)
Codeforces Beta Round #67 (Div. 2) http://codeforces.com/contest/75 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- 玩转音频、视频的利器:FFmpeg
导语 当下直播平台发展十分迅猛,依靠游戏内直播平台的发展带动游戏活跃提升收入,那么对于我们开发来说如何玩转视频呢?下面就来介绍一个音频.视频处理利器——FFmpeg. FFmpeg 简介 FFmpeg ...
- OV7670配置和调试小结
先上一下OV7670的框架图 OV7670常用寄存器设置说明 直接看OV7670 Implementation Guide (V1.0)等 资料我已经上传了 https://files.cnblogs ...
- H5自动准备杂记
由于之前没做过UI自动化,近期准备做H5自动化,要学的东西还是很多. 1.本地debug环境:android studio + android SDK(想要调试通要关注:驱动.手机开发者模式要打开) ...
- beego orm操蛋问题:操作都需要主键
查看bee generate appcode自动生成的代码,会发现orm操作都是以主键为依据的. 如果我不想根据主键怎么操作?用 ORM.Raw(cmd).Exec()吧,cmd=[你的mysql语句 ...
- C++Builder debug 程序的时候 structure required
C++Builder debug 程序的时候, deub一个变量 dm->avar; E2288 Pointer to structure required on left side of -& ...
- 机器学习入门-数值特征-对数据进行log变化
对于一些标签和特征来说,分布不一定符合正态分布,而在实际的运算过程中则需要数据能够符合正态分布 因此我们需要对特征进行log变化,使得数据在一定程度上可以符合正态分布 进行log变化,就是对数据使用n ...
- UI5-Fiori初学者导航
正文 你是UI5和Fiori的新手?来对地方了. 对我来说,今年是不得不“跟上时代”去提升自己ABAP世界以外的技术技能的困难的一年.幸运的是,有很多可免费获得的信息和课程可以帮你实现这个跳跃.不要等 ...
- 2018SDIBT_国庆个人第五场
A - ACodeForces 1060A Description Let's call a string a phone number if it has length 11 and fits th ...
- Kotlin语言编程技巧集
空语句 Kotlin 语言中的空语句有 {} Unit when (x) { 1 -> ... 2 -> ... else -> {} // else -> Unit } Wh ...
- 判断页面是否添加了W3C声明
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...