답안 #829782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829782 2023-08-18T15:00:10 Z Blagoj 길고양이 (JOI20_stray) C++17
0 / 100
26 ms 14856 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 + 2];
	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;
string path;
bool wrong;
set<string> valid, invalid;
vector<string> vl, ivl;
int last;
}  // namespace


void Init(int A, int B) {
    ::A = A;
    ::B = B;
    vl = {"11010", "10100", "01001", "10011", "00110", "01101"};
    ivl = {"00101", "10010", "11001", "01100", "10110", "01011"};
    for (auto x : vl) valid.insert(x);
    for (auto x : ivl) invalid.insert(x);
    path = "";
    went = 0;
    wrong = 0;
    last = -1;
}

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

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:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i = 0; i < y.size(); i++) {
      |                     ~~^~~~~~~~~~
Catherine.cpp:59:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for (int i = 0; i < y.size(); i++) {
      |                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 14856 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 14856 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 12648 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 12648 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 896 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 10976 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 11044 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -