2011/08/14

Codeforces Beta Round #81 report

It's too bad!

I read Problem-A, first. I solve this, and test first at 0:20.
However, I notice lexicographical order. So, I make sort. Submit at 0:35. And System test, there is round-off error. I'm wrong!

Other problems, I gave up because...
1. It's difficult for me!
2. The problem is too long! I'm not good at English, so it's hard.

Then, Score=0. Rank=403/1500. Problems are here.
No people could solve all problems, and about 1100 people couldn't solve any problem.
I think, this round is difficult.

A.(wrong)

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct {
  char name[21];
  int level;
} skills;

void ssort(skills skill[],int size);

int main(void){
  short n,m;
  char str[21];
  double k;
  skills skill[40];
  int i,j,l,c=0,flg;
  scanf("%hd %hd %lf",&n,&m,&k);
  for(i=0;i<n;i++){
    scanf("%s %d",skill[i].name,&skill[i].level);
    skill[i].level*=k;
    if(skill[i].level<100) skill[i].level=-1;
    else c++;
  }
  l=n;
  for(i=0;i<m;i++){
    scanf("%s",str);
    flg=0;
    for(j=0;j<l;j++){
      if(strcmp(str,skill[j].name)==0){
if(skill[j].level<0){
 c++;
 skill[j].level=0;
}
flg=1;
break;
      }
    }
    if(flg==1) continue;
    strcpy(skill[l].name,str);
    skill[l++].level=0;
    c++;
  }
  ssort(skill,l);
  printf("%d\n",c);
  for(i=0;i<l;i++){
    if(skill[i].level<0) continue;
    printf("%s %d\n",skill[i].name,skill[i].level);
  }
  return 0;
}

void ssort(skills skill[],int size){
  int i,j,place;
  skills tmp;
  for(i=0;i<size;i++){
    place=i;
    for(j=i+1;j<size;j++) if(strcmp(skill[place].name,skill[j].name)>0) place=j;
    tmp=skill[i];
    skill[i]=skill[place];
    skill[place]=tmp;
  }
}

0 件のコメント:

コメントを投稿