当前位置:编程学习 > C/C++ >>

poj 4451 Dressing 一个小模拟 金华regional

cou[],cou1[]分别记录clothes 和shoe的重复次数,自己花一下图就好啦
[cpp] 
#include<iostream> 
#include<cstdio> 
#include<memory.h> 
#define M 1005 
using namespace std; 
char a[20],b[20]; 
int cou[M],te[M][M],te1[M][M],cou1[M]; 
int main(){ 
 //   freopen("in.txt","r",stdin); 
    int n,m,k,p,x,y; 
//    printf("%d\n",(1<<31)); 
    while(~scanf("%d%d%d",&n,&m,&k),n+m+k){ 
        scanf("%d",&p); 
        memset(cou,0,sizeof(cou)); 
        memset(cou1,0,sizeof(cou1)); 
        for(int i=0;i<=1000;i++) 
            for(int j=0;j<=1000;j++) 
                {te[i][j]=0;te1[i][j]=0;} 
        int sum=n*m*k; 
        while(p--){ 
            scanf("%s%d%s%d",a,&x,b,&y); 
            if(a[0]=='c'){ 
                if(te[x][y]==0){ 
                    cou[y]++; 
                    sum-=k; 
                    sum+=cou1[y]; 
                    te[x][y]=1;//去重 
                } 
            } 
            if(a[0]=='p'){ 
                if(te1[x][y]==0){ 
                    cou1[x]++; 
                    sum-=n; 
                    sum+=cou[x]; 
                    te1[x][y]=1;//去重 
                } 
            } 
        } 
        printf("%d\n",sum); 
    } 

 

补充:软件开发 , C++ ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,