답안 #710184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710184 2023-03-15T05:35:08 Z MinhAnhnd 길고양이 (JOI20_stray) C++14
컴파일 오류
0 ms 0 KB
#include "Anthony.h"
#include <vector>
#include <bits/stdc++.h>

namespace {

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

std::vector<int> adj[20001];
int index[20001] = {};

} // namespace

std::vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {

  std::vector<int> X(M);
  std::queue<int> bfs;
  bfs.push(0);
  index[0] = 1;
  for (int i = 0; i < M; ++i) {
    adj[U[i]].push_back(V[i]);
    adj[V[i]].push_back(U[i]);
  }
  while(!bfs.empty()){
    int node = bfs.back();
    bfs.pop();
    for(auto child:adj[node]){
        if(index[child]==0){
            index[child] = index[node] + 1;
            if(index[child]==4) index[child] = 1;
            bfs.push(child);
        }
    }
  }
  for (int i = 0; i < M; ++i) {
    int nodeA = index[U[i]];
    int nodeB = index[V[i]];
    if(nodeA > nodeB) swap(nodeA,nodeB);
    if((nodeA == 1)&&(nodeB == 2)) X[i] = 0;
    if((nodeA == 2)&&(nodeB == 3)) X[i] = 1;
    if((nodeA == 1)&&(nodeB == 3)) X[i] = 2;
    if((nodeA == 2)&&(nodeB == 2)) X[i] = 1;
    if((nodeA == 3)&&(nodeB == 3)) X[i] = 2;
    if((nodeA == 1)&&(nodeB == 1)) X[i] = 0;
  }
  return X;
}
#include "Catherine.h"
#include <vector>

namespace {

int A, B;
int variable_example = 0;
}  // namespace

using namespace std;

void Init(int A, int B) {
  ::A = A;
  ::B = B;

}

int Move(std::vector<int> y) {
  ++variable_example;
  /*for (int j = 0; j < A; ++j) {
    if (y[j] != 0) {
      return j;
    }
  }*/
  if (y[0]==0){
    if (y[1]==0){
        return 2;
    }
    else return 1;
  }

  if (y[1]==0){
    if (y[2]==0){
        return 0;
    }
    else return 2;
  }

  if (y[2]==0){
    if (y[0]==0){
        return 1;
    }
    else return 0;
  }

  return -1;
}

Compilation message

Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:22:3: error: reference to 'index' is ambiguous
   22 |   index[0] = 1;
      |   ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:31:12: error: reference to 'index' is ambiguous
   31 |         if(index[child]==0){
      |            ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:32:13: error: reference to 'index' is ambiguous
   32 |             index[child] = index[node] + 1;
      |             ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:32:28: error: reference to 'index' is ambiguous
   32 |             index[child] = index[node] + 1;
      |                            ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:33:16: error: reference to 'index' is ambiguous
   33 |             if(index[child]==4) index[child] = 1;
      |                ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:33:33: error: reference to 'index' is ambiguous
   33 |             if(index[child]==4) index[child] = 1;
      |                                 ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:39:17: error: reference to 'index' is ambiguous
   39 |     int nodeA = index[U[i]];
      |                 ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:40:17: error: reference to 'index' is ambiguous
   40 |     int nodeB = index[V[i]];
      |                 ^~~~~
Anthony.cpp:12:5: note: candidates are: 'int {anonymous}::index [20001]'
   12 | int index[20001] = {};
      |     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from Anthony.cpp:3:
/usr/include/strings.h:61:1: note:                 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
/usr/include/strings.h:55:1: note:                 'char* index(char*, int)'
   55 | index (char *__s, int __c) __THROW
      | ^~~~~
Anthony.cpp:41:23: error: 'swap' was not declared in this scope
   41 |     if(nodeA > nodeB) swap(nodeA,nodeB);
      |                       ^~~~
Anthony.cpp:41:23: note: suggested alternatives:
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from Anthony.cpp:3:
/usr/include/c++/10/bits/regex.h:2141:5: note:   'std::__cxx11::swap'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from Anthony.h:5,
                 from Anthony.cpp:1:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/new:41,
                 from /usr/include/c++/10/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/vector:64,
                 from Anthony.h:5,
                 from Anthony.cpp:1:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
Anthony.cpp: At global scope:
Anthony.cpp:12:5: warning: '{anonymous}::index' defined but not used [-Wunused-variable]
   12 | int index[20001] = {};
      |     ^~~~~
Anthony.cpp:7:5: warning: 'int {anonymous}::FunctionExample(int, int)' defined but not used [-Wunused-function]
    7 | int FunctionExample(int i, int A) {
      |     ^~~~~~~~~~~~~~~