2011/11/04

Codeforces Beta Round #92(Div.2) report


This is Codeforces report after a long absence.

At first I decided to solve A. I misunderstanded it; 1WA.I resubmitted this at 00:08, and get Pretest Passed(and System test Passed).

I read B next, but it does not just occur to algorithm.Because there is no help for it, I move to C. However, Cdoes not understand meanings well either. Therefore Imoved to D when it was allocation of points same as C. D was good and understood a meaning, I took out graph paper and thought. I thought that it was the problem of a plus domain, the minus number domain, theimplementation was relatively comfortable when I was goodand thought. I submitted this at 1:08, and get Pretest Passed(and System test Passed).

I did not seem to be relieved of E, return chews it in C. I understood it , I got along well very much when I really crossed it.I submitted this at 1:35, and get Pretest Passed(and System test Passed).

o-oo-,Score:3130,Place:26/1458,Rating:1550->1666(Blue to Purple!) Problems are here.

[Prob.A(C,AC)]

#include<stdio.h>

int main(void){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  printf("%d\n",n-a<=b+1?n-a:b+1);
  return 0;
}


[Prob.C(C,AC)]

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

int prime(int n);

int main(void){
  int chara[26],num_p=1;
  char str[1024],maxc;
  int i,j,k,l,max=0;
 
  memset(chara,0,sizeof(chara));
  scanf("%s",str);
  l=strlen(str);
  for(i=0;i<l;i++) chara[str[i]-'a']++;

  for(i=l/2;i<l;i++) num_p+=prime(i+1);
  for(i=0;i<26;i++){
    if(max<chara[i]){
      max=chara[i];
      maxc='a'+i;
    }
  }
  if(max<l-num_p){
    puts("NO");
    return 0;
  }
  puts("YES");
  for(i=1;i<=l;i++){
    if(i==1 || (prime(i)==1 && 2*i>l)){
      for(j=0;j<26;j++){
if(j==maxc-'a') continue;
if(chara[j]==0) continue;
putchar('a'+j);
chara[j]--;
break;
      }
      if(j==26){
putchar(maxc);
chara[maxc-'a']--;
      }
    }else{
      putchar(maxc);
      chara[maxc-'a']--;
    }
  }
  putchar('\n');
  return 0;
}

int prime(int n){
  int i;
  if(n!=2 && n%2==0) return 0;
  if(n==1) return 0;
  if(n==2) return 1;
  for(i=3;i<n/2;i+=2) if(n%i==0) return 0;
  return 1;
}


[Prob.D(C,AC)]

#include<stdio.h>
#define MAX(x,y) (((x)>(y))?(x):(y))
#define ABS(x) (((x)<0)?(-(x)):(x))

int getagroup(int x,int y,int num);
int getbgroup(int x,int y,int num);

int main(void){
  int a,b,x1,x2,y1,y2;
  int ga1,ga2,gb1,gb2;
  int difa,difb,ans;
  scanf("%d %d %d %d %d %d",&a,&b,&x1,&y1,&x2,&y2);
  ga1=getagroup(x1,y1,a);
  ga2=getagroup(x2,y2,a);
  gb1=getbgroup(x1,y1,b);
  gb2=getbgroup(x2,y2,b);
  difa=ABS(ga1-ga2);
  difb=ABS(gb1-gb2);
  ans=MAX(difa,difb);
  printf("%d\n",MAX(difa,difb));
  return 0;
}

int getagroup(int x,int y,int num){
  int n;
  n=x+y;
  if(n>=0) n/=(2*num);
  else{
    n/=(2*num);
    n--;
  }
  return n;
}

int getbgroup(int x,int y,int num){
  int n;
  n=x-y;
  if(n>=0) n/=(2*num);
  else{
    n/=(2*num);
    n--;
  }
  return n;
}



0 件のコメント:

コメントを投稿