Submission #433926


Source Code Expand

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;

typedef pair<int, int> pos;
struct ten {
	int bd[3][3];
};
struct ans {
	int ten[2];
	int bd[3][3];
	int te;
};

ten b, c;

ans cao(ans aaa);

int main(){
	for ( int x = 0; x < 3; x++ )
		for ( int y = 0; y < 2; y++ ){
			int b_;
			cin >> b_;
			b.bd[x][y] = b_;
		}
	for ( int x = 0; x < 3; x++ )
		for ( int y = 0; y < 2; y++ ){
			int c_;
			cin >> c_;
			c.bd[x][y] = c_;
		}
	ans answer;
	answer.ten[0] = 0;
	answer.ten[1] = 0;
	for ( int x = 0; x < 3; x++ )
		for ( int y = 0; y < 3; y++ )
			answer.bd[x][y] = -1;
	answer.te = 0;
	answer = cao(answer);
	cout << answer.ten[0] << endl << answer.ten[1] << endl;
	return 0;
}

ans cao(ans a){
	ans max = a;
	a.te++;
	for ( int x = 0; x < 3; x++ )
		for ( int y = 0; y < 3; y++ )
		{
			int player = a.te % 2;
			if ( a.bd[x][y] == -1 ){
				for ( int i = 0; i < 2; i++ )
				{
					ans temp = a;
					temp.te++;
					temp.bd[x][y] = i;
					if ( y < 2 ){
						if ( temp.bd[x][y] == temp.bd[x][y + 1] )
							temp.ten[0] += b.bd[x][y];
						else
							temp.ten[1] += b.bd[x][y];
					}
					if ( x < 2 ){
						if ( temp.bd[x][y] == temp.bd[x + 1][y] )
							temp.ten[0] += c.bd[x][y];
						else
							temp.ten[1] += c.bd[x][y];
					}
					temp = cao(temp);
					if ( temp.ten[player] > max.ten[player] )max = temp;
				}
			}
		}
	return max;
}//´・ω・`

Submission Info

Submission Time
Task C - 双子と○×ゲーム
User toikage
Language C++14 (Clang++ 3.4)
Score 0
Code Size 1518 Byte
Status TLE
Exec Time 2060 ms
Memory 928 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
TLE × 2
TLE × 22
Set Name Test Cases
Sample sample-01.txt, sample-02.txt
All test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
sample-01.txt TLE 2031 ms 808 KB
sample-02.txt TLE 2032 ms 800 KB
test-01.txt TLE 2060 ms 808 KB
test-02.txt TLE 2032 ms 804 KB
test-03.txt TLE 2032 ms 856 KB
test-04.txt TLE 2032 ms 916 KB
test-05.txt TLE 2033 ms 800 KB
test-06.txt TLE 2032 ms 800 KB
test-07.txt TLE 2032 ms 816 KB
test-08.txt TLE 2033 ms 808 KB
test-09.txt TLE 2032 ms 808 KB
test-10.txt TLE 2032 ms 804 KB
test-11.txt TLE 2032 ms 800 KB
test-12.txt TLE 2033 ms 796 KB
test-13.txt TLE 2033 ms 928 KB
test-14.txt TLE 2033 ms 860 KB
test-15.txt TLE 2033 ms 860 KB
test-16.txt TLE 2032 ms 804 KB
test-17.txt TLE 2033 ms 920 KB
test-18.txt TLE 2032 ms 928 KB
test-19.txt TLE 2032 ms 860 KB
test-20.txt TLE 2032 ms 924 KB