답안 #100550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100550 2019-03-12T08:06:50 Z Pro_ktmr Dungeon 2 (JOI16_dungeon2) C++14
0 / 100
17 ms 768 KB
#include<bits/stdc++.h>
using namespace std;
#define MP(a,b) make_pair(a,b)

#include"dungeon2.h"

//void Answer(int D, int A)
//void Move(int I, int C)
//int NumberOfRoads()
//int LastRoad()
//int Color()

struct way{
public:
	vector<int> toGo;
	vector<int> toRe;
};

int ans[201] = {};
void wfs(int c){
	queue<pair<way,int> > que;
	way w;
	que.push(MP(w,0));
	while(!que.empty()){
		w = que.front().first;
		int cost = que.front().second;
		ans[cost]++;
		que.pop();
		for(int i=0; i<w.toGo.size(); i++){
			Move(w.toGo[i], c);
		}
		for(int i=0; i<NumberOfRoads(); i++){
			if(w.toRe.size() > 0 && w.toRe.back() == i+1) continue;
			Move(i+1, c);
			if(Color() != c){
				w.toGo.push_back(i+1);
				w.toRe.push_back(LastRoad());
				que.push(MP(w,cost+1));
				w.toGo.pop_back();
				w.toRe.pop_back();
			}
			Move(LastRoad(), c);
		}
		for(int i=w.toRe.size()-1; i>=0; i--){
			Move(w.toRe[i], c);
		}
	}
}

void Inspect(int R){
	queue<way> que;
	vector<way> ways;
	way w;
	que.push(w);
	ways.push_back(w);
	while(!que.empty()){
		w = que.front();
		que.pop();
		for(int i=0; i<w.toGo.size(); i++){
			Move(w.toGo[i], 2);
		}
		for(int i=0; i<NumberOfRoads(); i++){
			if(w.toRe.size() > 0 && w.toRe.back() == i+1) continue;
			Move(i+1, 2);
			if(Color() == 1){
				w.toGo.push_back(i+1);
				w.toRe.push_back(LastRoad());
				que.push(w);
				ways.push_back(w);
				w.toGo.pop_back();
				w.toRe.pop_back();
			}
			Move(LastRoad(), 2);
		}
		for(int i=w.toRe.size()-1; i>=0; i--){
			Move(w.toRe[i], 2);
		}
	}
	
	int now = 2;
	for(int i=0; i<ways.size(); i++){
		for(int i=0; i<w.toGo.size(); i++){
			Move(w.toGo[i], now);
		}
		if(now == 2) now = 1;
		else now = 2;
		wfs(now);
		for(int i=w.toRe.size()-1; i>=0; i--){
			Move(w.toRe[i], now);
		}
	}
	for(int i=1; i<=R; i++){
		Answer(i, ans[i]/2);
		//cout << ans[i] << endl;
	}
}

Compilation message

dungeon2.cpp: In function 'void wfs(int)':
dungeon2.cpp:29:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<w.toGo.size(); i++){
                ~^~~~~~~~~~~~~~
dungeon2.cpp: In function 'void Inspect(int)':
dungeon2.cpp:59:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<w.toGo.size(); i++){
                ~^~~~~~~~~~~~~~
dungeon2.cpp:81:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ways.size(); i++){
               ~^~~~~~~~~~~~
dungeon2.cpp:82:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<w.toGo.size(); i++){
                ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 768 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -