AtCoder Beginner Contest 025

Submission #3730275

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

ll b[2][3] ,c[3][2];
ll solve(bool C,vec<vec<int>> used){
	ll M = -114514,m = 114514;
	bool ok = true;
	REP(i,3)REP(j,3){
		vec<vec<int>> unko;
		copy(ALL(used),back_inserter(unko));
		if(used[i][j] == 0){
			ok = false;
			if(C)unko[i][j] = 1;
			else unko[i][j] = 2;
			ll tmp = solve(!C,unko);
			M = max(tmp,M);
			m = min(tmp,m);
		}
	}
	if(!ok){
		return (C ? M : m);
	}
	else{
		ll dif = 0;
		REP(i,2)REP(j,3){
			if(used[i][j] == used[i + 1][j])dif += b[i][j];
			else dif -= b[i][j];
		}
		REP(i,3)REP(j,2){
			if(used[i][j] == used[i][j + 1])dif += c[i][j];
			else dif -= c[i][j];
		}
		return dif;
	}
}

signed main(){
	IOS;
	ll sum = 0;
	REP(i,2)REP(j,3){
		cin >> b[i][j];
		sum += b[i][j];
	}
	REP(i,3)REP(j,2){
		cin >> c[i][j];
		sum += c[i][j];
	}
	vec<vec<int>> used(3,vec<int>(3,0));
	ll dif = solve(true,used);
	cout << (sum + dif) / 2 << endl;
	cout << (sum - dif) / 2 << endl;
}

Submission

Task問題 C - 双子と○×ゲーム
User nameユーザ名 strtbox
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 0
Source lengthソースコード長 1646 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample-01.txt,sample-02.txt
All 0 / 100 sample-01.txt,sample-02.txt,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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample-01.txt TLE
sample-02.txt TLE
test-01.txt TLE
test-02.txt TLE
test-03.txt TLE
test-04.txt TLE
test-05.txt TLE
test-06.txt TLE
test-07.txt TLE
test-08.txt TLE
test-09.txt TLE
test-10.txt TLE
test-11.txt TLE
test-12.txt TLE
test-13.txt TLE
test-14.txt TLE
test-15.txt TLE
test-16.txt TLE
test-17.txt TLE
test-18.txt TLE
test-19.txt TLE
test-20.txt TLE