답안 #129224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129224 2019-07-11T21:09:53 Z mraron 질문 (CEOI14_question_grader) C++14
컴파일 오류
0 ms 0 KB
#include<vector>
using namespace std;
vector<int> sts;
int init=-1;
int encode (int n, int x, int y) {
	if(init==-1) {
    	init=1;
    	vector<int> sts;
    	for(int i=0;i<(1<<12);++i) {
	        int cnt=0;
	        for(int j=0;j<12;++j) {
              	cnt+=((1<<j)&i)!=0;
        	}
        	if(cnt==6) sts.push_back(i);
    	}
    }
  
  	int X=sts[x], Y=sts[Y];
  	int h=-1;
  	for(int j=0;j<12;++j) {
	    if((X&(1<<j)) && !(Y&(1<<j))) h=j+1;
  	}
  
  	return h;
}

#include<vector>
using namespace std;
vector<int> sts;
int init=-1;
int decode (int n, int q, int h) {
	if(init==-1) {
    	init=1;
    	vector<int> sts;
    	for(int i=0;i<(1<<12);++i) {
	        int cnt=0;
	        for(int j=0;j<12;++j) {
	            cnt+=((1<<j)&i)!=0;
        	}
	        if(cnt==6) sts.push_back(i);
    	}
    }
  
  	return (sts[q]&(1<<(h-1))>0;

}

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:18:25: warning: 'Y' may be used uninitialized in this function [-Wmaybe-uninitialized]
    int X=sts[x], Y=sts[Y];
                         ^

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:18:29: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    return (sts[q]&(1<<(h-1))>0;
                   ~~~~~~~~~~^~
decoder.cpp:18:31: error: expected ')' before ';' token
    return (sts[q]&(1<<(h-1))>0;
                               ^