답안 #837944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837944 2023-08-25T21:05:30 Z tolbi 자동 인형 (IOI18_doll) C++17
0 / 100
95 ms 11988 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define coutarr(x) for(auto &it : x) cout<<it<<" ";cout<<endl;
#define tol(bi) (1LL<<((long long)(bi)))
void create_circuit(int M, vector<int> A) {
	int n = A.size();
	vector<int> X(tol(ceil(log2(n)))-1);
	vector<int> Y(X.size());
	int S = X.size();
	for (int i = 0; i < S; i++){
		X[i]=(i+1)*2;
		Y[i]=(i+1)*2+1;
	}
	vector<int> gez;
	vector<bool> swit(S,false);
	int node = 1;
	while (gez.size()<S+1){
		if (node>S){
			gez.push_back(node);
			node=1;
		}
		else {
			if (swit[node-1]) swit[node-1]=false;
			else swit[node-1]=true;
			if (!swit[node-1]){
				node=Y[node-1];
			}
			else {
				node=X[node-1];
			}
		}
	}
	map<int,int> mp;
	for (int i = 0; i < n; ++i)
	{
		mp[gez[i]]=A[i];
	}
	mp[gez.back()]=0;
	for (int i = 0; i < S; ++i)
	{
		if (mp.count(X[i])){
			X[i]=mp[X[i]];
		}
		else if (X[i]<=S){
			X[i]=-X[i];
		}
		else X[i]=-1;
		if (mp.count(Y[i])){
			Y[i]=mp[Y[i]];
		}
		else if (Y[i]<=S){
			Y[i]=-Y[i];
		}
		else Y[i]=-1;
	}
	vector<int> C(M+1,-1);
	answer(C,X,Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:18:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |  while (gez.size()<S+1){
      |         ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 300 KB Output is partially correct
2 Incorrect 95 ms 11988 KB wrong motion
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 300 KB Output is partially correct
2 Incorrect 95 ms 11988 KB wrong motion
3 Halted 0 ms 0 KB -