Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

ac,附代码,168K 16MS

Posted by liduoldbiubiubiu at 2020-01-16 11:36:48 on Problem 1029
#include <stdio.h>
#include <iostream>
using namespace std;
char cs[1001];//unknown,equal,light,heavy
int w[10001];
bool w_cs[1001];
int main(){
    int c_num;
    scanf ("%d",&c_num);
    for(int i=0;i<=c_num;i++){
        cs[i]='u';
    }
    int w_num;
    scanf ("%d",&w_num);
    for(int i = 0;i<w_num;i++){
        int num_side;
        scanf ("%d",&num_side);
        memset(w_cs,false,sizeof(w_cs));
        for(int i=1;i<=num_side*2;i++){
            int c;
            scanf ("%d",&c);
            w[i]=c;
            w_cs[c]=true;
        }
        char res;
        cin>>res;
        if(res=='<' || res=='>'){
            int light_begin,ligth_end,heavy_begin,heavy_end;
            if(res=='<'){
                light_begin=1;ligth_end=num_side;
                heavy_begin=num_side+1;heavy_end=num_side*2;
            }else{
                light_begin=num_side+1;ligth_end=num_side*2;
                heavy_begin=1;heavy_end=num_side;
            }
            //light
            for(int i=light_begin;i<=ligth_end;i++){
                int c = w[i];
                char old = cs[c];
                if(old=='u'){
                    cs[c]='l';
                }else if(old=='e'){
                }else if(old=='l'){
                }else{//h
                    cs[c]='e';
                }
            }
            //heavy
            for(int i=heavy_begin;i<=heavy_end;i++){
                int c = w[i];
                char old = cs[c];
                if(old=='u'){
                    cs[c]='h';
                }else if(old=='e'){
                }else if(old=='l'){
                    cs[c]='e';
                }else{//h
                }
            }
            for(int n=1;n<=c_num;n++){
                if(!w_cs[n]){
                    cs[n]='e';
                }
            }
        }else{//=
            for(int i=1;i<=num_side*2;i++){
                int c = w[i];
                cs[c]='e';
            }
        }
    }
    int fcn=0;
    int fc=0;
    for(int i=1;i<=c_num;i++){
        if(cs[i]!='e'){
            fcn++;
            fc=i;
        }
        if(fcn > 1){
            fc=0;
            break;
        }

    }
    printf("%d",fc);

    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator