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

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

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--HLSL中矩阵的内存布局和mul函数探讨

    前言 说实话,我感觉这是一个大坑,不知道为什么要设计成这样混乱的形式. 在我用的时候,以row_major矩阵,并且mul函数以向量左乘矩阵的形式来绘制时的确能够正常显示,并不会有什么感觉.但是也有人 ...

  2. SPFA+SLF+LLL

    关于SLF优化 朴素SPFA使用常规队列(FIFO)更新距离,并没有考虑优化出队顺序(dis值小的优先出队)可以在一开始就把各个点的dis值限值小,从而避免大量的松弛操作,从而提高效率.这就是SLF( ...

  3. 盒子显隐,伪类边框,盒子阴影,2d平面形变

    -盒子显隐 显隐的盒子尽量不影响其他盒子的布局 display:none; 消失的时候不占位置,显示的时候占位 opacity:0-1; 盒子透明度 overflow: hidden; 超出部分隐藏 ...

  4. [再寄小读者之数学篇](2014-10-08 乘积型 Sobolev 不等式)

    $$\bex n\geq 2, 1\leq p<n\ra \sen{f}_{L^\frac{np}{n-p}(\bbR^n)} \leq C\prod_{k=1}^n \sen{\p_k f}_ ...

  5. 【js课设】电子画板01

    这学期web开发课的课设选了电子画板课题.(人家本来想做富文本编辑器的嘛然鹅老师在第二版里把这题删掉了。゚ヽ(゚´Д`)ノ゚。) 主要考虑的有[界面美观][画笔类型][画布分层]这三个点了. [界面美 ...

  6. LOJ #2116 Luogu P3241「HNOI2015」开店

    好久没写数据结构了 来补一发 果然写的时候思路极其混乱.... LOJ #2116 Luogu P3241 题意 $ Q$次询问,求树上点的颜色在$ [L,R]$中的所有点到询问点的距离 强制在线 询 ...

  7. library 显示所有的数据

    <?php  $conn = @mysql_connect('localhost', 'root', ''); if($conn) {  echo "连接成功"; }else ...

  8. 整理一下C++语言中的头文件

    对于每一个像我一样的蒟蒻来说,C++最重要的东西就是头文件的使用了.由于初学,直到现在我打代码还是靠一些事先写好的的头文件,仍然不能做到使用自己需要的.最近看了几位大佬打代码,心中突然闪过要把自己冗长 ...

  9. django/python日志logging 的配置以及处理

    日志在程序开发中是少不了的,通过日志我们可以分析到错误在什么地方,有什么异常.在生产环境下有很大的用处.在java 开发中通常用 log4j,logback 等三方组件.那么在 django中是怎么处 ...

  10. 我实在不懂Python的Asyncio

    原语 事件循环(Event Loop) Awaitables和Coroutines Coroutine Wrappers Awaitables and Futures Tasks Handles Ex ...