답안 #710658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710658 2023-03-15T13:47:10 Z penguin133 길고양이 (JOI20_stray) C++17
20 / 100
53 ms 16908 KB
#include <bits/stdc++.h>
using namespace std;
#include "Anthony.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
 

namespace {
 
int FunctionExample(int i, int A) {
  return i % A;
}
 
vector <int> adj[20005];
int dist[20005], grr[200005], which[200005];

void dfs(int x, int cur){
	dist[x] = cur;
	for(auto i : adj[x]){
		if(!dist[i])dfs(i, cur + 1);
	}
}

string wtf = "0011010", wtf2 = "1101001";


}  // 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);
  for(int i=0;i<M;i++){
	  adj[U[i]].push_back(V[i]);
	  adj[V[i]].push_back(U[i]);
  }
  if(B == 0){
	  queue <int> qu;
	  for(int i=0;i<N;i++)dist[i] = 1e9;
	  dist[0] = 0;
	  qu.push(0);
	  while(!qu.empty()){
		  int x = qu.front(); qu.pop();
		  for(auto i : adj[x]){
			  if(dist[i] > dist[x] + 1)dist[i] = dist[x] + 1, qu.push(i);
		  }
	  }
	  for(int i=0;i<M;i++){
		  int x = max(dist[U[i]], dist[V[i]]);
		if(abs(dist[U[i]] - dist[V[i]]) != 1)X[i] = (x + 1) % 3;
		 else X[i] = x % min(A, 3);
	  }
	  return X;
  }
  else{
	  queue <int> qu;
	  for(int i=0;i<N;i++)dist[i] = 1e9;
	  dist[0] = 0;
	  grr[0] = -1;
	  which[0] = 0;
	  qu.push(0);
	  while(!qu.empty()){
		 int x = qu.front(); qu.pop();
		 for(auto i : adj[x]){
			if(dist[i] > dist[x] + 1){
				dist[i] = dist[x] + 1;
				qu.push(i);
				if((int)adj[x].size() <= 2){
					grr[i] = (grr[x] + 1)%7;
					which[i] = which[x];
				}
				else{
					int tmp;
					if(x == 0)tmp = 0;
					else if(!which[x])tmp = wtf[grr[x]] - '0';
					else tmp = wtf2[grr[x]] - '0';
					if(tmp)grr[i] = 0, which[i] = 0;
					else grr[i] = 0, which[i] = 1;
				}
			}
		 }
	 }
	 for(int i=0;i<M;i++){
		 int x = (dist[U[i]] > dist[V[i]] ? U[i] : V[i]);
		 int tmp;
					if(x == 0)tmp = 0;
					else if(!which[x])tmp = wtf[grr[x]] - '0';
					else tmp = wtf2[grr[x]] - '0';
		 X[i] = tmp;
		// cout << tmp << ' ';
	 }
	 return X;
  }
}

#include <bits/stdc++.h>
using namespace std;
#include "Catherine.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
namespace {
 
int A, B;
int variable_example = 0;
 int prv= -1;
 int cnt = 0, bruh[20005];
 int st = -1;
 vector <string> stuf[3] = {{"232"}, {"322", "221", "212", "123"}, {"222"}};
 string cur = "";
 bool ret = 0;
 int rem = 0;
}  // namespace
 
void Init(int A, int B) {
  ::A = A;
  ::B = B;
}
 
int Move(std::vector<int> y) {
	if(rem){
		rem--;
		return -1;
	}
  ++variable_example;
  if(B == 0){
	 if(prv != -1){
	  prv--;
	  if(prv < 0)prv += 3;
	  return prv;
  }
  vector <int> stuf2;
  int x = -1;
  for(int j=0;j<3;j++){
	  if(y[j] == 1)stuf2.push_back(j);
	  else x = j;
  }
  if((int)stuf2.size() == 1){prv = stuf2[0]; return stuf2[0];}
  else{
	  if(x == 0)prv = 1;
	  else if(x == 1)prv = 2;
	  else prv = 0;
	  return prv;
  }
  return -1;
	}
  int sm = 0;
  for(int j=0;j<A;j++)sm += y[j];
 // cout << sm << ' ' << variable_example << ' ';
  if(sm + (prv != -1) == 2){
	 // cout << variable_example << '\n';
	  if(ret){
		 // cout << "bozo\n";
		  for(int j=0;j<A;j++)if(y[j] == 1){prv = j; return j;}
	  }
	  if(cnt >= 1){
		  if(y[0] == 2 && y[1] == 0)cur += "1";
		  else if(y[0] == 1 && y[1] == 1)cur += "2";
		  else cur += "3";
	  }
	  if(cnt == 3){
		  bool f = 0;
		  for(auto i : stuf[st-1])if(i == cur)f = 1;
		  ret = 1;
		  if(f){
			  rem = 2;
			return -1;  
		  }
		  else{
			  for(int j=0;j<A;j++)if(y[j] == 1){prv = j; return j;}
		  }
	  }
	  if(cnt == 0){
		  if(y[0] == 2 && y[1] == 0)st = 1;
		  else if(y[0] == 1 && y[1] == 1)st = 2;
		  else st = 3;
		  cur = "";
	  }
	  cnt++;
	  for(int j=0;j<A;j++)if(y[j]){prv = j; return j;}
  }
  else if(cnt){
	  int x = -1;
	  for(int j=0;j<A;j++)if(y[j] + (j == prv) == 1)x = j;
	  if(x == prv){ret = 1; return -1;}
	  else {ret = 1; prv = x; return x;}
  }
  else cnt = 0, cur = "";
  if(sm >= 2 && prv != -1){
	  ret = 1;
	  prv = 1 - prv;
	  return prv;
  }
  else if(sm >= 3){
	  ret = 1;
	  for(int j=0;j<A;j++)if(y[j] == 1){prv = j; return j;}
  }
  else if(ret || sm == 1){
	  for(int j=0;j<A;j++)if(y[j]){prv = j; return j;}
  }
  if(sm == 0){ret = 1; return -1;}
  return -1;
}

Compilation message

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

Catherine.cpp:19:15: warning: '{anonymous}::bruh' defined but not used [-Wunused-variable]
   19 |  int cnt = 0, bruh[20005];
      |               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 15272 KB Output is correct
2 Correct 1 ms 1008 KB Output is correct
3 Correct 30 ms 15180 KB Output is correct
4 Correct 45 ms 16804 KB Output is correct
5 Correct 41 ms 16908 KB Output is correct
6 Correct 35 ms 15564 KB Output is correct
7 Correct 37 ms 15568 KB Output is correct
8 Correct 42 ms 16368 KB Output is correct
9 Correct 43 ms 16240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 15272 KB Output is correct
2 Correct 1 ms 1008 KB Output is correct
3 Correct 30 ms 15180 KB Output is correct
4 Correct 45 ms 16804 KB Output is correct
5 Correct 41 ms 16908 KB Output is correct
6 Correct 35 ms 15564 KB Output is correct
7 Correct 37 ms 15568 KB Output is correct
8 Correct 42 ms 16368 KB Output is correct
9 Correct 43 ms 16240 KB Output is correct
10 Correct 33 ms 13632 KB Output is correct
11 Correct 32 ms 13508 KB Output is correct
12 Correct 34 ms 13536 KB Output is correct
13 Correct 35 ms 13648 KB Output is correct
14 Correct 34 ms 13896 KB Output is correct
15 Correct 39 ms 14208 KB Output is correct
16 Correct 41 ms 16424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 13020 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 31 ms 12964 KB Output is correct
4 Correct 53 ms 14708 KB Output is correct
5 Correct 49 ms 14728 KB Output is correct
6 Correct 34 ms 13356 KB Output is correct
7 Correct 33 ms 13416 KB Output is correct
8 Correct 44 ms 13976 KB Output is correct
9 Correct 41 ms 13940 KB Output is correct
10 Correct 41 ms 13684 KB Output is correct
11 Correct 42 ms 13696 KB Output is correct
12 Correct 40 ms 13708 KB Output is correct
13 Correct 50 ms 13664 KB Output is correct
14 Correct 45 ms 14060 KB Output is correct
15 Correct 39 ms 14144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 13020 KB Output is correct
2 Correct 1 ms 1028 KB Output is correct
3 Correct 31 ms 12964 KB Output is correct
4 Correct 53 ms 14708 KB Output is correct
5 Correct 49 ms 14728 KB Output is correct
6 Correct 34 ms 13356 KB Output is correct
7 Correct 33 ms 13416 KB Output is correct
8 Correct 44 ms 13976 KB Output is correct
9 Correct 41 ms 13940 KB Output is correct
10 Correct 41 ms 13684 KB Output is correct
11 Correct 42 ms 13696 KB Output is correct
12 Correct 40 ms 13708 KB Output is correct
13 Correct 50 ms 13664 KB Output is correct
14 Correct 45 ms 14060 KB Output is correct
15 Correct 39 ms 14144 KB Output is correct
16 Correct 30 ms 11856 KB Output is correct
17 Correct 31 ms 11756 KB Output is correct
18 Correct 32 ms 11692 KB Output is correct
19 Correct 32 ms 11652 KB Output is correct
20 Correct 38 ms 12312 KB Output is correct
21 Correct 33 ms 12108 KB Output is correct
22 Correct 36 ms 14204 KB Output is correct
23 Correct 30 ms 11816 KB Output is correct
24 Correct 32 ms 11752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1280 KB Output is correct
2 Correct 1 ms 1032 KB Output is correct
3 Correct 2 ms 1292 KB Output is correct
4 Correct 2 ms 1288 KB Output is correct
5 Correct 2 ms 1296 KB Output is correct
6 Correct 2 ms 1300 KB Output is correct
7 Correct 2 ms 1288 KB Output is correct
8 Correct 2 ms 1344 KB Output is correct
9 Correct 3 ms 1288 KB Output is correct
10 Correct 2 ms 1300 KB Output is correct
11 Correct 2 ms 1296 KB Output is correct
12 Correct 3 ms 1296 KB Output is correct
13 Correct 2 ms 1284 KB Output is correct
14 Correct 3 ms 1348 KB Output is correct
15 Correct 2 ms 1288 KB Output is correct
16 Correct 2 ms 1296 KB Output is correct
17 Correct 2 ms 1284 KB Output is correct
18 Correct 2 ms 1344 KB Output is correct
19 Correct 2 ms 1416 KB Output is correct
20 Correct 3 ms 1288 KB Output is correct
21 Correct 2 ms 1296 KB Output is correct
22 Correct 2 ms 1288 KB Output is correct
23 Correct 2 ms 1296 KB Output is correct
24 Correct 2 ms 1288 KB Output is correct
25 Correct 2 ms 1288 KB Output is correct
26 Correct 2 ms 1288 KB Output is correct
27 Correct 2 ms 1288 KB Output is correct
28 Correct 2 ms 1296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 11068 KB Output is correct
2 Correct 48 ms 11816 KB Output is correct
3 Correct 1 ms 1028 KB Output is correct
4 Correct 27 ms 11588 KB Output is correct
5 Correct 40 ms 12724 KB Output is correct
6 Correct 41 ms 12656 KB Output is correct
7 Correct 33 ms 11768 KB Output is correct
8 Correct 34 ms 11764 KB Output is correct
9 Correct 40 ms 12652 KB Output is correct
10 Correct 40 ms 12764 KB Output is correct
11 Correct 45 ms 12660 KB Output is correct
12 Correct 49 ms 12668 KB Output is correct
13 Correct 42 ms 12660 KB Output is correct
14 Correct 46 ms 12660 KB Output is correct
15 Correct 46 ms 12776 KB Output is correct
16 Correct 46 ms 12652 KB Output is correct
17 Correct 43 ms 12504 KB Output is correct
18 Incorrect 40 ms 12428 KB Wrong Answer [6]
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 11096 KB Output is correct
2 Correct 35 ms 11844 KB Output is correct
3 Correct 1 ms 1080 KB Output is correct
4 Correct 32 ms 11576 KB Output is correct
5 Correct 40 ms 12660 KB Output is correct
6 Correct 41 ms 12716 KB Output is correct
7 Incorrect 31 ms 11892 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -