Submission #2180973
Source Code Expand
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define MAP map<int,int>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e17;
void ANS(bool flag) {
cout << ((flag) ? "YES" : "NO") << endl;
}
void Ans(bool flag) {
cout << ((flag) ? "Yes" : "No") << endl;
}
void ans(bool flag) {
cout << ((flag) ? "yes" : "no") << endl;
}
int a[3][3] = {}, b[2][3], c[3][2];
int score(void){
int diff = 0;
diff += ((a[0][0] == a[1][0]) ? b[0][0] : -b[0][0]);
diff += ((a[0][1] == a[1][1]) ? b[0][1] : -b[0][1]);
diff += ((a[0][2] == a[1][2]) ? b[0][2] : -b[0][2]);
diff += ((a[1][0] == a[2][0]) ? b[1][0] : -b[1][0]);
diff += ((a[1][1] == a[2][1]) ? b[1][1] : -b[1][1]);
diff += ((a[1][2] == a[2][2]) ? b[1][2] : -b[1][2]);
diff += ((a[0][0] == a[0][1]) ? c[0][0] : -c[0][0]);
diff += ((a[1][0] == a[1][1]) ? c[1][0] : -c[1][0]);
diff += ((a[2][0] == a[2][1]) ? c[2][0] : -c[2][0]);
diff += ((a[0][1] == a[0][2]) ? c[0][1] : -c[0][1]);
diff += ((a[1][1] == a[1][2]) ? c[1][1] : -c[1][1]);
diff += ((a[2][1] == a[2][2]) ? c[2][1] : -c[2][1]);
return diff;
}
int dfs(int round){
if (round == 9) return(score());
if(round % 2 == 0){
int diff = -MOD;
REP(i,3){
REP(j,3){
if(a[i][j] == 0){
a[i][j] = 1;
diff = max(diff, dfs(round + 1));
a[i][j] = 0;
}
}
}
return diff;
}
if (round % 2 == 1) {
int diff = MOD;
REP(i, 3) {
REP(j, 3) {
if (a[i][j] == 0) {
a[i][j] = -1;
diff = min(diff, dfs(round + 1));
a[i][j] = 0;
}
}
}
return diff;
}
}
int main() {
REP(i, 2)REP(j, 3) cin >> b[i][j];
REP(i, 3)REP(j, 2) cin >> c[i][j];
int sum = 0;
REP(i, 2)REP(j, 3) sum += b[i][j];
REP(i, 3)REP(j, 2) sum += c[i][j];
int diff = dfs(0);
int chokudai = (sum + diff) / 2;
int naoko = (sum - diff) / 2;
cout << chokudai << endl << naoko << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 双子と○×ゲーム |
User |
ningenMe |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
3383 Byte |
Status |
AC |
Exec Time |
14 ms |
Memory |
384 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
100 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample-01.txt, sample-02.txt |
All |
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 |
Case Name |
Status |
Exec Time |
Memory |
sample-01.txt |
AC |
13 ms |
256 KB |
sample-02.txt |
AC |
13 ms |
384 KB |
test-01.txt |
AC |
13 ms |
256 KB |
test-02.txt |
AC |
13 ms |
256 KB |
test-03.txt |
AC |
13 ms |
256 KB |
test-04.txt |
AC |
13 ms |
256 KB |
test-05.txt |
AC |
13 ms |
256 KB |
test-06.txt |
AC |
13 ms |
256 KB |
test-07.txt |
AC |
13 ms |
256 KB |
test-08.txt |
AC |
13 ms |
256 KB |
test-09.txt |
AC |
13 ms |
256 KB |
test-10.txt |
AC |
13 ms |
256 KB |
test-11.txt |
AC |
13 ms |
256 KB |
test-12.txt |
AC |
14 ms |
256 KB |
test-13.txt |
AC |
13 ms |
256 KB |
test-14.txt |
AC |
13 ms |
256 KB |
test-15.txt |
AC |
14 ms |
256 KB |
test-16.txt |
AC |
13 ms |
256 KB |
test-17.txt |
AC |
13 ms |
256 KB |
test-18.txt |
AC |
13 ms |
256 KB |
test-19.txt |
AC |
13 ms |
256 KB |
test-20.txt |
AC |
13 ms |
256 KB |