Submission #427294

# Submission time Handle Problem Language Result Execution time Memory
427294 2021-06-14T14:01:08 Z kai824 City (JOI17_city) C++17
8 / 100
359 ms 21872 KB
#include "Encoder.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> adjl[250005];

void dfs(int node,ll bits,int p=-1){
	Code(node,bits);
	int sz=adjl[node].size();
	if(p!=-1)sz--;
	int j=0;
	while((1ll<<j)<sz)j++;
	bits*=2*(1ll<<j);
	for(int x:adjl[node]){
		if(x==p)continue;
		dfs(x,bits,node);
		bits++;
	}
}

void Encode(int n, int a[], int b[]){
	for(int i=0;i+1<n;i++){
		adjl[a[i]].push_back(b[i]);
		adjl[b[i]].push_back(a[i]);
	}
	dfs(0,1);
	//Code(i, 0LL): node, label...
}
#include "Device.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void InitDevice(){}

int Answer(long long s, long long t){
	vector<int> v1,v2;
	while(s>0){
		v1.push_back(s&1);
		s>>=1;
	}
	while(t>0){
		v2.push_back(t&1);
		t>>=1;
	}
	reverse(v1.begin(),v1.end());
	reverse(v2.begin(),v2.end());
	//for(int x:v1)cout<<x;cout<<'\n';
	//for(int x:v2)cout<<x;cout<<'\n';

	for(int i=0;i<v1.size() && i<v2.size();i++){
		if(v1[i]!=v2[i])return 2;
	}
	if(v1.size()<v2.size())return 1;
	else return 0;
}

Compilation message

Device.cpp: In function 'int Answer(long long int, long long int)':
Device.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=0;i<v1.size() && i<v2.size();i++){
      |              ~^~~~~~~~~~
Device.cpp:23:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=0;i<v1.size() && i<v2.size();i++){
      |                             ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6396 KB Output is correct
2 Correct 4 ms 6404 KB Output is correct
3 Correct 5 ms 6476 KB Output is correct
4 Correct 5 ms 6428 KB Output is correct
5 Correct 5 ms 6380 KB Output is correct
6 Correct 5 ms 6404 KB Output is correct
7 Correct 5 ms 6392 KB Output is correct
8 Correct 5 ms 6476 KB Output is correct
9 Correct 4 ms 6472 KB Output is correct
10 Correct 5 ms 6372 KB Output is correct
11 Correct 5 ms 6396 KB Output is correct
12 Correct 4 ms 6396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 355 ms 21872 KB Output is partially correct - L = 4303893650
2 Incorrect 359 ms 21804 KB Output isn't correct - L = 4608938827841
3 Halted 0 ms 0 KB -