답안 #796825

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796825 2023-07-28T19:22:47 Z Antekb 길고양이 (JOI20_stray) C++17
76 / 100
290 ms 16472 KB
#include "Anthony.h"
#include <vector>
#include<iostream>
#include<cassert>
#define pb push_back
#define st first
#define nd second
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;

namespace {
vi vis, col;
vector<vector<pii> > E;
vector<int> wzo={0,0,0,1,1,0,1};
void dfs(int v, int i, int zmi, int co, int czy, int p){
//i, zmi - pozycje w ciagu, co-krawedz do ojca, czy=czy ojciec mial wiele dzieci
	vis[v]=1;
	int cnt=0;
	for(pii u:E[v])if(!vis[u.st])cnt++;
	for(pii u:E[v]){
		if(!vis[u.st]){
			if(cnt==1){
				col[u.nd]=wzo[i]^zmi;
				dfs(u.st,(i+1)%7, zmi, col[u.nd], 0, v);
			}
			else{
				col[u.nd]=co^1;
				dfs(u.st, 1, co^1, co^1, 1, v);
			}
		}
		else if(u.st!=p)col[u.nd]=2;
	}
}

}  // namespace

std::vector<int> Mark(int N, int M, int A, int B,
	std::vector<int> U, std::vector<int> V) {
	vis.resize(N);
	E.resize(N);
	col.resize(M);
	for(int i=0; i<M; i++){
		E[U[i]].pb({V[i], i});
		E[V[i]].pb({U[i], i});
	}
	dfs(0, 0, 0, 0, 0, -1);
	for(int i=0; i<M; i++){
		cerr<<U[i]<<" "<<V[i]<<" "<<col[i]<<"\n";
	}
	return col;
}
#include "Catherine.h"
#include <vector>
#include<iostream>
#include<cassert>
#include<algorithm>
#define pb push_back
#define st first
#define nd second
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;

namespace {

int A, B;
int czy_pocz, lst, czy_dobrze;
vector<int> co;

}  // namespace

void Init(int A, int B) {
	co.clear();
	::A = A;
	::B = B;
	czy_pocz=1;
	czy_dobrze=0;
}

int Move(std::vector<int> y) {
	for(int i:y)cerr<<i<<" ";
	cerr<<endl;
	if(1-czy_pocz+y[0]+y[1]>=3){
		czy_dobrze=1;
		if(czy_pocz){
			czy_pocz=0;
			if(y[0]<=1){
				lst=0;
				return 0;
			}
			else{
				lst=1;
				return 1;
			}
		}
		else{
			if(y[lst]){
				lst^=1;
				return lst;
			}
			else return -1;
		}
	}
	if(czy_pocz==1){
		lst=!!y[1];
		co.pb(!!y[1]);
		czy_pocz=0;
		return !!y[1];
	}
	if(czy_dobrze){
		lst=y[1];
		return y[1];
	}
	if(y[0]+y[1]==0){
		czy_dobrze=1;
		return -1;
	}
	co.pb(y[1]);
	if(co.size()==7){
		while(co[0]==co.back()){
			co.pb(co[0]);
			reverse(co.begin(), co.end());
			co.pop_back();
			reverse(co.begin(), co.end());
		}
		cerr<<"a\n";
		vector<int> V;
		int cnt=0;
		for(int i=0; i<7; i++){
			cnt++;
			if(i==6 || co[i]!=co[i+1]){
				V.pb(cnt);
				cnt=0;
			}
		}
		czy_dobrze=1;
		if(V==vi({3,2,1,1})
			||V==vi({2,1,1,3})||V==vi({1,1,3,2})||V==vi({1,3,2,1})){
			return -1;
		}
		else{
			lst=y[1];
			return y[1];
		}
	}
	lst=y[1];
	return y[1];
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 186 ms 16044 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 186 ms 16044 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 13724 KB Output is correct
2 Correct 0 ms 520 KB Output is correct
3 Correct 141 ms 13168 KB Output is correct
4 Correct 287 ms 16080 KB Output is correct
5 Incorrect 290 ms 16472 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 13724 KB Output is correct
2 Correct 0 ms 520 KB Output is correct
3 Correct 141 ms 13168 KB Output is correct
4 Correct 287 ms 16080 KB Output is correct
5 Incorrect 290 ms 16472 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 900 KB Output is correct
2 Correct 1 ms 508 KB Output is correct
3 Correct 4 ms 904 KB Output is correct
4 Correct 7 ms 904 KB Output is correct
5 Correct 6 ms 892 KB Output is correct
6 Correct 6 ms 904 KB Output is correct
7 Correct 7 ms 896 KB Output is correct
8 Correct 7 ms 896 KB Output is correct
9 Correct 7 ms 896 KB Output is correct
10 Correct 6 ms 932 KB Output is correct
11 Correct 4 ms 904 KB Output is correct
12 Correct 4 ms 904 KB Output is correct
13 Correct 5 ms 900 KB Output is correct
14 Correct 5 ms 908 KB Output is correct
15 Correct 6 ms 900 KB Output is correct
16 Correct 5 ms 912 KB Output is correct
17 Correct 5 ms 904 KB Output is correct
18 Correct 5 ms 900 KB Output is correct
19 Correct 5 ms 900 KB Output is correct
20 Correct 5 ms 908 KB Output is correct
21 Correct 5 ms 904 KB Output is correct
22 Correct 5 ms 900 KB Output is correct
23 Correct 5 ms 908 KB Output is correct
24 Correct 5 ms 900 KB Output is correct
25 Correct 5 ms 868 KB Output is correct
26 Correct 5 ms 900 KB Output is correct
27 Correct 5 ms 900 KB Output is correct
28 Correct 5 ms 900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 11256 KB Output is correct
2 Correct 180 ms 12868 KB Output is correct
3 Correct 1 ms 520 KB Output is correct
4 Correct 137 ms 11636 KB Output is correct
5 Correct 241 ms 14464 KB Output is correct
6 Correct 252 ms 14628 KB Output is correct
7 Correct 145 ms 13472 KB Output is correct
8 Correct 144 ms 13556 KB Output is correct
9 Correct 248 ms 14496 KB Output is correct
10 Correct 247 ms 14528 KB Output is correct
11 Correct 271 ms 14524 KB Output is correct
12 Correct 243 ms 14560 KB Output is correct
13 Correct 246 ms 14764 KB Output is correct
14 Correct 242 ms 14552 KB Output is correct
15 Correct 244 ms 14472 KB Output is correct
16 Correct 255 ms 14596 KB Output is correct
17 Correct 212 ms 14092 KB Output is correct
18 Correct 221 ms 14336 KB Output is correct
19 Correct 207 ms 14196 KB Output is correct
20 Correct 210 ms 14124 KB Output is correct
21 Correct 211 ms 14316 KB Output is correct
22 Correct 212 ms 14092 KB Output is correct
23 Correct 141 ms 11680 KB Output is correct
24 Correct 147 ms 11724 KB Output is correct
25 Correct 151 ms 12076 KB Output is correct
26 Correct 152 ms 12136 KB Output is correct
27 Correct 193 ms 13012 KB Output is correct
28 Correct 192 ms 12936 KB Output is correct
29 Correct 192 ms 12932 KB Output is correct
30 Correct 210 ms 13284 KB Output is correct
31 Correct 141 ms 11660 KB Output is correct
32 Correct 139 ms 11728 KB Output is correct
33 Correct 150 ms 12112 KB Output is correct
34 Correct 160 ms 12512 KB Output is correct
35 Correct 193 ms 12912 KB Output is correct
36 Correct 190 ms 12788 KB Output is correct
37 Correct 189 ms 12940 KB Output is correct
38 Correct 191 ms 12892 KB Output is correct
39 Correct 212 ms 13060 KB Output is correct
40 Correct 185 ms 12912 KB Output is correct
41 Correct 207 ms 13536 KB Output is correct
42 Correct 211 ms 13424 KB Output is correct
43 Correct 207 ms 13604 KB Output is correct
44 Correct 213 ms 13680 KB Output is correct
45 Correct 216 ms 13760 KB Output is correct
46 Correct 228 ms 13652 KB Output is correct
47 Correct 183 ms 12876 KB Output is correct
48 Correct 182 ms 12768 KB Output is correct
49 Correct 165 ms 12508 KB Output is correct
50 Correct 194 ms 13020 KB Output is correct
51 Correct 140 ms 11656 KB Output is correct
52 Correct 140 ms 11732 KB Output is correct
53 Correct 141 ms 11628 KB Output is correct
54 Correct 141 ms 11680 KB Output is correct
55 Correct 144 ms 11676 KB Output is correct
56 Correct 138 ms 11596 KB Output is correct
57 Correct 148 ms 11680 KB Output is correct
58 Correct 140 ms 11928 KB Output is correct
59 Correct 140 ms 12032 KB Output is correct
60 Correct 141 ms 12004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 144 ms 11640 KB Output is correct
2 Correct 168 ms 12648 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 138 ms 11616 KB Output is correct
5 Correct 256 ms 14560 KB Output is correct
6 Correct 255 ms 14772 KB Output is correct
7 Incorrect 145 ms 13488 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -