結果

問題 No.197 手品
ユーザー ramia777ramia777
提出日時 2022-12-28 18:53:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,751 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 102,732 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 13:19:10
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 1 ms
4,384 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,384 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 WA -
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicodr
// No.197



//二次元可変配列
//vector <vector <int>> mass;
//vector <vector <int>> memo;
//vector <int> memo;


//#include "stdafx.h"
#include <iostream>
#include <vector>
#include <list>//list
#include <queue> //queue
#include <set> //連想コンテナ(要素が自動でソートされる)、要素1つ(Key)、keyの重複ない、O(logN)
#include <map> //連想コンテナ(要素が自動でソートされる)、要素2つ(Key,data)、keyの重複ない、dataは重複あり、O(logN)
#include <unordered_set> //hash、O(1)
#include <unordered_map> //hash、O(1)
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <climits>
#include <math.h>
//#include <bits/stdc++.h>

using namespace std;

#define FOR(x,to) for(x=0;x<to;x++)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FMAX(a,b)  ((a)>(b)?(a):(b))
#define FMIN(a,b)  ((a)<(b)?(a):(b))
#define FCEIL(a,b)  ((a)+(b)-1)/(b)

typedef unsigned long long ULL;
typedef signed long long SLL;


queue<int> _queue;


//昇順
int compare_up(const int * a, const int *b)
{
	if (*a > *b)
		return (1);
	else if (*a < *b)
		return (-1);
	return (0);
}

//降順
int compare_down(const int * a, const int *b)
{
	if (*a > *b)
		return (-1);
	else if (*a < *b)
		return (1);
	return (0);
}


int par[3005 * 3005];  //ルートの番号
int _rank[3005 * 3005]; //木の高さ
int flag[3005 * 3005];

// 経路圧縮
// 直列で連結しているような木はすべて直接ルートにつなぐようにする
int _find(int x)
{

	if (x == par[x])
	{
		//cout << "x=" << x << endl;
		return x;
	}
	else
	{
		int a;
		//cout << "in->" << endl;
		a = _find(par[x]);
		//cout << "<-out" << endl;




		//cout << "x=" << x << ",par[x]=" << par[x] << ",a=" << a << endl;


		//ルートを更新(圧縮)
		par[x] = a;

		//新しいルートを返す
		return par[x];
	}
}

//xとyが同じ集合かどうか
bool same(int x, int y)
{
	//ルートが同じかどうかを判定すればOK
	return	_find(x) == _find(y);
}

//初期化
//はじめは全部の頂点がルート
void init(int n)
{
	for (int i = 0; i < n; i++)
	{
		par[i] = i;
		_rank[i] = 0;
	}
}


// x と y を同じツリーにする
void _union(int x, int y)
{
	int root_x;
	int root_y;

	root_x = _find(x);
	root_y = _find(y);


	if (root_x == root_y) return; //最初から同じルートならすぐ返す


	//木の高さが高いほうの木の根に、低いほうの根をつなげる
	if (_rank[root_x] < _rank[root_y])
	{
		// x<yのとき
		par[root_x] = root_y;
	}
	else
	{
		// x>y または x==y のとき

		// yをxにつなげる
		par[root_y] = root_x;

		// 高さが同じときだけ 高さを変える必要がある
		if (_rank[root_x] == _rank[root_y])
			_rank[root_x]++; // つなげられた木の高さを1つふやす(全体の木の高さは1増える)
	}

}

// ユークリッドの互除法 
static ULL Gcd(ULL a, ULL b)
{
	if (a < b)
		// 引数を入替えて自分を呼び出す
		return Gcd(b, a);

	while (b != 0) {
		ULL remainder = a % b;
		a = b;
		b = remainder;
	}
	return a;
}

// 最小公倍数
static ULL Lcm(ULL a, ULL b)
{
	return a * b / Gcd(a, b);
}

int solve(int i, ULL index_flag)
{

	return 0;
}



int main()
{
	ULL N;
	string S1;
	string S2;
	int n1 = 0;
	int n2 = 0;
	int ptn1 = 0;
	int ptn2 = 0;
	int flag = 0;


	cin >> S1;
	cin >> N;
	cin >> S2;
	
	for (int i=0;i<3;i++)
	{
		if (S1[i] == 'o')
		{
			n1++;
			ptn1 |= (1<<(2-i));
		}
		if (S2[i] == 'o')
		{
			n2++;
			ptn2 |= (1<<(2-i));
		}
	}


	//操作前後でコイン数が同じ場合は場合分けが必要
	if (n1 == n2)
	{
		switch (ptn1)
		{
		case 0:
		case 7:
			flag = 1;
			break;
		case 1:
			if((ptn2==1) && (N%2) == 0)
				flag = 1;
			if ((ptn2 == 2) && (N % 2) == 1)
				flag = 1;
			if ((ptn2 == 4) && (N >=2))
				flag = 1;
			break;
		case 2:
			if ((ptn2 == 1) && (N >=1))
				flag = 1;
			if ((ptn2 == 2) && !(N % 2))
				flag = 1;
			if ((ptn2 == 4) && (N >= 1))
				flag = 1;
			break;
		case 3:
			if (ptn2 == 3)
				flag = 1;
			if ((ptn2 == 5) && (N % 2))
				flag = 1;
			if ((ptn2 == 6) && (N >= 2))
				flag = 1;
			break;
		case 4:
			if ((ptn2 == 1) && (N >=2))
				flag = 1;
			if ((ptn2 == 2) && !(N % 2))
				flag = 1;
			if ((ptn2 == 4) && !(N % 2))
				flag = 1;
			break;
		case 5:
			if ((ptn2 == 3) && (N>=1))
				flag = 1;
			if ((ptn2 == 5) && !(N % 2))
				flag = 1;
			if ((ptn2 == 6) && (N >= 1))
				flag = 1;
			break;
		case 6:
			if ((ptn2 == 3) && (N>=2))
				flag = 1;
			if ((ptn2 == 5) && (N % 2))
				flag = 1;
			if (ptn2 == 6)
				flag = 1;
			break;

		}
	}

	if(flag)
		cout << "FAILURE" << endl;
	else
		cout << "SUCCESS" << endl;

	return 0;

}

0