Codeforces Beta Round #59 (Div. 2)

http://codeforces.com/contest/63

A

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define eb emplace_back
  8. #define maxn 1000006
  9. #define rep(k,i,j) for(int k=i;k<j;k++)
  10. typedef long long ll;
  11. typedef unsigned long long ull;
  12.  
  13. struct sair{
  14. string name,v;
  15. }a[];
  16.  
  17. int main(){
  18. #ifndef ONLINE_JUDGE
  19. freopen("input.txt","r",stdin);
  20. #endif
  21. std::ios::sync_with_stdio(false);
  22. int n;
  23. cin>>n;
  24. rep(i,,n+){
  25. cin>>a[i].name>>a[i].v;
  26. }
  27. rep(i,,n+){
  28. if(a[i].v=="rat"){
  29. cout<<a[i].name<<endl;
  30. }
  31. }
  32. rep(i,,n+){
  33. if(a[i].v=="woman"||a[i].v=="child"){
  34. cout<<a[i].name<<endl;
  35. }
  36. }
  37. rep(i,,n+){
  38. if(a[i].v=="man"){
  39. cout<<a[i].name<<endl;
  40. }
  41. }
  42. rep(i,,n+){
  43. if(a[i].v=="captain"){
  44. cout<<a[i].name<<endl;
  45. }
  46. }
  47. }

B

暴力模拟即可

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define eb emplace_back
  8. #define maxn 1000006
  9. #define rep(k,i,j) for(int k=i;k<j;k++)
  10. typedef long long ll;
  11. typedef unsigned long long ull;
  12.  
  13. int n,k;
  14. int a[];
  15. int book[];
  16.  
  17. int main(){
  18. #ifndef ONLINE_JUDGE
  19. // freopen("input.txt","r",stdin);
  20. #endif
  21. std::ios::sync_with_stdio(false);
  22. cin>>n>>k;
  23. int ans=;
  24. rep(i,,n+){
  25. cin>>a[i];
  26. }
  27. a[]=-0x3f3f3f3f;
  28. sort(a,a+n+);
  29. int flag=;
  30. while(flag){
  31. flag=;
  32. rep(i,,n+){
  33. if(a[i]<k)
  34. if(a[i]!=a[i-]){
  35. book[i]++;
  36. flag=;
  37. }
  38. }
  39. rep(i,,n+) a[i]+=book[i],book[i]=;
  40. sort(a,a+n+);
  41. ans+=flag;
  42. }
  43. cout<<ans<<endl;
  44. }

C

枚举1-9999的数,然后一个个判断,看看有几个符合条件

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define eb emplace_back
  8. #define maxn 1000006
  9. #define rep(k,i,j) for(int k=i;k<j;k++)
  10. typedef long long ll;
  11. typedef unsigned long long ull;
  12.  
  13. int n;
  14. struct sair{
  15. int a,b,c;
  16. }q[];
  17.  
  18. int main(){
  19. #ifndef ONLINE_JUDGE
  20. // freopen("input.txt","r",stdin);
  21. #endif
  22. // std::ios::sync_with_stdio(false);
  23. cin>>n;
  24. rep(i,,n) {
  25. cin>>q[i].a>>q[i].b>>q[i].c;
  26. }
  27. int x,y,z;
  28. int ans,num=;
  29. rep(i,,){
  30. int tmp=i;
  31. int a,b,c,d;
  32. a=tmp%,tmp/=;
  33. b=tmp%,tmp/=;
  34. c=tmp%,tmp/=;
  35. d=tmp%;
  36. if(a==b||a==c||a==d||b==c||b==d||c==d) continue;
  37. int flag=;
  38. rep(j,,n){
  39. x=,y=,z;
  40. tmp=q[j].a;
  41. z=tmp%;
  42. if(a==z) x++;
  43. if(b==z) y++;
  44. if(c==z) y++;
  45. if(d==z) y++;
  46. tmp/=;
  47. z=tmp%;
  48. if(b==z) x++;
  49. if(a==z) y++;
  50. if(c==z) y++;
  51. if(d==z) y++;
  52. tmp/=;
  53. z=tmp%;
  54. if(c==z) x++;
  55. if(b==z) y++;
  56. if(a==z) y++;
  57. if(d==z) y++;
  58. tmp/=;
  59. z=tmp%;
  60. if(d==z) x++;
  61. if(b==z) y++;
  62. if(c==z) y++;
  63. if(a==z) y++;
  64. if(x!=q[j].b||y!=q[j].c){
  65. flag=;
  66. break;
  67. }
  68. }
  69. if(flag){
  70. num++;
  71. ans=i;
  72. }
  73. }
  74. if(num==) cout<<"Incorrect data"<<endl;
  75. else if(num==) printf("%04d\n",ans);
  76. else cout<<"Need more data"<<endl;
  77. }

D

通过多次模拟可以发现,只要走S形即可

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define eb emplace_back
  8. #define maxn 1000006
  9. #define rep(k,i,j) for(int k=i;k<j;k++)
  10. typedef long long ll;
  11. typedef unsigned long long ull;
  12.  
  13. int field[][];
  14.  
  15. int main(){
  16. #ifndef ONLINE_JUDGE
  17. // freopen("input.txt","r",stdin);
  18. #endif
  19. std::ios::sync_with_stdio(false);
  20. int a,b,c,d,n;
  21. cin >> a >> b >> c >> d >> n;
  22. for (int i=; i<; i++) {
  23. for (int j=; j<; j++) {
  24. field[i][j]=;
  25. }
  26. }
  27. int party[]={};
  28. for (int i=; i<n; i++) {
  29. cin >> party[i];
  30. }
  31. for (int i=; i<max(b,d); i++) {
  32. for (int j=; j<a+c; j++) {
  33. if ((j<a&&i>=b)||(j>=a&&i>=d))field[i][j]='.';
  34. }
  35. }
  36. int x=,y=,dx=;
  37. if (((b>d)&&(d%==))||((d>b)&&(b%==))){
  38. x=a+c-;dx=-;
  39. }
  40. for (int i=; i<n; i++) {
  41. for (int j=; j<party[i]; j++) {
  42. field[y][x]='a'+i;
  43. if (x+dx<||x+dx>=a+c||field[y][x+dx]=='.') {
  44. dx*=-;
  45. y++;
  46. } else {
  47. x+=dx;
  48. }
  49. }
  50. }
  51. cout << "YES" << endl;
  52. for (int i=; i<max(b,d); i++) {
  53. for (int j=; j<a+c; j++) {
  54. cout << char(field[i][j]);
  55. }
  56. cout << endl;
  57. }
  58.  
  59. }

E

一种类似博弈的题目,用状压表示每一种情况,然后搜索,找出Karlsson的必胜路径,找不到的话就是必败

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define eb emplace_back
  8. #define maxn 1000006
  9. #define rep(k,i,j) for(int k=i;k<j;k++)
  10. typedef long long ll;
  11. typedef unsigned long long ull;
  12.  
  13. const int N=,S=<<;
  14.  
  15. int Next[][N]={{,,,,,,,N,,,,,N,,,,N,N,N},
  16. {,,N,,,,N,,,,,N,,,,N,,,N},
  17. {,,,,,,,,,,,N,,,,N,N,N,N}};
  18.  
  19. int dp[S],status=;
  20.  
  21. int dfs(int now){
  22. if(dp[now]) return dp[now];
  23. rep(t,,){
  24. rep(i,,N){
  25. int tmp=now,p=i;
  26. while(tmp&(<<p)){
  27. tmp^=(<<p);
  28. if(dfs(tmp)==){
  29. return dp[now]=;
  30. }
  31. p=Next[t][p];
  32. }
  33. }
  34. }
  35. return dp[now]=;
  36. }
  37.  
  38. int main(){
  39. #ifndef ONLINE_JUDGE
  40. freopen("input.txt","r",stdin);
  41. #endif
  42. std::ios::sync_with_stdio(false);
  43. char ch;
  44. rep(i,,N){
  45. cin>>ch;
  46. if(ch=='.'||ch=='O'){
  47. if(ch=='O'){
  48. status+=(<<i);
  49. }
  50. }
  51. else{
  52. i--;
  53. }
  54. }
  55. int flag=dfs(status);
  56. if(flag==) cout<<"Karlsson"<<endl;
  57. else cout<<"Lillebror"<<endl;
  58. }

Codeforces Beta Round #59 (Div. 2)的更多相关文章

  1. Codeforces Beta Round #55 (Div. 2)

    Codeforces Beta Round #55 (Div. 2) http://codeforces.com/contest/59 A #include<bits/stdc++.h> ...

  2. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  5. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  8. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  9. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

随机推荐

  1. Firefox What's New 太难找了

    Firefox每次更新版本,不知道更新了什么,找不到Waht‘s New,做个记录! 1.点击mozilla下拉 2.最左侧 MOZILLA>SUPPORT>Firefox 3.https ...

  2. html to docx

    public static void main(String[] args) throws Exception{ //创建 POIFSFileSystem 对象 POIFSFileSystem poi ...

  3. WDA-5-VIEW视图切换

    这一部分介绍同一窗口下不同视图之间的链接跳转. 前提:完成上一步骤MAIN视图ALV显示. 1.效果展示 点击ALV物料下划线链接,页面跳转到物料明细页面. 2.实现过程 基于上一步骤在MAIN页面显 ...

  4. Win2008R2配置WebDeploy(转)

    一.配置服务器 1.安装管理服务 2.点击管理服务进行配置 3.安装WebDeploy 3.1通过离线安装包方式安装: https://www.iis.net/downloads/microsoft/ ...

  5. zookeeper windows7下集群搭建

    模拟分布式环境!!!  搞了好几天,各种错误!!终于成功了. 环境: windows7 /centos/xsheel    安装了三个虚拟机... 1.下载zookeeper http://archi ...

  6. Spring AOP demo 和获取被CGLIB代理的对象

    本文分为两部分:1)给出Spring AOP的一个例子(会使用CGLIB代理):2)给出获取被CGLIB代理的原始对象. 1.Spring AOP Demo 这部分参考了博文(http://www.v ...

  7. 转: JQuery this和$(this)的区别及获取$(this)子元素对象的方法

    1.JQuery this和$(this)的区别 相信很多刚接触JQuery的人,很多都会对$(this)和this的区别模糊不清,那么这两者有什么区别呢? 首先来看看JQuery中的  $()  这 ...

  8. 讲一讲Servlet和JSP的关系

    Test.jsp在运行时首先被解析成一个java类Test_jsp.java,该类继承于org.apache.jasper.runtime.HtppJspBase类,而Http又是继承HttpServ ...

  9. Android Studio 3.0.1 又见恶心爆的bug。。。xiete

    写了个AIDL的东西,结果一直编译不通过: Error:Execution failed for task ':app:compileDebugAidl'. > java.io.IOExcept ...

  10. 一个关于EasyUI超恶心的BUG。。。Cannot read property 'options' of undefined

    控制台Console抛出的异常: jquery.easyui.min.js:9148 Uncaught TypeError: Cannot read property 'options' of und ...