답안 #388319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388319 2021-04-10T22:38:39 Z ngrace 길고양이 (JOI20_stray) C++14
15 / 100
59 ms 16344 KB
#include "Anthony.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {

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

}  // 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,-1);

  vector<vector<pair<int,int>>> adj(N,vector<pair<int,int>>(0));//node,index of road
  for(int i=0;i<M;i++){
    adj[U[i]].push_back({V[i],i});
    adj[V[i]].push_back({U[i],i});
  }

  if(A==4 || A==3){
    vector<int> dists(N,-1);
    dists[0]=0;
    queue<int> q;
    q.push(0);

    while(q.size()>0){
      int cur=q.front();
      q.pop();
      for(pair<int,int>& it:adj[cur]){
        if(dists[it.first]==-1){
          dists[it.first]=dists[cur]+1;
          X[it.second]=dists[cur]%3;
          q.push(it.first);
        }
      }
    }

    for(int i=0;i<M;i++){
      if(X[i]==-1){
        vector<int> cur(3,0);
        vector<int> cur1(3,0);
        for(pair<int,int>& it:adj[U[i]]){
          if(X[it.second]!=-1){
            cur[X[it.second]]=1;
          }
        }
        for(pair<int,int>& it:adj[V[i]]){
          if(X[it.second]!=-1){
            cur1[X[it.second]]=1;
          }
        }

        vector<int> a = cur;
        for(int p=0;p<3;p++){
          if(cur1[p]==1){
            a[p]++;
          }
        }
        
        if(a[0]>0 && a[1]>0 && a[2]>0){
          if(a[0]==1&&a[1]==1&&a[2]==1){
            if(cur[0]+cur[1]+cur[2]==1){
              if(cur[0]==1){
                X[i]=1;
              }
              else if(cur[1]==1){
                X[i]=2;
              }
              else if(cur[2]==1){
                X[i]=0;
              }
            }
            else{
                if(cur1[0]==1){
                  X[i]=1;
                }
                else if(cur1[1]==1){
                  X[i]=2;
                }
                else if(cur1[2]==1){
                  X[i]=0;
                }
            }
          }
          else if(a[0]==2){
            X[i]=0;
          }
          else if(a[1]==2){
            X[i]=1;
          }
          else{
            X[i]=2;
          }
        }
        if(a[0]==0){
          X[i]=2;
        }
        if(a[1]==0){
          X[i]=0;
        }
        if(a[2]==0){
          X[i]=1;
          if(a[0]==0){
            X[i]=2;
          }
        }
      }
    }
  }

  /**for(int&it:X){
    cout<<it<<" ";
  }
  cout<<endl;**/

  return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {

int A, B, out;
int variable_example = 0;
vector<int> cur;
vector<int> pastMoves;

}  // namespace

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

int Move(std::vector<int> y) {
  out=0;
  cur = vector<int>(4,0);
  if(A==4 || A==3){
    if(pastMoves.size()>0){
      y[pastMoves.back()]++;
    }
    for(int i=0;i<y.size();i++){
      if(y[i]>0){
        cur[i]=1;
      }
    }
    
    if(cur[0]==1 && cur[1]==1){
      out=0;
    }
    else if(cur[1]==1&&cur[2]==1){
      out=1;
    }
    else if(cur[2]==1&&cur[0]==1){
      out=2;
    }
    else if(cur[0]==1){
      out=0;
    }
    else if(cur[1]==1){
      out=1;
    }
    else{
      out=2;
    }
  }
  
  pastMoves.push_back(out);
  return out;
}

Compilation message

Anthony.cpp:7:5: warning: 'int {anonymous}::FunctionExample(int, int)' defined but not used [-Wunused-function]
    7 | int FunctionExample(int i, int A) {
      |     ^~~~~~~~~~~~~~~

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<y.size();i++){
      |                 ~^~~~~~~~~
Catherine.cpp: At global scope:
Catherine.cpp:7:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    7 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 14980 KB Output is correct
2 Correct 1 ms 496 KB Output is correct
3 Correct 36 ms 14392 KB Output is correct
4 Correct 55 ms 16140 KB Output is correct
5 Correct 55 ms 16344 KB Output is correct
6 Correct 43 ms 14804 KB Output is correct
7 Correct 43 ms 14836 KB Output is correct
8 Correct 52 ms 15588 KB Output is correct
9 Correct 55 ms 15624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 14980 KB Output is correct
2 Correct 1 ms 496 KB Output is correct
3 Correct 36 ms 14392 KB Output is correct
4 Correct 55 ms 16140 KB Output is correct
5 Correct 55 ms 16344 KB Output is correct
6 Correct 43 ms 14804 KB Output is correct
7 Correct 43 ms 14836 KB Output is correct
8 Correct 52 ms 15588 KB Output is correct
9 Correct 55 ms 15624 KB Output is correct
10 Correct 40 ms 12764 KB Output is correct
11 Correct 40 ms 12828 KB Output is correct
12 Correct 39 ms 12752 KB Output is correct
13 Correct 40 ms 12796 KB Output is correct
14 Correct 41 ms 13028 KB Output is correct
15 Correct 47 ms 13448 KB Output is correct
16 Correct 51 ms 15708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 12664 KB Output is correct
2 Correct 0 ms 488 KB Output is correct
3 Correct 34 ms 12172 KB Output is correct
4 Correct 54 ms 13952 KB Output is correct
5 Correct 53 ms 14044 KB Output is correct
6 Correct 47 ms 12524 KB Output is correct
7 Correct 41 ms 12644 KB Output is correct
8 Correct 48 ms 13224 KB Output is correct
9 Correct 47 ms 13356 KB Output is correct
10 Correct 46 ms 13080 KB Output is correct
11 Correct 47 ms 13056 KB Output is correct
12 Correct 59 ms 13084 KB Output is correct
13 Correct 52 ms 13012 KB Output is correct
14 Correct 47 ms 13312 KB Output is correct
15 Correct 49 ms 13240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 12664 KB Output is correct
2 Correct 0 ms 488 KB Output is correct
3 Correct 34 ms 12172 KB Output is correct
4 Correct 54 ms 13952 KB Output is correct
5 Correct 53 ms 14044 KB Output is correct
6 Correct 47 ms 12524 KB Output is correct
7 Correct 41 ms 12644 KB Output is correct
8 Correct 48 ms 13224 KB Output is correct
9 Correct 47 ms 13356 KB Output is correct
10 Correct 46 ms 13080 KB Output is correct
11 Correct 47 ms 13056 KB Output is correct
12 Correct 59 ms 13084 KB Output is correct
13 Correct 52 ms 13012 KB Output is correct
14 Correct 47 ms 13312 KB Output is correct
15 Correct 49 ms 13240 KB Output is correct
16 Correct 36 ms 11076 KB Output is correct
17 Correct 43 ms 11008 KB Output is correct
18 Correct 42 ms 10876 KB Output is correct
19 Correct 43 ms 10876 KB Output is correct
20 Correct 44 ms 11524 KB Output is correct
21 Correct 43 ms 11776 KB Output is correct
22 Correct 49 ms 13868 KB Output is correct
23 Correct 52 ms 11436 KB Output is correct
24 Correct 40 ms 11568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 496 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 2164 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2176 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -