제출 #389420

#제출 시각아이디문제언어결과실행 시간메모리
389420quickn앵무새 (IOI11_parrots)C++14
컴파일 에러
0 ms0 KiB
using namespace std; typedef long long i64; const int MAX_LENGTH = 40; vector<pair<int, int>> list(N, make_pair(0, 0)); for (int i = 0; i < N; i++) { list[i] = make_pair(M[i], i); } vector<i64> msg_block; for (int i = 0; i < N/8; i++) { i64 msg = 0; for (int j = 0; j < 8; j++) { msg = msg*256 + static_cast<i64>(list[i*8 + j].first); } msg_block.push_back(msg); } i64 msg = 0; for (int i = 8*(N/8); i < N; i++) { msg = msg*256 + static_cast<i64>(list[i].first); } if (N % 8 != 0) msg_block.push_back(msg); vector<vector<i64>> dp(MAX_LENGTH, vector<i64>(32, 0)); for (int j = 0; j < 32; j++) dp[0][j] = 1; for (int i = 1; i < MAX_LENGTH; i++) { for (int j = 0; j < 32; j++) if (j > 0) dp[i][j] = dp[i-1][j] + dp[i][j-1]; else dp[i][j] = dp[i-1][j]; } int cnt = 0; vector<int> q; for (auto msg: msg_block) { i64 m = msg; int i = MAX_LENGTH-1; int j = 30; vector<int> arr; while (i >= 0) { bool non = false; while (m > 0 && j > 0) { if (dp[i][j-1] == m) { m -= dp[i][j-1]; arr.push_back(j); non = true; break; } else if (dp[i][j-1] < m) { m -= dp[i][j-1]; arr.push_back(j+1); non = true; break; } j--; } if (!non) { arr.push_back(0); } i--; } for (auto a: arr) { send(cnt*32 + a); } cnt += 1; }
using namespace std; typedef long long i64; const int MAX_LENGTH = 40; vector<vector<i64>> dp(MAX_LENGTH, vector<i64>(32, 0)); for (int j = 0; j < 32; j++) dp[0][j] = 1; for (int i = 1; i < MAX_LENGTH; i++) { for (int j = 0; j < 32; j++) if (j > 0) dp[i][j] = dp[i-1][j] + dp[i][j-1]; else dp[i][j] = dp[i-1][j]; } vector<vector<int>> recover(static_cast<int>(ceil(static_cast<long double>(N)/8.0))); for (int i = 0; i < L; i++) { recover[X[i] / 32].push_back(X[i] % 32); } for (int i = 0; i < recover.size(); i++) { sort(recover[i].begin(), recover[i].end(), greater<int>()); i64 nth = 0; for (int j = 0; j < recover[i].size(); j++) { if (recover[i][j] == 0) break; if (j == recover[i].size()-1 || recover[i][j+1] == 0) { nth += dp[recover[i].size()-j-1][recover[i][j]-1]; } else { nth += dp[recover[i].size()-j-1][recover[i][j]-2]; } } vector<int> out; if (i == recover.size()-1 && N % 8 != 0) { for (int j = 8*(N/8); j < N; j++) { out.push_back(nth % 256); nth /= 256; } } else { for (int j = 0; j < 8; j++) { out.push_back(nth % 256); nth /= 256; } } for (int j = out.size()-1; j >= 0; j--) output(out[j]);// out[j] << " "; }

컴파일 시 표준 에러 (stderr) 메시지

encoder.cpp:6:5: error: 'vector' does not name a type
    6 |     vector<pair<int, int>> list(N, make_pair(0, 0));
      |     ^~~~~~
encoder.cpp:7:2: error: expected unqualified-id before 'for'
    7 |  for (int i = 0; i < N; i++) {
      |  ^~~
encoder.cpp:7:18: error: 'i' does not name a type
    7 |  for (int i = 0; i < N; i++) {
      |                  ^
encoder.cpp:7:25: error: 'i' does not name a type
    7 |  for (int i = 0; i < N; i++) {
      |                         ^
encoder.cpp:10:5: error: 'vector' does not name a type
   10 |     vector<i64> msg_block;
      |     ^~~~~~
encoder.cpp:11:5: error: expected unqualified-id before 'for'
   11 |     for (int i = 0; i < N/8; i++) {
      |     ^~~
encoder.cpp:11:21: error: 'i' does not name a type
   11 |     for (int i = 0; i < N/8; i++) {
      |                     ^
encoder.cpp:11:30: error: 'i' does not name a type
   11 |     for (int i = 0; i < N/8; i++) {
      |                              ^
encoder.cpp:19:5: error: expected unqualified-id before 'for'
   19 |     for (int i = 8*(N/8); i < N; i++) {
      |     ^~~
encoder.cpp:19:27: error: 'i' does not name a type
   19 |     for (int i = 8*(N/8); i < N; i++) {
      |                           ^
encoder.cpp:19:34: error: 'i' does not name a type
   19 |     for (int i = 8*(N/8); i < N; i++) {
      |                                  ^
encoder.cpp:22:5: error: expected unqualified-id before 'if'
   22 |     if (N % 8 != 0)
      |     ^~
encoder.cpp:24:5: error: 'vector' does not name a type
   24 |     vector<vector<i64>> dp(MAX_LENGTH, vector<i64>(32, 0));
      |     ^~~~~~
encoder.cpp:25:5: error: expected unqualified-id before 'for'
   25 |     for (int j = 0; j < 32; j++)
      |     ^~~
encoder.cpp:25:21: error: 'j' does not name a type
   25 |     for (int j = 0; j < 32; j++)
      |                     ^
encoder.cpp:25:29: error: 'j' does not name a type
   25 |     for (int j = 0; j < 32; j++)
      |                             ^
encoder.cpp:27:5: error: expected unqualified-id before 'for'
   27 |     for (int i = 1; i < MAX_LENGTH; i++) {
      |     ^~~
encoder.cpp:27:21: error: 'i' does not name a type
   27 |     for (int i = 1; i < MAX_LENGTH; i++) {
      |                     ^
encoder.cpp:27:37: error: 'i' does not name a type
   27 |     for (int i = 1; i < MAX_LENGTH; i++) {
      |                                     ^
encoder.cpp:35:5: error: 'vector' does not name a type
   35 |     vector<int> q;
      |     ^~~~~~
encoder.cpp:36:5: error: expected unqualified-id before 'for'
   36 |     for (auto msg: msg_block) {
      |     ^~~

decoder.cpp:6:9: error: 'vector' does not name a type
    6 |         vector<vector<i64>> dp(MAX_LENGTH, vector<i64>(32, 0));
      |         ^~~~~~
decoder.cpp:7:5: error: expected unqualified-id before 'for'
    7 |     for (int j = 0; j < 32; j++)
      |     ^~~
decoder.cpp:7:21: error: 'j' does not name a type
    7 |     for (int j = 0; j < 32; j++)
      |                     ^
decoder.cpp:7:29: error: 'j' does not name a type
    7 |     for (int j = 0; j < 32; j++)
      |                             ^
decoder.cpp:9:5: error: expected unqualified-id before 'for'
    9 |     for (int i = 1; i < MAX_LENGTH; i++) {
      |     ^~~
decoder.cpp:9:21: error: 'i' does not name a type
    9 |     for (int i = 1; i < MAX_LENGTH; i++) {
      |                     ^
decoder.cpp:9:37: error: 'i' does not name a type
    9 |     for (int i = 1; i < MAX_LENGTH; i++) {
      |                                     ^
decoder.cpp:16:5: error: 'vector' does not name a type
   16 |     vector<vector<int>> recover(static_cast<int>(ceil(static_cast<long double>(N)/8.0)));
      |     ^~~~~~
decoder.cpp:17:5: error: expected unqualified-id before 'for'
   17 |     for (int i = 0; i < L; i++) {
      |     ^~~
decoder.cpp:17:21: error: 'i' does not name a type
   17 |     for (int i = 0; i < L; i++) {
      |                     ^
decoder.cpp:17:28: error: 'i' does not name a type
   17 |     for (int i = 0; i < L; i++) {
      |                            ^
decoder.cpp:20:5: error: expected unqualified-id before 'for'
   20 |     for (int i = 0; i < recover.size(); i++) {
      |     ^~~
decoder.cpp:20:21: error: 'i' does not name a type
   20 |     for (int i = 0; i < recover.size(); i++) {
      |                     ^
decoder.cpp:20:41: error: 'i' does not name a type
   20 |     for (int i = 0; i < recover.size(); i++) {
      |                                         ^