답안 #1063395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063395 2024-08-17T17:50:09 Z Andrey 길고양이 (JOI20_stray) C++14
컴파일 오류
0 ms 0 KB
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;

int A;
int seq[6] = {0,1,0,0,1,1};
vector<int> wow(0);
bool first = true;
bool yeah = true;

void Init(int a, int b) {
    A = a;
}

int Move(vector<int> haha) {
    if(A > 2) {
        vector<int> wow(0);
        for(int i = 0; i < haha.size(); i++) {
            if(haha[i] >= 1) {
                wow.push_back(i);
            }
        }
        if(wow.size() == 1) {
            return wow[0];
        }
        else if(wow.size() == 2) {
            if(wow[0] == 0 && wow[1] == 1) {
                return 0;
            }
            else if(wow[0] == 1 && wow[1] == 2) {
                return 1;
            }
            else {
                return 2;
            }
        }
    }
    else {
        if(first) {
            first = false;
            if(haha[1] > 0 && (haha[0] > 1 || haha[0] == 0)) {
                yeah = false;
                wow.push_back(1);
                return 1;
            }
            else if(haha[0] > 0 && (haha[1] == 0 || haha[1] > 1)) {
                yeah = false;
                wow.push_back(0);
                return 0;
            }
            else {
                wow.push_back(0);
                return 0;
            }
        }
        else {
            if(yeah) {
                if(haha[0]+haha[1] == 0) {
                    yeah = false;
                    return -1;
                }
                else if(haha[0]+haha[1] > 1) {
                    yeah = false;
                    if(haha[0] == 0 || haha[1] == 0) {
                        return -1;
                    }
                    else {
                        if(wow[wow.size()-1] == 1) {
                            wow.push_back(1);
                            return 0;
                        }
                        else {
                            wow.push_back(0);
                            return 1;
                        }
                    }
                }
                else if(wow.size() == 6) {
                    for(int i = 0; i < 6; i++) {
                        bool bubu = true;
                        for(int j = i; j < i+6; j++) {
                            if(seq[j-i] != wow[j%6]) {
                                bubu = false;
                            }
                        }
                        if(bubu) {
                            yeah = false;
                            break;
                        }
                    }
                    if(yeah) {
                        yeah = false;
                        return -1;
                    }
                    else {
                        if(haha[0] > 0) {
                            wow.push_back(0);
                            return 0;
                        }
                        else {
                            wow.push_back(1);
                            return 1;
                        }
                    }
                }
                else {
                    if(haha[0] > 0) {
                        wow.push_back(0);
                        return 0;
                    }
                    else {
                        wow.push_back(1);
                        return 1;
                    }
                }
            }
            else {
                if(haha[0] == 0 || wow[wow.size()-1] == 0) {
                    return 1;
                }
                else {
                    return 0;
                }
            }
        }
    }
}
#include "Anthony.h"
#include "Catherine.h"
#include "zadachki.cpp"
#include "haha.cpp"
#include <cstdio>
#include <cstdlib>
#include <random>
#include <utility>
#include <vector>

namespace {

using std::atoll;
using std::exit;
using std::fprintf;
using std::printf;
using std::scanf;
using std::vector;

void WrongAnswer(int code) {
  printf("Wrong Answer [%d]\n", code);
  exit(0);
}

}  // namespace

int main(int argc, char **argv) {
  long long seed = 0;
  if (argc >= 2) {
    seed = atoll(argv[1]);
  }
  std::mt19937 rng(seed);

  // input
  int N, M, A, B, S;
  if (scanf("%d%d%d%d%d", &N, &M, &A, &B, &S) != 5) {
    fprintf(stderr, "Error while reading input.\n");
    exit(1);
  }
  vector<int> U(M), V(M);
  for (int i = 0; i < M; ++i) {
    if (scanf("%d%d", &U[i], &V[i]) != 2) {
      fprintf(stderr, "Error while reading input.\n");
      exit(1);
    }
  }

  // Anthony
  const vector<int> x = Mark(N, M, A, B, U, V);
  if (x.size() != static_cast<size_t>(M)) {
    WrongAnswer(1);
  }
  for (int i = 0; i < M; ++i) {
    if (!(0 <= x[i] && x[i] <= A - 1)) {
      WrongAnswer(2);
    }
  }

  vector<vector<vector<int>>> adjacent_towns(N, vector<vector<int>>(A));
  for (int i = 0; i < M; ++i) {
    adjacent_towns[U[i]][x[i]].push_back(V[i]);
    adjacent_towns[V[i]][x[i]].push_back(U[i]);
  }

  // Catherine
  Init(A, B);
  int num_moves = 0;
  int last_town = -1, current_town = S;
  for (; current_town != 0; ) {
    cout << current_town << endl;
    if (num_moves >= N + B) {
      printf("Wrong Answer; Number of moves > N + B\n");
      exit(0);
    }
    vector<int> y(A, 0);
    vector<vector<int>> next_towns(A);
    for (int j = 0; j < A; ++j) {
      for (const int next_town : adjacent_towns[current_town][j]) {
        if (next_town != last_town) {
          ++y[j];
          next_towns[j].push_back(next_town);
        }
      }
    }
    const int z = Move(y);
    ++num_moves;
    if (!(-1 <= z && z <= A - 1)) {
      WrongAnswer(3);
    }
    if (last_town == -1 && z == -1) {
      WrongAnswer(4);
    }
    if (0 <= z && z <= A - 1 && y[z] == 0) {
      WrongAnswer(5);
    }
    if (z == -1) {
      std::swap(last_town, current_town);
    } else {
      last_town = current_town;
      current_town =
          next_towns[z][std::uniform_int_distribution<int>(0, y[z] - 1)(rng)];
    }
  }

  printf("Number of moves = %d\n", num_moves);
  return 0;
}

Compilation message

Anthony.cpp: In function 'int Move(std::vector<int>)':
Anthony.cpp:18:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for(int i = 0; i < haha.size(); i++) {
      |                        ~~^~~~~~~~~~~~~
Anthony.cpp:127:1: warning: control reaches end of non-void function [-Wreturn-type]
  127 | }
      | ^
/usr/bin/ld: /tmp/ccLbq6UU.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

Catherine.cpp:3:10: fatal error: zadachki.cpp: No such file or directory
    3 | #include "zadachki.cpp"
      |          ^~~~~~~~~~~~~~
compilation terminated.