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> ...
随机推荐
- 深度学习原理与框架-神经网络-cifar10分类(代码) 1.np.concatenate(进行数据串接) 2.np.hstack(将数据横着排列) 3.hasattr(判断.py文件的函数是否存在) 4.reshape(维度重构) 5.tanspose(维度位置变化) 6.pickle.load(f文件读入) 7.np.argmax(获得最大值索引) 8.np.maximum(阈值比较)
横1. np.concatenate(list, axis=0) 将数据进行串接,这里主要是可以将列表进行x轴获得y轴的串接 参数说明:list表示需要串接的列表,axis=0,表示从上到下进行串接 ...
- mongodb学习-练习实例
C:\Users\issuser>mongoMongoDB shell version: 2.4.6connecting to: test> db.user.find(){ "_ ...
- JEECG-P3开发专题 - 开发环境搭建入门
官方标准开发工具: 1 .IDE Eclipse Java EE IDE for Web Developers. Version: Mars.2 Release (4.5.2) Build id: 2 ...
- mysql每天凌晨0点准时启动taskeng.exe如何关闭
MySQL弹出一个taskeng.exe. 内容如下:=====================Start Initialization====================mysql Instal ...
- confusing c++ 重写 与 重定义 记录1
class parent { public: void f() { cout << "parent f()" << endl; } void f(int i ...
- cordova-config.xml配置应用图标
1. <icon src="res/icon/ios/browser.png"/> 2.规格: iphone平台一般要求3种规格的图片:1x.2x.3x,也是就Icon ...
- System.net.mail 使用ssl发送邮件失败
我采用了.net 的自带组件System.Net.Mail发送邮件,主要是在客户注册网站成功的时候发条欢迎邮件,最近邮件无法发送了,看了下腾讯smtp邮件配置,所有的邮件发送都换成ssl了,之前用的是 ...
- void类型详解
void含义 void的字面意思是"无类型",void*则为"无类型指针",void*可以指向任何类型的数据. void几乎只有"注释"和限 ...
- 跨域(一)——CORS机制
Ajax是严格遵守同源策略的,既不能从另一个域读取数据,也不能发送数据到另一个域.但是,W3C的新标准中CORS(Cross Origin Resource Sharing)推进浏览器支持这样的跨域方 ...
- Linux Shell 内建命令:冒号(:)
https://blog.csdn.net/honghuzhilangzixin/article/details/7073312/ 在Linux系统中,冒号(:)常用来做路径的分隔符(PATH),数据 ...