답안 #60959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60959 2018-07-25T04:23:54 Z 정원준(#1763) City (JOI17_city) C++11
0 / 100
3000 ms 12544 KB
#include "Encoder.h"
#include <bits/stdc++.h>
#define L long long

using namespace std;

void Code(int,long long);

int chk[250050];


vector<int>v[250050];
int code[250050];


void dfs(int x,int val,int bit){
	code[x]=val;
	int i;
	L temp=1,givebit=bit;
	while(temp<v[x].size()+1)
	{
		temp<<=1;
		givebit++;
	}
	
	for(i=0;i<v[x].size();i++)
	{
		if(!chk[v[x][i]])
		{
			chk[v[x][i]]=1;
			dfs(v[x][i],val+(i<<bit),givebit);
		}
	}
}



void Encode(int N,int A[],int B[]){
	int i;
	for(i=0;i<N-1;i++)
	{
		v[A[i]].push_back(B[i]);
		v[B[i]].push_back(A[i]);
	}
	chk[0]=1;
	dfs(0,0,0);
	for(i=0;i<N;i++)
	{
		Code(i,code[i]);
	}
}
#include "Device.h"
#include <bits/stdc++.h>
#define L long long

using namespace std;

void InitDevice(){
	return;
}

int Answer(L S,L T){
	while(1)
	{
		if(S%2!=T%2)
		{
			S>>=1;
			T>>=1;
			if(S==0) return 1;
			if(T==0) return 0;
			return 2;
		}
		S>>=1;
		T>>=1;
	}
}

Compilation message

Encoder.cpp: In function 'void dfs(int, int, int)':
Encoder.cpp:20:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(temp<v[x].size()+1)
        ~~~~^~~~~~~~~~~~~~
Encoder.cpp:26:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<v[x].size();i++)
          ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3018 ms 12288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 12544 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -