답안 #829728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829728 2023-08-18T14:35:29 Z Blagoj 길고양이 (JOI20_stray) C++17
0 / 100
33 ms 27348 KB
#include <bits/stdc++.h>
#include "Anthony.h"

namespace {

int FunctionExample(int i, int A) { return i % A; }

}  // namespace

using namespace std;

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
    vector<int> X(M);
	queue<pair<int, int>> q;
	q.push({0, 0});
	string s = "001011";
	vector<pair<int, int>> g[N];
	for (int i = 0; i < M; i++) {
		g[U[i]].push_back({V[i], i});
		g[V[i]].push_back({U[i], i});
	}
	bool visited[N + 2];
	memset(visited, 0, sizeof(visited));
	visited[0] = 1;
	while (q.size()) {
		int cur = q.front().first, clr = q.front().second;
		q.pop();
		for (auto [to, id] : g[cur]) {
			if (visited[to]) continue;
			visited[to] = 1;
			q.push({to, (clr + 1) % 6});
			// cout << id << " : " << clr << endl;
			X[id] = s[clr] - '0';
		}
	}
	// for (int i = 0; i < X.size(); i++) cout << U[i] << " " << V[i] << " : " << X[i] << endl;
    return X;
}
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;

namespace {

int A, B;
int went = 0;
string path;
bool wrong = 0;
set<string> valid, invalid;
vector<string> vl = {"11010", "10100", "01001", "10011", "00110", "01101"}, ivl = {"00101", "10010", "11001", "01100", "10110", "01011"};
}  // namespace


void Init(int A, int B) {
    ::A = A;
    ::B = B;
    for (auto x : vl) valid.insert(x);
    for (auto x : ivl) invalid.insert(x);
    path = "";
}

int Move(vector<int> y) {
    if (went && wrong) {
        went--;
        path.pop_back();
        return -1;
    }
    if (path.size() == 6) {
        path = path.substr(1);
    }
    wrong = 0;
    vector<pair<int, int>> total;
    for (int i = 0; i < y.size(); i++) {
        if (y[i]) total.push_back({y[i], i});
    }
    sort(total.begin(), total.end());
    went++;
    if (total.size() == 1 || total[0] < total[1]) {
        path += total[0].second;
        cout << total[0].first << " " << total[0].second << endl;
        return total[0].second;
    }
    if (path.size() + 1 == 5) {
        for (int i = 0; i < y.size(); i++) {
            if (y[i]) {
                string cur = path + to_string(i);
                if (invalid.count(cur)) {
                    wrong = 1;
                    went -= 2;
                    return -1;
                }
                if (valid.count(cur)) {
                    path += to_string(i);
                    return i;
                }
            }
        }
    }
}

Compilation message

Anthony.cpp:6:5: warning: 'int {anonymous}::FunctionExample(int, int)' defined but not used [-Wunused-function]
    6 | int FunctionExample(int i, int A) { return i % A; }
      |     ^~~~~~~~~~~~~~~

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < y.size(); i++) {
      |                     ~~^~~~~~~~~~
Catherine.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for (int i = 0; i < y.size(); i++) {
      |                         ~~^~~~~~~~~~
Catherine.cpp:34:28: warning: control reaches end of non-void function [-Wreturn-type]
   34 |     vector<pair<int, int>> total;
      |                            ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 27348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 27348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 22800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 22800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 33 ms 19344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 19492 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -