我老人家走了四公里吃个汉堡还没吃成。垃圾肯德基。垃圾春分半价桶。

蜜雪冰城百香果加冰+烤串真是爽死了。原来二十多块钱可以吃的这么爽。

A:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
int main(){
ios::sync_with_stdio(false);
cin>>n>>m;
if(m%n)cout<<-;
else{
ll tmp = m/n;
int c1=,c2=;
while (tmp%==){
c1++;tmp/=;
}
while (tmp%==){
c2++;tmp/=;
}
if(tmp!=){
cout<<-;
} else{
cout<<c1+c2<<endl;
}
}
}

B:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+;
int n,a[N<<];
int main(){
ios::sync_with_stdio(false);
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i];
a[n+i]=a[i];
}
int ans = ,tmp = ;
for(int i=;i<=*n;i++){
if(a[i]==){
tmp++;
} else{
ans = max(ans,tmp);
tmp = ;
}
}
ans = max(ans,tmp);
cout<<ans<<endl;
}

C:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+;
int n,q[N],ans[N];
set<int> s;
int main(){
ios::sync_with_stdio(false);
cin>>n;
for(int i=;i<n;i++){
cin>>q[i];
}
int mx = ;
for(int i=;i<n;i++){
ans[i+]=ans[i]+q[i];
mx = max(mx,ans[i]);
}
mx = max(mx,ans[n]);
for(int i=;i<=n;i++){
ans[i]+=(n-mx);
if(ans[i]>n||ans[i]<){
cout<<-<<endl;
exit();
}
s.insert(ans[i]);
}
if(s.size()!=n) cout<<-;
else{
for(int i=;i<=n;i++){
cout<<ans[i]<<' ';
}
}
}

D:

 #include <bits/stdc++.h>
#define pii pair<int,int>
#define mk(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
const int N = 15e4+;
int n;
string a,b;
int v1[N],v2[N];
set<int> s[];
vector<pii>ans;
int main(){
ios::sync_with_stdio(false);
cin>>n>>a>>b;a="*"+a;b="*"+b;
for(int i=;i<=n;i++){
if(b[i]=='?')s[].insert(i);
else s[b[i]-'a'].insert(i);
}
for(int i=;i<=n;i++){
if(a[i]=='?')continue;
if(!s[a[i]-'a'].empty()) {
int id = *s[a[i] - 'a'].begin();
ans.push_back(mk(i, id));
s[a[i] - 'a'].erase(id);
v1[i] = ;
v2[id] = ;
} else{
if(s[].empty())continue;
int id = *s[].begin();
ans.push_back(mk(i, id));
s[].erase(id);
v1[i] = ;
v2[id] = ;
}
}
int id = ;
for(int i=;i<=n;i++){
if(a[i]!='?')continue;
while (s[id].empty()){
id++;
if(id>)break;
}
int x = *s[id].begin();
ans.push_back(mk(i,x));
s[id].erase(x);
}
cout<<ans.size()<<endl;
for(auto t:ans){
cout<<t.first<<' '<<t.second<<endl;
} }

E:直接暴力吧。看到同学有写二分的。。。二分个锤子啊。。

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+;
ll h, n;
ll a[N],pre[N];
int main(){
ios::sync_with_stdio(false);
cin>>h>>n;
ll tmp = h;
ll mn = 1e18;
for(int i=;i<=n;i++){
cin>>a[i];
tmp+=a[i];
if(tmp<=){
cout<<i;
exit();
}
pre[i]=pre[i-]+a[i];
mn = min(mn,pre[i]);
}
if(pre[n]>=){
cout<<-;
} else{
ll tmp = h+mn;
ll ans = abs(tmp/pre[n]*n);
h-=abs(ans/n*pre[n]);
while () {
for (int i = ; i <= n; i++) {
if (h <= ) {
cout << ans;
exit();
}
h += a[i];
ans++;
}
}
}
}

那么到这里已经过去四十多分钟了,接下来是专治傻逼题。

F2:被治了好几分钟然后挂机睡觉了。

直接暴力枚举所有区间和。完了。

 #include <bits/stdc++.h>
#define pii pair<int,int>
#define mk(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
map<int,vector<pii>>mp;
vector<pii>t,v,ans;
bool cmp(pii a,pii b){
return a.second<b.second;
}
int n,a[];
int main(){
ios::sync_with_stdio(false);
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i];
a[i]+=a[i-];
}
for(int i=;i<=n;i++){
for(int j=i;j<=n;j++){
mp[a[j]-a[i-]].push_back(mk(i,j));
}
}
for(auto x:mp){
t=x.second;
v.clear();
sort(t.begin(),t.end(),cmp);
int tmp = ;
int r=t[].second;
v.push_back(t[]);
for(int i=;i<t.size();i++){
if(t[i].first<=r)continue;
r=t[i].second;tmp++;
v.push_back(t[i]);
}
if(tmp>ans.size()){
ans=v;
}
}
cout<<ans.size()<<endl;
for(auto tmp:ans){
cout<<tmp.first<<' '<<tmp.second<<endl;
}
}

G:我感觉我写的假算法。。和别人的代码,和题解好像都不一样???

首先注意到一个性质,答案其实就是第k+1大的节点度数。

然后我们就搜一遍顺便染个色。

我在搜的过程中 直接把  父节点 能染的颜色起始下标赋给了子节点。。结果1A了。。。不太懂为啥是对的,明天问问学长。。。

 #include <bits/stdc++.h>
#define pii pair<int,int>
#define mk(a,b) make_pair(a,b)
using namespace std;
const int N = 2e5+;
struct Node{
int id,deg;
}a[N];
bool cmp(Node a,Node b){ return a.deg>b.deg;}
map<pii,int>mp;
int n,k,deg[N],ans[N],col[N];
vector<int> g[N];
void dfs(int v,int fa,int p){
for(auto u:g[v]){
if(u==fa)continue;
ans[mp[mk(max(u,v),min(u,v))]]=col[v]++;
col[u]=col[v];
col[u]%=p;col[v]%=p;
dfs(u,v,p);
}
}
int main(){
ios::sync_with_stdio(false);
cin>>n>>k;
int u,v;
for(int i=;i<n;i++){
cin>>u>>v;
deg[u]++;deg[v]++;
g[u].push_back(v);
g[v].push_back(u);
mp[mk(max(u,v),min(u,v))]=i;
}
for(int i=;i<=n;i++)a[i]={i,deg[i]},col[i]=;
sort(a+,a++n,cmp);
int tmp = a[k+].deg;
dfs(a[k+].id,a[k+].id,tmp);
cout<<tmp<<endl;
for(int i=;i<n;i++){
cout<<ans[i]+<<' ';
}
}

Codeforces Round #547 (Div. 3)的更多相关文章

  1. Codeforces Round #547 (Div. 3) 题解

    Codeforces Round #547 (Div. 3) 题目链接:https://codeforces.com/contest/1141 A,B咕咕了... C. Polycarp Restor ...

  2. E. Superhero Battle Codeforces Round #547 (Div. 3) 思维题

    E. Superhero Battle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #547 (Div. 3) G 贪心

    https://codeforces.com/contest/1141/problem/G 题意 在一棵有n个点的树上给边染色,连在同一个点上的边颜色不能相同,除非舍弃掉这个点,问最少需要多少种颜色来 ...

  4. Codeforces Round #547 (Div. 3) F 贪心 + 离散化

    https://codeforces.com/contest/1141/problem/F2 题意 一个大小为n的数组a[],问最多有多少个不相交的区间和相等 题解 离散化用值来做,贪心选择较前的区间 ...

  5. Codeforces Round #547 (Div. 3) D

    http://codeforces.com/contest/1141/problem/D 题目大意: 鞋子匹配,用一个小写字母表示一种颜色.L[i]表示左脚的颜色,R[i]表示右脚的颜色,只有当L[i ...

  6. Codeforces Round #547 (Div. 3) D. Colored Boots

    链接:https://codeforces.com/contest/1141/problem/D 题意: 给连个n长度的字符串. 求两个字符串相同字符对应位置的对数,并挨个打印. 字符:?可以代替任何 ...

  7. Codeforces Round #547 (Div. 3) B.Maximal Continuous Rest

    链接:https://codeforces.com/contest/1141/problem/B 题意: 给n个数,0代表工作,1代表休息,求能连续最大的休息长度. 可以连接首尾. 思路: 求普通连续 ...

  8. Codeforces Round #547 (Div. 3) A.Game 23

    链接:https://codeforces.com/contest/1141/problem/A 题意: 给n和m,有两种操作:将n×2 或 n×3,求最少的乘法次数由n得到m. 不能得到时为-1. ...

  9. Codeforces Round #547 (Div. 3) E. Superhero Battle

    E. Superhero Battle A superhero fights with a monster. The battle consists of rounds, each of which ...

随机推荐

  1. LCA(Tarjan)

    时间复杂度:dfs为O(N),dfs过程中处理所有查询对为O(M),总时间复杂度O(N+M) #include<iostream> #include<cstdio> using ...

  2. SpringBoot系列: JdbcTemplate 快速入门

    对于一些小的项目, 我们没有必要使用MyBatis/JPA/Hibernate等重量级技术, 直接使用Spring JDBC 即可, Spring JDBC 是对 jdbc的简单封装, 很容易掌握. ...

  3. Navier-Stokes equations (Lectured by Luis Caffarelli)

    百万美元问题: http://www.claymath.org/millennium-problems/navier%E2%80%93stokes-equation Official Problem ...

  4. [Everyday Mathematics]20150305

    设 $f\in C^2[0,1]$, $$\bex f(0)=-1,\quad f'(1)=3,\quad \int_0^1 xf''(x)\rd x=1. \eex$$ 试求 $f(1)$. 解答: ...

  5. [物理学与PDEs]第1章第2节 预备知识 2.2 Ampere-Biot-Savart 定律, 静磁场的散度与旋度

    1. 电流密度, 电荷守恒定律 (1) 电荷的定向移动形成电流. (2) 电流密度 ${\bf j}$, 是描述导体内一点在某一时刻电流流动情况的物理量, 用单位时间内通过垂直于电流方向的单位面积的电 ...

  6. 2.12 for循环

    for循环 像while循环一样,for可以完成循环的功能. 在Python中 for循环可以遍历任何序列的项目,如一个列表或者一个字符串等. for循环的格式 for 临时变量 in 列表或者字符串 ...

  7. python爬虫解决编码问题

    参考 https://blog.csdn.net/qq_38008452/article/details/80423436 问题 解决方法 加上encoding='utf-8'

  8. ES--08

    71.内核原理探秘_最后优化写入流程实现海量磁盘文件合并(segment merge,optimize) 课程大纲 每秒一个segment file,文件过多,而且每次search都要搜索所有的seg ...

  9. 帆软报表(finereport) 折叠树

    在进行展现数据时,希望模板的数据是可以动态折叠的,即点击数据前面的加号才展开对应下面的数据,可通过树节点按钮实现折叠树效果 实现思路: 1.这里建立一个内置数据集 添加数据 设置模板样式,添加颜色和对 ...

  10. 【原创】大叔问题定位分享(15)spark写parquet数据报错ParquetEncodingException: empty fields are illegal, the field should be ommited completely instead

    spark 2.1.1 spark里执行sql报错 insert overwrite table test_parquet_table select * from dummy 报错如下: org.ap ...