제출 #262885

#제출 시각아이디문제언어결과실행 시간메모리
262885dolphingarlicMeandian (CEOI06_meandian)C++14
100 / 100
6 ms256 KiB
#include "libmean.h"
#include <bits/stdc++.h>
using namespace std;

int ans[100], c[5];

int main() {
    int n = Init();
    fill(ans, ans + n, -1);
    queue<int> cand;
    for (int i = 1; i <= n; i++) cand.push(i);
    while (cand.size() > 4) {
        for (int i = 0; i < 5; i++) {
            c[i] = cand.front();
            cand.pop();
        }
        map<int, vector<int>> occ;
        occ[Meandian(c[0], c[1], c[2], c[3])].push_back(c[4]);
        occ[Meandian(c[0], c[1], c[2], c[4])].push_back(c[3]);
        occ[Meandian(c[0], c[1], c[3], c[4])].push_back(c[2]);
        occ[Meandian(c[0], c[2], c[3], c[4])].push_back(c[1]);
        occ[Meandian(c[1], c[2], c[3], c[4])].push_back(c[0]);
        int found, val = 0;
        for (pair<int, vector<int>> i : occ) {
            if (i.second.size() == 1) {
                found = i.second[0];
                val -= i.first;
            } else val += i.first;
        }
        ans[found - 1] = val;
        for (int i = 0; i < 5; i++) if (c[i] != found) cand.push(c[i]);
    }
    Solution(ans);
}

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

meandian.cpp: In function 'int main()':
meandian.cpp:30:19: warning: 'found' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |         ans[found - 1] = val;
      |             ~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...