제출 #788903

#제출 시각아이디문제언어결과실행 시간메모리
788903Boas길고양이 (JOI20_stray)C++17
컴파일 에러
0 ms0 KiB
#include "Anthony.h" #include <bits/stdc++.h> namespace { int a, m; } using namespace std; typedef vector<vector<int>> vvi; typedef vector<int> vi; void doStuff(const bool &debug, const int &i, const vi &arr, const int &j, const int &mark, vi &lijn, vi &X, const vi &graad, vvi &lijnen, queue<tuple<int, int, vector<int>>> &q) { if (debug) cerr << "Road from " << i << " to " << arr[j] << " gets mark " << mark << endl; X[j] = mark; if (a == 2 && graad[i] != 2) { if (lijn.size() >= 4) { lijnen.push_back(lijn); } lijn.clear(); } if (a != 2 || (graad[i] != 2 && graad[arr[j]] != 2)) { q.push({arr[j], (mark - 1 + a) % a, lijn}); } else { vi newLijn(lijn); newLijn.push_back(j); q.push({arr[j], (mark - 1 + a) % a, newLijn}); } } vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V, bool debug = false) { a = A; m = M; vector<int> X(M, -1); vector<int> graad(N); for (int i : U) graad[i]++; for (int i : V) graad[i]++; queue<tuple<int, int, vector<int>>> q; q.push({0, A - 1, {}}); vector<vi> lijnen; while (!q.empty()) { auto [i, mark, lijn] = q.front(); q.pop(); bool isEnd = true; for (int j = 0; j < m; j++) { if (X[j] != -1) continue; if (U[j] == i) { isEnd = false; doStuff(debug, i, V, j, mark, lijn, X, graad, lijnen, q); } else if (V[j] == i) { isEnd = false; doStuff(debug, i, U, j, mark, lijn, X, graad, lijnen, q); } } if (A == 2 && isEnd && lijn.size() >= 4) lijnen.push_back(lijn); } vi pattern = {0, 0, 1, 0, 1, 1}; for (const auto &lijn : lijnen) { if (lijn.size() < 4) continue; int d = 0; while (X[lijn[0]] != pattern[(d) % 6] || X[lijn.back()] != pattern[(d + lijn.size() - 1) % 6]) { d++; if (d > 1000) { break; } } for (uint32_t i = 0; i < lijn.size(); i++) { int mark = pattern[(i + d) % 6]; if (debug) cerr << "Lijn van " << U[lijn[i]] << " naar " << V[lijn[i]] << " krijgt mark " << mark << endl; X[lijn[i]] = mark; } } return X; }
#include "Catherine.h" #include <vector> #include <map> #include <iostream> using namespace std; typedef vector<int> vi; namespace { vi prevMarks; int A, B; int prevMark = -1; } // namespace void Init(int A, int B) { ::A = A; ::B = B; prevMarks.clear(); prevMark = -1; } int calculateMove(vi &y) { vector<int> leastOccurences = {}; int least = (1 << 30); map<int, int> occurences; if (A == 2 && prevMark != -1) { y[prevMark]++; } for (int j = 0; j < A; ++j) { if (y[j] > 0) { if (y[j] < least) { least = y[j]; leastOccurences = {j}; } else if (y[j] == least) { leastOccurences.push_back(j); } occurences[j] = y[j]; } } if (A > 2) { if (occurences.find(A - 1) != occurences.end() && occurences.find(0) != occurences.end()) { return 0; } int max = 0; for (const auto &[j, c] : occurences) { max = std::max(j, max); } return max; } if (leastOccurences.size() == 0) { throw; return -1; } if (leastOccurences.size() == 1) { if (leastOccurences[0] == prevMark && y[leastOccurences[0]] == 1) { prevMarks.clear(); return -1; } return leastOccurences[0]; } if (leastOccurences.size() == 2) { // extra code for long straight lines with A = 2 for (int i : leastOccurences) { if (i != prevMark) // when prevMark == -1, the 0 size is chosen return i; } } throw; } int Move(vi y) { int sum = 0; for (int v : y) sum += v; int mark = calculateMove(y); if (A == 2 && sum == 1) { prevMarks.push_back(mark); int s = prevMarks.size(); if (s > 3) { const vector<vi> turnAroundMarks = { {0, 0, 1, 0}, {0, 1, 0, 1}, {1, 0, 1, 1}, {1, 1, 0, 0}}; for (const auto &seq : turnAroundMarks) { for (int d = 0; d <= (int)turnAroundMarks.size() - 4; d++) { bool allEqual = true; for (int i = 0; i < 4; i++) { if (seq[i] != prevMarks[i + d]) { allEqual = false; break; } } if (allEqual) { prevMarks.clear(); return prevMark = -1; } } } } } else prevMarks.clear(); return prevMark = mark; }

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

/usr/bin/ld: /tmp/cck4thRx.o: in function `main':
grader_anthony.cpp:(.text.startup+0x191): undefined reference to `Mark(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status