SRM618(Div.2)250500

2017/12/05

初めてtopcoder練習会に参加した

とりあえず2完した。

また参加したいです。

※250

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

class LongWordsDiv2{
public:
	string find(string word){
	
	bool flag = true;
	
	for(int i = 0;i < word.size()-1;i++){
		if(word[i] == word[i+1]){
			flag = false;
			break;
		}
	}
	
	if(flag){
		
		for(int i = 0;i < word.size();i++){
			for(int j = i+1;j < word.size();j++){
				int k = j+1;
				bool ch = false;
				for(;k < word.size();k++){
					if(word[i] == word[k]){
						ch = true;
						break;
					}
				}
				if(ch){
					for(int l = k+1;l < word.size();l++){
						if(word[j] == word[l]){
							flag = false;
							goto out;
						}
					}
				}
			}
		}
		
	}
	
	out:
	;
	
	if(flag){
	return "Likes";
	}else{
	return "Dislikes";
	}

}
};


※500

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

class MovingRooksDiv2{
public:
	string move(vector <int> Y1, vector <int> Y2){
	
		int len = Y1.size();
		
		bool ch[8] = {};
		
		for(int i = 0;i < len;i++){
			ch[i] = false;
			if(Y1[i] == Y2[i]){
				ch[i] = true;
			}
		}
		bool flag = true;
		while(flag){
		flag = false;
		
		for(int i = 0;i < len;i++){
			if(ch[i] == true) continue;
			for(int j = i+1;j < len;j++){
				if(ch[j] == true) continue;
				if(Y1[i] > Y2[j]){
					flag = true;
					int tmp = Y1[i];
					Y1[i] = Y2[j];
					Y2[j] = tmp;
					goto out;
				}
			}
		}
		
		for(int i = 0;i < len;i++){
			if(Y1[i] == Y2[i]){
				ch[i] = true;
			}
		}
		
		out:
		;
		}
		
		int last = true;
		for(int i = 0;i < len;i++){
		if(Y1[i] != Y2[i]) last = false;
		}
		
		if(last){
		return "Possible";
		}else{
		return "Impossible";
		}
	
	
}
};