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

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

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. DirectX11 With Windows SDK--19 模型加载:obj格式的读取及使用二进制文件提升读取效率

    前言 一个模型通常是由三个部分组成:网格.纹理.材质.在一开始的时候,我们是通过Geometry类来生成简单几何体的网格.但现在我们需要寻找合适的方式去表述一个复杂的网格,而且包含网格的文件类型多种多 ...

  2. [物理学与PDEs]第4章第3节 一维反应流体力学方程组 3.2 一维反应流体力学方程组的 Lagrange 形式

    1.  一维粘性热传导反应流体力学方程组的 Lagrange 形式 $$\beex \bea \cfrac{\p \tau}{\p t'}-\cfrac{\p u}{\p m}&=0,\\ \ ...

  3. java(10)类的无参方法

    一.变量的作用域(有效的使用范围) 1.变量有2种 1.1成员变量(属性) 声明在类的里面,方法的外面 1.2 局部变量 声明在方法里面或for循环结构中 2.调用时的注意事项(初始值不同.作用域不同 ...

  4. audio autoplay 是pause 不会停止播放

    $("#alarmWav").append( $('<audio id="alarmAudio" autoplay loop src="../j ...

  5. phpstudy 安装Apache SSL证书实现https连接

    Windows phpstudy安装ssl证书教程. 工具/原料   phpstudy 集成环境 申请的SSL证书 方法/步骤     首先申请免费的ssl证书,很多地方都可以申请.我是在腾讯云!如图 ...

  6. 华为交换机配置stelnet登陆的实例

    作者:邓聪聪 为满足等堡安全要求,对测评对象的交换机做安全登陆的限制 :开启ssh的服务 stelnet server enable :#创建认证用户的用户名和密码 aaa local-user te ...

  7. Django Tastypie: 贴士,技巧和故障排除

    为Resource加入字段 1.为字段实现专门的dehydrate函数 2.实现(resource级别的)dehydrate方法 3.额外的方法 排除故障 通过外键,外键的反向关系来映射一个对象的属性 ...

  8. SQL Server with ties 语句

    With ties 语句是与top.order by 语句联合使用的语句:我们在实际查询过程中会遇到这样的情况,比如查询考试为前三名的学生信息,发现有并列第三的情况,如果我们只是top 3 发现并列第 ...

  9. <?xml version="1.0" encoding="UTF-8"?> 的作用

    version="1.0" 声明用的xml版本是1.0 encoding="UTF-8" 声明用xml传输数据的时候的字符编码,假如文档里面有中文,编码方式不是 ...

  10. 关于数据库中日期格式(yy-MM-dd HH-mm-ss)通过json传到后台变成毫秒数的问题

    在日期封装对象前面加一个json标签即可防止自动转换 如 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date mod ...