답안 #1089535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089535 2024-09-16T16:01:59 Z Error42 Trobojnica (COCI19_trobojnica) C++17
컴파일 오류
0 ms 0 KB
#include <array>
#include <iostream>
#include <vector>

using namespace std;

struct node {
    int color;
    int lower;
    node* prev;
    node* next;
};

struct diag {
    int a, b, color;
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    string s;
    cin >> s;

    vector<node> nodes(n);
    vector<node*> next_different;

    array<int, 3> cnts = { 0, 0, 0 };

    for (int i = 0; i < n; i++) {
        nodes[i].color = (s[i] - '0') % 3;
        nodes[i].lower = i;

        cnts[nodes[i].color]++;

        nodes[i].prev = &nodes[i > 0 ? i - 1 : n - 1];
        nodes[i].next = &nodes[i + 1 < n ? i + 1 : 0];
    }

    if (count(cnts.begin(), cnts.end(), n) || cnts[0] % 2 != n % 2 || cnts[1] % 2 != n % 2 || cnts[2] % 2 != n % 2) {
        cout << "NE\n";
        return 0;
    }

    int node_cnt = n;

    vector<diag> diagonals(n - 3, { 1, 1, 1 });

    while (node_cnt > 3) {
        // TODO

        node_cnt--;
    }

    cout << "DA\n";

    for (auto const& [a, b, c] : diagonals) {
        cout << a << " " << b << " " << c << "\n";
    }
}

Compilation message

trobojnica.cpp: In function 'int main()':
trobojnica.cpp:43:9: error: 'count' was not declared in this scope
   43 |     if (count(cnts.begin(), cnts.end(), n) || cnts[0] % 2 != n % 2 || cnts[1] % 2 != n % 2 || cnts[2] % 2 != n % 2) {
      |         ^~~~~