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 排座椅
  • 相关阅读:
    linux 安装 Chrome
    J2EE版本
    Java 源码解析之局部变量检查
    /etc/xinetd.conf 和 /etc/xinetd.d/*【新网络服务配置】
    Linux 内核编译
    linux 汇编
    /etc/ethers【地址映射】
    Linux LAMP 搭建
    Linux ftp 使用
    linux apache
  • 原文地址:https://www.cnblogs.com/lukelmouse/p/9709766.html
Copyright © 2011-2022 走看看