제출 #1071102

#제출 시각아이디문제언어결과실행 시간메모리
1071102PlurmAncient Machine (JOI21_ancient_machine)C++17
0 / 100
76 ms16892 KiB
#include "Anna.h"
#include <vector>

namespace {

int variable_example = 0;

}

void Anna(int N, std::vector<char> S) {
    for (int i = 0; i < N; i++) {
        if (S[i] == 'X') {
            Send(0);
        } else if (S[i] == 'Y') {
            Send(1);
            Send(0);
        } else {
            Send(1);
            Send(1);
        }
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
void dfs1(vector<vector<int>> &g, vector<int> &col, vector<int> &stk, int u) {
    if (col[u])
        return;
    col[u] = -1;
    for (int v : g[u]) {
        dfs1(g, col, stk, v);
    }
    stk.push_back(u);
}
void dfs2(vector<vector<int>> &rg, vector<int> &col, int cc, int u) {
    if (col[u] >= 0)
        return;
    col[u] = cc;
    for (int v : rg[u]) {
        dfs2(rg, col, cc, v);
    }
}
vector<int> get_scc(vector<vector<int>> g) {
    vector<vector<int>> rg(g.size());
    for (int i = 0; i < g.size(); i++) {
        for (int j : g[i])
            rg[j].push_back(i);
    }
    vector<int> col(g.size(), 0);
    vector<int> stk;
    for (int i = 0; i < g.size(); i++)
        dfs1(g, col, stk, i);
    int ccnt = 0;
    while (!stk.empty()) {
        int u = stk.back();
        stk.pop_back();
        if (col[u] == -1)
            dfs2(rg, col, ccnt++, u);
    }
    return col;
}
} // namespace

void Bruno(int N, int L, std::vector<int> A) {
    string target;
    int ptr = 0;
    while (ptr < L) {
        if (A[ptr++] == 0)
            target.push_back('X');
        else if (A[ptr++] == 0)
            target.push_back('Y');
        else
            target.push_back('Z');
    }
    vector<vector<int>> g(N);
    for (int i = 0; i < N; i++) {
        if (target[i] != 'Y')
            continue;
        int x = -1;
        for (int j = i - 1; j >= 0; j--) {
            if (target[j] == 'X') {
                x = j;
                break;
            }
        }
        int z = N;
        for (int j = i + 1; j < N; j++) {
            if (target[j] == 'Z') {
                z = j;
                break;
            }
        }
        for (int j = x + 1; j < z; j++) {
            if (j == i)
                continue;
            g[j].push_back(i);
        }
    }
    vector<int> sccnum = get_scc(g);
    vector<int> ord(N);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(),
         [&sccnum](int x, int y) { return sccnum[x] > sccnum[y]; });
    for (int x : ord)
        Remove(x);
}

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

Anna.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    6 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~

Bruno.cpp: In function 'std::vector<int> {anonymous}::get_scc(std::vector<std::vector<int> >)':
Bruno.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 0; i < g.size(); i++) {
      |                     ~~^~~~~~~~~~
Bruno.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < g.size(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...