Submission #829705

# Submission time Handle Problem Language Result Execution time Memory
829705 2023-08-18T14:15:37 Z MODDI Stray Cat (JOI20_stray) C++14
15 / 100
40 ms 16292 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
namespace {
}  // namespace
 
std::vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
 	vi arr(M, -1);
 	vector<vector<pii>> G(N, vector<pii>());
 	for(int i = 0; i < M; i++){
 		int u = U[i], v = V[i];
 		G[u].pb({v, i});
 		G[v].pb({u, i});
	 }
	vi dist(N, N);
	dist[0] = 0;
	vector<int> q;
  	q.push_back(0);
	  for (int i = 0; i < (int)q.size(); i++) {
	    int v = q[i];
	    for (pii e : G[v]) if (dist[e.first] == N) {
	      dist[e.first] = dist[v] + 1;
	      q.push_back(e.first);
	    }
	  }
	if(A >= 3){
		for(int i = 0; i < M; i++){
			arr[i] = min(dist[U[i]], dist[V[i]]) % 3;
		}
		return arr;
	}
	else{
		assert(false);
		vi pib(N, -1);
		for(int i = 0; i < N; i++){
			int v = q[i];
			if(i == 0){
				for(auto t : G[v]){
					arr[t.second] = 0;
				}
				continue;
			}
			int deg = (int) G[v].size();
			if(deg == 1)	continue;
			int par = -1, parC = -1;
			for(auto t : G[v]){
				if(dist[t.first] < dist[v]){
					par = t.first;
					parC = arr[t.second];
				}
			}
			if(deg == 2){
				if(pib[par] != -1){
					pib[v] = (pib[par] + 1) % 6;
				}
				else
					pib[v] = parC + 1;
				int col = (pib[v] == 0 || pib[v] == 2 || pib[v] == 3 ? 0 : 1);
				for(auto t : G[v]){
					if(t.first != par)
						arr[t.second] = col;
				}
			}
			else{
				for(auto t : G[v]){
					if(t.first != par)
						arr[t.second] = parC ^ 1;
				}
			}
			
		}
	}
	
	return arr;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
namespace {
 
int A;
bool bP;
vector<int> colors;
 
bool Uping(vector<int> s) {
  vector<int> t = {1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0};
//  reverse(t.begin(), t.end());
  for (int i = 0; i + (int)s.size() <= (int)t.size(); i++) {
    bool ok = true;
    for (int j = 0; j < (int)s.size(); j++)
      ok &= s[j] == t[i + j];
    if (ok) return true;
  }
  return false;
}
 
}  // namespace
 
void Init(int A, int B) {
  ::A = A;
  ::bP = true;
  ::colors = vector<int>();
}
 
int Move(std::vector<int> y) {
  if (::A > 2) {
    int c = 0;
    while(c < 3) {
      if (y[c] > 0 && y[(c + 2) % 3] == 0) break;
      c++;
    }
    assert(c < 3);
    return c;
  } 
 else{
		assert(false);
		if(!colors.empty())	y[colors.back()]++;
		int deg = y[0] + y[1], col = -2;
		if(deg == 1){
			bP = false;
			if(colors.empty())	col = (y[0] > 0 ? 0 : 1);
			else col = -1;
		}
		else if (deg == 2) {
     		if (!bP) {
       			y[colors.back()]--;
        		col = (y[0] > 0 ? 0 : 1);
      		} 
		    else {
		        if ((int)colors.size() < 4) {
		          	if (!colors.empty()) y[colors.back()]--;
		         	col = (y[0] > 0 ? 0 : 1);
		         	if (colors.empty()) {
		            	y[col]--;
		            	colors.push_back((y[0] > 0 ? 0 : 1));
		         	}
	        	} 
				else {
			        y[colors.back()]--;
			        col = (y[0] > 0 ? 0 : 1);
			        vector<int> s = colors;
			    	s.push_back(col);
			        if (!Uping(s)) col = -1;
			        bP = false;
	        	}
	      	}
    	} 
		else {
		    bP = false;
		    col = (y[0] == 1 ? 0 : 1);
		    if (!colors.empty() && colors.back() == col) col = -1;
    	}
	    if (col == -1) {
	      int x = colors.back();
	      colors.push_back(x);
	    } else {
	      colors.push_back(col);
	    }
    return col;
  }
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 15348 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 23 ms 14556 KB Output is correct
4 Correct 37 ms 16292 KB Output is correct
5 Correct 40 ms 16276 KB Output is correct
6 Correct 27 ms 14952 KB Output is correct
7 Correct 26 ms 15088 KB Output is correct
8 Correct 31 ms 15856 KB Output is correct
9 Correct 32 ms 15816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 15348 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 23 ms 14556 KB Output is correct
4 Correct 37 ms 16292 KB Output is correct
5 Correct 40 ms 16276 KB Output is correct
6 Correct 27 ms 14952 KB Output is correct
7 Correct 26 ms 15088 KB Output is correct
8 Correct 31 ms 15856 KB Output is correct
9 Correct 32 ms 15816 KB Output is correct
10 Correct 24 ms 13164 KB Output is correct
11 Correct 28 ms 13144 KB Output is correct
12 Correct 30 ms 13148 KB Output is correct
13 Correct 25 ms 13104 KB Output is correct
14 Correct 28 ms 13432 KB Output is correct
15 Correct 27 ms 13800 KB Output is correct
16 Correct 28 ms 15840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 12888 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 22 ms 12416 KB Output is correct
4 Correct 34 ms 14148 KB Output is correct
5 Correct 31 ms 14176 KB Output is correct
6 Correct 26 ms 12912 KB Output is correct
7 Correct 25 ms 12872 KB Output is correct
8 Correct 33 ms 13420 KB Output is correct
9 Correct 28 ms 13552 KB Output is correct
10 Correct 27 ms 13288 KB Output is correct
11 Correct 28 ms 13288 KB Output is correct
12 Correct 35 ms 13280 KB Output is correct
13 Correct 26 ms 13280 KB Output is correct
14 Correct 30 ms 13588 KB Output is correct
15 Correct 28 ms 13616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 12888 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 22 ms 12416 KB Output is correct
4 Correct 34 ms 14148 KB Output is correct
5 Correct 31 ms 14176 KB Output is correct
6 Correct 26 ms 12912 KB Output is correct
7 Correct 25 ms 12872 KB Output is correct
8 Correct 33 ms 13420 KB Output is correct
9 Correct 28 ms 13552 KB Output is correct
10 Correct 27 ms 13288 KB Output is correct
11 Correct 28 ms 13288 KB Output is correct
12 Correct 35 ms 13280 KB Output is correct
13 Correct 26 ms 13280 KB Output is correct
14 Correct 30 ms 13588 KB Output is correct
15 Correct 28 ms 13616 KB Output is correct
16 Correct 27 ms 11256 KB Output is correct
17 Correct 26 ms 11212 KB Output is correct
18 Correct 24 ms 11240 KB Output is correct
19 Correct 24 ms 11268 KB Output is correct
20 Correct 26 ms 11952 KB Output is correct
21 Correct 25 ms 11624 KB Output is correct
22 Correct 27 ms 13752 KB Output is correct
23 Correct 24 ms 11304 KB Output is correct
24 Correct 24 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 4308 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 4308 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -