답안 #24128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
24128 2017-05-31T11:11:51 Z ms990606 비교 (balkan11_cmp) C
19 / 100
2057 ms 82592 KB
#include "cmp.h"

void remember(int n) {
  int a[13],ans=0;
  for(int i=100;i<112;i++)
  {
    a[i]=( (n&(1<<(111-i))) > 0 ? 1 : 0);
    ans+=a[i];
  }
  if(ans>6)
  {
    bit_set(1);
    
    for(int i=100;i<112;i++)
    {
      if(a[i]==0) bit_set(i);
    }
  }
  else
  {
    for(int i=100;i<112;i++)
    {
      if(a[i]==1) bit_set(i);
    }
  }
  
}

int compare(int b) {
  int a=bit_get(1);
  int c,d;
  for(int i=0;i<12;i++)
  {
    	c=((b&(1<<(11-i)))?1:0);
    	d=bit_get(i+100);
    	if(a==1) d=1-d;
    	if(c>d) return 1;
    	if(c<d) return -1;
  }
  return 0;
}

Compilation message

cmp.c: In function 'remember':
cmp.c:7:6: warning: array subscript is above array bounds [-Warray-bounds]
     a[i]=( (n&(1<<(111-i))) > 0 ? 1 : 0);
     ~^~~
cmp.c:16:11: warning: array subscript is above array bounds [-Warray-bounds]
       if(a[i]==0) bit_set(i);
          ~^~~
cmp.c:23:11: warning: array subscript is above array bounds [-Warray-bounds]
       if(a[i]==1) bit_set(i);
          ~^~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2057 ms 82592 KB Output is partially correct - maxAccess = 19, score = 19