https://codeforces.com/contest/1138

B:

#include <bits/stdc++.h>
using namespace std;
const int maxn=1e3+5;
string a,b;
void check(int x,int y,int z,int k)
{for(int i=0;a[i];i++){if(a[i]=='1'&&b[i]=='0'&&x) //这里奇耻大辱,居然写反了 当时{cout<<i+1<<' ';x--;}if(a[i]=='0'&&b[i]=='1'&&y){cout<<i+1<<' ';y--;}if(a[i]=='1'&&b[i]=='1'&&z){cout<<i+1<<' ';z--;}if(a[i]=='0'&&b[i]=='0'&&k){cout<<i+1<<' ';k--;}}}
int main()
{int n;while(cin>>n){cin>>a>>b;int x=0,y=0,z=0,k=0;for(int i=0;a[i];i++){if(a[i]=='1'&&b[i]=='0') x++;if(a[i]=='0'&&b[i]=='1') y++;if(a[i]=='1'&&b[i]=='1') z++;if(a[i]=='0'&&b[i]=='0') k++;}int x1,x2,x3,x4 ,y1,y2,y3,y4;for(int i=0;i<=x;i++){x1=i;y1=x-i;for(int j=0;j<=y;j++){x2=j;y2=y-j;x3=y2-x1+z;y3=x1-y2+z;if(x3%2!=0||y3%2!=0||x3<0||y3<0) continue;x3/=2;y3/=2;x4=n/2-x1-x2-x3;y4=n/2-y1-y2-y3;if(x4+y4==k&&x4>=0&&y4>=0){cout<<"asd "<<x4<<' '<<y4<<endl;
//                    cout<<x1<<' '<<x2<<' '<<x3<<' '<<x4<<endl;
//                   cout<<y1<<' '<<y2<<' '<<y3<<' '<<y4<<endl;check(x1,x2,x3,x4);return 0;}}}cout<<-1<<endl;}}

https://codeforces.com/contest/1138/problem/C

题意:
注意一点,是去寻找这一行,和这一列,行和列是单独的。
比如例子中,是因为横行确定为3了之后,所以上面的20才是4,4和 3所在和横行没有关系。

读题也是实力的一部分

题解;
对每一行每一列进行离散化。
然后,取行列的最大值,和行列数所在行列大小的差值和其对应的行列加起来的值的最大值进行比较。

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
struct node
{node ( int xx, int yy, int zz ){x = xx;y = yy;v = zz;}int x;int y;int v;int m;};
vector<node > d[maxn];
bool cmp1 ( node a, node b )
{return a.x < b.x;
}bool cmp2 ( node a, node b )
{return  a.v < b.v;
}int hang[maxn], lie[maxn];int main()
{int n, m;while ( cin >> n >> m ){int x;for ( int i = 1; i <= n; i++ ){for ( int j = 0; j < m; j++ ){// cin>>x;scanf ( "%d", &x );d[i].push_back ( node ( x, 0, j ) );}sort ( d[i].begin(), d[i].end(), cmp1 );map<int, int > tag;int les = 0;for ( int j = 0; j < m; j++ ){if ( !tag[d[i][j].x] ){tag[d[i][j].x] = 1;les++;}d[i][j].y = les;}hang[i] = les;sort ( d[i].begin(), d[i].end(), cmp2 );}//  cout<<" asd  "<<endl;for ( int i = 0; i < m; i++ ){vector<node > temp;for ( int j = 1; j <= n; j++ ){temp.push_back ( node ( d[j][i].x, 0, j ) );}map<int, int > tag;int les = 0;sort ( temp.begin(), temp.end(), cmp1 );for ( int j = 0; j < n; j++ ){if ( !tag[temp[j].x] ){tag[temp[j].x] = 1;les++;}temp[j].m = les;}lie[i] = les;sort ( temp.begin(), temp.end(), cmp2 );for ( int j = 0; j < n; j++ )d[j + 1][i].m = temp[j].m;}for ( int i = 1; i <= n; i++ ){for ( int j = 0; j < m; j++ ){int a = max ( hang[i], lie[j] );int b = max ( d[i][j].y - d[i][j].m + lie[j], d[i][j].m - d[i][j].y + hang[i]  );cout << max (  a, b ) << ' ';}cout << endl;}}
}

题意:
构造一个kmp能查出来尽可能子串的串串。

题解:
找一个最大后缀,然后无限构造后缀;直到01不够用
最大的后缀,只需要看看kmp算法中next数组的最后一位是几,就可以了。
然后 对于next数组的位置,一直无限构造后缀,直到01不够用。

赛中突然就失忆了!!!
kmp突然就不会了 ,手突然就残了。

代码真漂亮啊 - -。。。。。。


#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int nex[maxn];
void getnext ( string &b )
{memset ( nex, 0, sizeof ( nex ) );for ( int i = 1, j = 0; b[i]; i++ ){while ( b[i] != b[j] && j > 0 )j = nex[j - 1];if ( b[i] == b[j] )nex[i] = j + 1, j++;}
}
int main()
{string a, b;while ( cin >> a >> b ){getnext ( b );int x = 0, y = 0;for ( int i = 0; a[i]; i++ )a[i] == '0' ? x++ : y++;string temp;char c;int len = b.size();int num = nex[len - 1], xe = 0, ye = 0, z = 1;for ( int i = 0;; ++i ,i = i == len ? num : i){if ( i < num && z )c = b[i];elsec = b[i], z = 0;c == '0' ? ++xe : ++ye;if ( xe > x || ye > y )break;temp += c;}while ( xe < x )temp += '0', xe++;while ( ye < y )temp += '1', ye++;cout << temp << endl;}
}

https://codeforces.com/contest/1138/problem/F

使用龟兔赛跑算法列出s和2*s。

所以 最后的证明是,(m-x) 是圈长的倍数,那么,当点再走(m-x) 步 ,最后则一定相遇。

#include <bits/stdc++.h>
using namespace std;int get()
{int t;cin>>t;string s;for( int i=0 ;i< t;i++){cin>>s;}return t;
}int main()
{while(1){cout<<"next 0 1"<<endl;get();cout<<"next 0"<<endl;if( get() != 3 )break;}while(1){cout<<"next 0 1 2 3 4 5 6 7 8 9 "<<endl;if(get()!=2) break;}cout<<"done"<<endl;
}

Codeforces Round #545 (Div. 2)相关推荐

  1. Codeforces Round #545 (div 1.)

    B.Camp Schedule 给两个 $01$ 串 $s$ 和 $t$,你可以将 $s$ 串任意重排,要求最大化 $t$ 在 $s$ 子串中出现的次数,可以重叠 $|s|,|t| \leq 5000 ...

  2. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  3. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  4. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  5. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  6. Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...

  7. Codeforces Round #701 (Div. 2) A ~ F ,6题全,超高质量良心题解【每日亿题】2021/2/13

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Add and Divide B - Replace and Keep Sorted C ...

  8. Codeforces Round #700 (Div. 2) D2 Painting the Array II(最通俗易懂的贪心策略讲解)看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 整场比赛的A ~ E 6题全,全部题目超高质量题解链接: Codeforces Round #700 ...

  9. Codeforces Round #699 (Div. 2) F - AB Tree(贪心、树上DP)超级清晰,良心题解,看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) F - AB Tree Problem ...

最新文章

  1. SQL记录-PLSQL异常
  2. 使用互斥体使程序只运行一个
  3. 尚硅谷_JavaScript_学习笔记
  4. python迭代器使用_python迭代器的使用方法实例
  5. Servlet读取文件的最好的方式
  6. javascript构造函数类和原型prototype定义的属性和方法的区别
  7. C语言程序设计(代码+知识点)
  8. 2019.08.30数组去重的几种方法以及所需时间对比
  9. ajax 的post方法用例(带循环)
  10. java更改安卓图标_java – 一个按钮的Android背景文本图标
  11. python库下载地址
  12. 《视觉SLAM十四讲》笔记
  13. mysql 命令行关闭fuw_网络管理 - eSight V300R009C00 维护指南 12 - 华为
  14. springboot kafka集成
  15. 微信内域名被多人投诉导致无法访问怎么办?
  16. CATIA V5 R24 2014安装教程
  17. 迅雷7 down.php,帝国CMS教程:教你如何添加迅雷下载
  18. Java Web中的一些概念(JSP、Servlet以及过滤器等)
  19. C++ vector去重 交集 并集
  20. USB gadget(1)----controller driver

热门文章

  1. java接口方式调用海康大华摄像机预览。
  2. nomasp 博客导读:Lisp/Emacs、Algorithm、Android
  3. 【Java面试】什么是字节码?采用字节码的好处是什么?
  4. NOIP学习之函数与过程抽象:91.质数的和与积
  5. 水晶报表 图表 百分比
  6. 奥利给!有了这么豪横的指南,还愁不会逛 GitHub?!
  7. LockSupport 以及 park、unpark 方法
  8. web前端面试宝典——带你直击面试重难点(40个经典题目,涵盖近90%的考点,码字2w,干货满满!)
  9. Pygame键盘输入和鼠标操作
  10. 增广拉格朗日函数法(ALM)