제출 #1238911

#제출 시각아이디문제언어결과실행 시간메모리
1238911Joshua_Andersson슈퍼트리 잇기 (IOI20_supertrees)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; //#define int ll const int inf = 1e18; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> p2; #define rep(i, high) for (int i = 0; i < (high); i++) #define repp(i, lo, high) for (int i = (lo); i < (high); i++) #define repe(i, container) for (auto& i : container) #define sz(x) ((int)(x).size()) #define all(x) begin(x), end(x) #if _LOCAL static int n; static std::vector<std::vector<int>> p; static std::vector<std::vector<int>> b; static bool called = false; #endif #if _LOCAL static void check(bool cond, std::string message) { if (!cond) { printf("%s\n", message.c_str()); fclose(stdout); exit(0); } } #else static void check(bool cond, std::string message) { #endif #if _LOCAL void build(std::vector<std::vector<int>> _b) { check(!called, "build is called more than once"); called = true; check((int)_b.size() == n, "Invalid number of rows in b"); for (int i = 0; i < n; i++) { check((int)_b[i].size() == n, "Invalid number of columns in b"); } b = _b; } #else void build(std::vector<std::vector<int>> _b) { #endif int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); if (i != n - 1) row[i + 1] = 1; answer.push_back(row); } build(answer); return 1; } #if _LOCAL int main() { assert(scanf("%d", &n) == 1); p.resize(n); for (int i = 0; i < n; i++) { p[i].resize(n); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { assert(scanf("%d", &p[i][j]) == 1); } } fclose(stdin); int possible = construct(p); check(possible == 0 || possible == 1, "Invalid return value of construct"); if (possible == 1) { check(called, "construct returned 1 without calling build"); } else { check(!called, "construct called build but returned 0"); } printf("%d\n", possible); if (possible == 1) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j) { printf(" "); } printf("%d", b[i][j]); } printf("\n"); } } fclose(stdout); } #endif

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

supertrees.cpp:7:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    7 | const int inf = 1e18;
      |                 ^~~~
supertrees.cpp: In function 'void check(bool, std::string)':
supertrees.cpp:48:46: error: a function-definition is not allowed here before '{' token
   48 | void build(std::vector<std::vector<int>> _b) {
      |                                              ^
supertrees.cpp:63:2: error: expected '}' at end of input
   63 | }
      |  ^
supertrees.cpp:34:51: note: to match this '{'
   34 | static void check(bool cond, std::string message) {
      |                                                   ^