답안 #608842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
608842 2022-07-27T10:43:50 Z DeMen100ns Monster Game (JOI21_monster) C++17
컴파일 오류
0 ms 0 KB
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/

#include <monster.h>

namespace {
	const int N = 1005;
  
    bool f[N][N];
    int cnt[N];

};

std::vector<int> Solve(int n)
{
    memset(cnt, 0, sizeof cnt);

    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            f[i][j] = Query(i, j);
            cnt[i] += f[i][j];
            cnt[j] += (!f[i][j]);
        }
    }

    std::vector <int> ans(n);
    int luu01 = -1, luu02 = -1, luun1 = -1, luun2 = -1;
    for(int i = 0; i < n; ++i){
        if (cnt[i] > 1 && cnt[i] < n - 1){
            ans[i] = cnt[i];
        }
        if (cnt[i] == 1){
            if (luu01 == -1) luu01 = i;
            else luu02 = i;
        }
        if (cnt[i] == n - 2){
            if (luun1 == -1) luun1 = i;
            else luun2 = i;
        }
    }
    //0 1 2 3 4 5
    //1 1 2 3 4 4
    ans[luu01] = ans[luu02] = 1;
    if (f[luu01][luu02]) ans[luu01] = 0;
    else ans[luu02] = 0;

    ans[luun1] = ans[luun2] = n - 1;
    if (f[luun1][luun2]) ans[luun1] = n - 2;
    else ans[luun2] = n - 2;

    return ans;
}

Compilation message

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:19:5: error: 'memset' was not declared in this scope
   19 |     memset(cnt, 0, sizeof cnt);
      |     ^~~~~~
monster.cpp:8:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    7 | #include <monster.h>
  +++ |+#include <cstring>
    8 |