답안 #1023220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023220 2024-07-14T13:38:18 Z codefox 질문 (CEOI14_question_grader) C++14
컴파일 오류
0 ms 0 KB
#pragma GCC target("popcnt")   
    #pragma GCC optimize("Ofast")
    #include<bits/stdc++.h>
     
    int encode(int n, int a, int b)
        {
          int k = 0;
            int aa=0, bb=0;
            for (int j = 30; j < (1<<12); j++)
            {
                if (__builtin_popcount(j)==6)
                {
                    k++;
                    if (k==a) aa = j;
                    if (k==b) bb = j;
                }
            }
            for (int h = 0; h< 12; h++)
            {
                if ((aa&(1<<h)) && (bb&(1<<h)==0)) return h+1;
            }
        }
#pragma GCC optimize("popcnt")
    #pragma GCC optimize("Ofast")
    #include<bits/stdc++.h>
     
    int decode(int n, int q, int h) 
        {
          	h--;
            int k = 0;
            int qq=0
            for (int j = 30; j < (1<<12); j++)
            {
                if (__builtin_popcount(j)==6)
                {
                    k++;
                    if (k==q) qq = j;
                }
            }
            if (qq&(1<<h)) return true;
            return false;
        }

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:20:46: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   20 |                 if ((aa&(1<<h)) && (bb&(1<<h)==0)) return h+1;
      |                                        ~~~~~~^~~
encoder.cpp:22:9: warning: control reaches end of non-void function [-Wreturn-type]
   22 |         }
      |         ^

decoder.cpp:1:30: warning: bad option '-fpopcnt' to pragma 'optimize' [-Wpragmas]
    1 | #pragma GCC optimize("popcnt")
      |                              ^
decoder.cpp:5:35: warning: bad option '-fpopcnt' to attribute 'optimize' [-Wattributes]
    5 |     int decode(int n, int q, int h)
      |                                   ^
decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:10:13: error: expected ',' or ';' before 'for'
   10 |             for (int j = 30; j < (1<<12); j++)
      |             ^~~
decoder.cpp:10:30: error: 'j' was not declared in this scope
   10 |             for (int j = 30; j < (1<<12); j++)
      |                              ^
decoder.cpp:8:17: warning: unused variable 'k' [-Wunused-variable]
    8 |             int k = 0;
      |                 ^