답안 #912759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912759 2024-01-19T20:58:18 Z amirhoseinfar1385 길고양이 (JOI20_stray) C++17
15 / 100
41 ms 20340 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn=20000+10;
struct yal{
	int u,v,w;	
	int getad(int fu){
		return (fu^u^v);
	}
}alle[maxn];

namespace {
	int a,b,n,m,high[maxn];
}

vector<int>res;
vector<int>adj[maxn];

void bfs(int u){
	vector<int>bf;
	bf.push_back(u);
	int dis=1;
	while((int)bf.size()>0){
		for(auto x:bf){
			high[x]=dis;
		}
		vector<int>fake;
		for(auto x:bf){
			for(auto y:adj[x]){
				int v=alle[y].getad(x);
				if(high[v]==0){
					high[v]=dis+1;
					fake.push_back(v);
				}
			}
		}
		swap(fake,bf);
		dis++;
	}
}

vector<int> Mark(int N, int M, int A, int B,std::vector<int> U, std::vector<int> V) {
  	a=A;
  	b=B;
  	n=N;
  	m=M;
  	res.resize(m);
  	for(int i=0;i<m;i++){
 		alle[i].u=U[i];
 		alle[i].v=V[i]; 		
  		adj[alle[i].u].push_back(i);
  		adj[alle[i].v].push_back(i);
  	}
  	if(a>=3){
  		bfs(0);
  		for(int i=0;i<m;i++){
  			if(high[alle[i].u]==high[alle[i].v]){
  				res[i]=(high[alle[i].v]+1)%3;
  				continue;
  			}
  			if(high[alle[i].u]>high[alle[i].v]){
  				swap(alle[i].u,alle[i].v);
  			}
  			res[i]=high[alle[i].v]%3;
  		}
  		return res;
  	}
  	bfs(0);
  	for(int i=0;i<m;i++){
  		if(high[alle[i].u]>high[alle[i].v]){
  			swap(alle[i].u,alle[i].v);
  		}
  		res[i]=high[alle[i].v]%2;
  	}
  	return res;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;

namespace {
  int a,b,peydashod=0,last=-1;
  vector<int>tofy;
}

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

int Move(std::vector<int> y) {
  if(a>=3){
    vector<int>tof;
    for(int i=0;i<(int)y.size();i++){
      if(y[i]!=0){
        tof.push_back(i);
      }
    }
    if((int)tof.size()==0){
      return -1;
    }
    if((int)tof.size()==1){
      return tof[0];
    }
    if(tof[0]==0&&tof[1]==1){
      return 0;
    }
    if(tof[0]==0&&tof[1]==2){
      return 2;
    }
    if(tof[0]==1&&tof[1]==2){
      return 1;
    }
  }
  if(y[0]>1){
    last=1;
    peydashod=1;
    return 1;
  }
  if(y[1]>1){
    last=0;
    peydashod=1;
    return 0;
  }
  if(peydashod==1){
    last^=1;
    return last;
  }
  if(last!=-1){
    if(y[0]==0&&y[1]==0){
      peydashod=1;
      return -1;
    }
    last^=1;
    tofy.push_back(last);
    int z=-1;
    if(z==-1){
      return last;
    }
    if(z==0){
      last^=1;
      peydashod=1;
      return -1;
    }
    peydashod=1;
    return last;
  }
  else{
    y[last]++;
    if(y[0]>1){
      last=1;
      peydashod=1;
     return 1;
    } 
    if(y[1]>1){
      last=0;
      peydashod=1;
      return 0;
    }
    return last;
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 15956 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 26 ms 15184 KB Output is correct
4 Correct 37 ms 17004 KB Output is correct
5 Correct 41 ms 16948 KB Output is correct
6 Correct 30 ms 15728 KB Output is correct
7 Correct 30 ms 15692 KB Output is correct
8 Correct 34 ms 16500 KB Output is correct
9 Correct 35 ms 16300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 15956 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 26 ms 15184 KB Output is correct
4 Correct 37 ms 17004 KB Output is correct
5 Correct 41 ms 16948 KB Output is correct
6 Correct 30 ms 15728 KB Output is correct
7 Correct 30 ms 15692 KB Output is correct
8 Correct 34 ms 16500 KB Output is correct
9 Correct 35 ms 16300 KB Output is correct
10 Correct 27 ms 13896 KB Output is correct
11 Correct 27 ms 13676 KB Output is correct
12 Correct 28 ms 13604 KB Output is correct
13 Correct 27 ms 13844 KB Output is correct
14 Correct 27 ms 13940 KB Output is correct
15 Correct 32 ms 14300 KB Output is correct
16 Correct 33 ms 16496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 13432 KB Output is correct
2 Correct 1 ms 1800 KB Output is correct
3 Correct 24 ms 12868 KB Output is correct
4 Correct 38 ms 14752 KB Output is correct
5 Correct 35 ms 14972 KB Output is correct
6 Correct 26 ms 13444 KB Output is correct
7 Correct 27 ms 13396 KB Output is correct
8 Correct 34 ms 14128 KB Output is correct
9 Correct 34 ms 14376 KB Output is correct
10 Correct 31 ms 13964 KB Output is correct
11 Correct 32 ms 14536 KB Output is correct
12 Correct 31 ms 13904 KB Output is correct
13 Correct 30 ms 14192 KB Output is correct
14 Correct 37 ms 14284 KB Output is correct
15 Correct 32 ms 14228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 13432 KB Output is correct
2 Correct 1 ms 1800 KB Output is correct
3 Correct 24 ms 12868 KB Output is correct
4 Correct 38 ms 14752 KB Output is correct
5 Correct 35 ms 14972 KB Output is correct
6 Correct 26 ms 13444 KB Output is correct
7 Correct 27 ms 13396 KB Output is correct
8 Correct 34 ms 14128 KB Output is correct
9 Correct 34 ms 14376 KB Output is correct
10 Correct 31 ms 13964 KB Output is correct
11 Correct 32 ms 14536 KB Output is correct
12 Correct 31 ms 13904 KB Output is correct
13 Correct 30 ms 14192 KB Output is correct
14 Correct 37 ms 14284 KB Output is correct
15 Correct 32 ms 14228 KB Output is correct
16 Correct 24 ms 11832 KB Output is correct
17 Correct 29 ms 11892 KB Output is correct
18 Correct 29 ms 11712 KB Output is correct
19 Correct 28 ms 11636 KB Output is correct
20 Correct 33 ms 12664 KB Output is correct
21 Correct 27 ms 12156 KB Output is correct
22 Correct 32 ms 14456 KB Output is correct
23 Correct 26 ms 11856 KB Output is correct
24 Correct 26 ms 11888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1820 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 20340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 20272 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -