zoukankan      html  css  js  c++  java
  • P1056 排座椅

    题目需要好好理解,

    要认真仔细的读题,

    我犯了一个比较严重的错误。。。

    用下标去和人数比了,扣了50分,半天不知道哪里错。。无语

    幸亏有大佬指出来了。

    P1056 排座椅  https://www.luogu.org/problemnew/show/P1056

    附上辣鸡代码

     1 #include<iostream>
     2 #include<algorithm>
     3 #include<cstdio>
     4 #include<cstring>
     5 #include<vector>
     6 
     7 using namespace std;
     8 const int NUM=2000;
     9 int row[NUM],col[NUM];
    10 bool cmp(const int x,const int y){
    11     return x>y;
    12 }
    13 int main()
    14 {
    15     int M,N,K,L,D;
    16     while(scanf("%d%d%d%d%d",&M,&N,&K,&L,&D)!=EOF){
    17         vector<int> vr,vc;
    18         memset(row,0,sizeof(row));
    19         memset(col,0,sizeof(col));
    20         int t1,t2,t3,t4;
    21         for(int i=0;i<D;i++){
    22             scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
    23             if(t1==t3){
    24                 if(t2<t4) col[t2]++;
    25                 else col[t4]++;
    26             }
    27             else if(t2==t4){
    28                 if(t1>t3) row[t3]++;
    29                 else row[t1]++;
    30             }
    31         }
    32         for(int i=0;i<K;i++){
    33             int maxi=0,go=0;
    34             for(int j=0;j<M;j++){
    35                 if(row[j]>maxi) {
    36                     maxi=row[j];
    37                     go=j;
    38                 }
    39             }
    40             row[go]=0;
    41             vr.push_back(go);
    42         }
    43         for(int i=0;i<L;i++){
    44             int maxi=0,go=0;
    45             for(int j=0;j<N;j++){
    46                 if(col[j]>maxi){
    47                     maxi=col[j];
    48                     go=j;
    49                 }
    50             }
    51             
    52             col[go]=0;
    53             vc.push_back(go);
    54         }
    55         sort(vr.begin(),vr.end());
    56         sort(vc.begin(),vc.end());
    57         for(int i=0;i<K-1;i++) printf("%d ",vr[i]);
    58         printf("%d\n",vr[K-1]);
    59         for(int i=0;i<L-1;i++) printf("%d ",vc[i]);
    60         printf("%d\n",vc[L-1]);
    61     }
    62     return 0;
    63 }
    P1056 排座椅
  • 相关阅读:
    高斯消元
    逻辑运算符之优先级&&and、or
    康托展开
    关于bootstrap的双层遮罩问题
    写好页面在内网内访问
    swiper插件的一些坑
    第一篇博客
    poj 3415 Common Substrings
    poj 1509 Glass Beads
    poj 3260 The Fewest Coins
  • 原文地址:https://www.cnblogs.com/lukelmouse/p/9709766.html
Copyright © 2011-2022 走看看