Submission #92994


Source Code Expand

Copy
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

class Solver{
	const int M,N;
	vector<vector<char> > tmp;
public:
	Solver(int _M,int _N):M(_M),N(_N){
		
	}

	bool valid(int y,int x){
		return 0<=y && 0<=x;
	}


	int rec(int m,int n){
		//cout << m << "," << n << endl;
		if(n==N){
			if(m==M-1)return 1;
			return rec(m+1,0);
		}
		int res = 0;
		for(int k=1 ; k<=3 ; k++){
			bool ok = true;
			REP(i,k){
				if(valid(m-i-1,n) && tmp[m-i-1][n]==k)ok = false;
				if(valid(m,n-i-1) && tmp[m][n-i-1]==k)ok = false;
			}
			if(ok){
				tmp[m][n] = k;
				res += rec(m,n+1);
				tmp[m][n] = 0;
			}
		}
		return res;
	}

	int solve(){
		tmp.assign(M,vector<char>(N,0));
		return rec(0,0);
	}
};

int main(){
	for(int M,N ; cin >> M >> N ;){
		Solver solver(M%16,N%16);
		cout << solver.solve() << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task C - 天下一二三パズル
User nel215
Language C++ (G++ 4.6.4)
Score 40
Code Size 1255 Byte
Status WA
Exec Time 246 ms
Memory 820 KB

Judge Result

Set Name small medium large
Score / Max Score 40 / 40 0 / 20 0 / 60
Status
AC × 18
AC × 66
WA × 6
AC × 97
WA × 18
RE × 3
Set Name Test Cases
small small, small/00_manual1, small/00_manual2, small/01_small_0, small/01_small_1, small/01_small_10, small/01_small_11, small/01_small_12, small/01_small_13, small/01_small_14, small/01_small_15, small/01_small_2, small/01_small_3, small/01_small_4, small/01_small_5, small/01_small_6, small/01_small_7, small/01_small_8, small/01_small_9
medium small, small/00_manual1, small/00_manual2, small/01_small_0, small/01_small_1, small/01_small_10, small/01_small_11, small/01_small_12, small/01_small_13, small/01_small_14, small/01_small_15, small/01_small_2, small/01_small_3, small/01_small_4, small/01_small_5, small/01_small_6, small/01_small_7, small/01_small_8, small/01_small_9, medium, medium/02_00_middle_0, medium/02_00_middle_1, medium/02_00_middle_10, medium/02_00_middle_11, medium/02_00_middle_12, medium/02_00_middle_13, medium/02_00_middle_14, medium/02_00_middle_15, medium/02_00_middle_16, medium/02_00_middle_17, medium/02_00_middle_18, medium/02_00_middle_19, medium/02_00_middle_2, medium/02_00_middle_20, medium/02_00_middle_21, medium/02_00_middle_22, medium/02_00_middle_23, medium/02_00_middle_24, medium/02_00_middle_25, medium/02_00_middle_26, medium/02_00_middle_27, medium/02_00_middle_28, medium/02_00_middle_29, medium/02_00_middle_3, medium/02_00_middle_30, medium/02_00_middle_31, medium/02_00_middle_32, medium/02_00_middle_33, medium/02_00_middle_34, medium/02_00_middle_35, medium/02_00_middle_36, medium/02_00_middle_37, medium/02_00_middle_38, medium/02_00_middle_39, medium/02_00_middle_4, medium/02_00_middle_40, medium/02_00_middle_41, medium/02_00_middle_42, medium/02_00_middle_43, medium/02_00_middle_44, medium/02_00_middle_45, medium/02_00_middle_46, medium/02_00_middle_47, medium/02_00_middle_48, medium/02_00_middle_49, medium/02_00_middle_5, medium/02_00_middle_6, medium/02_00_middle_7, medium/02_00_middle_8, medium/02_00_middle_9, medium/02_01_middle_random_0, medium/02_01_middle_random_1, medium/02_01_middle_random_2, medium/02_01_middle_random_3
large large, medium, small, large/03_00_big_0, large/03_00_big_1, large/03_00_big_10, large/03_00_big_11, large/03_00_big_12, large/03_00_big_13, large/03_00_big_14, large/03_00_big_15, large/03_00_big_16, large/03_00_big_17, large/03_00_big_18, large/03_00_big_19, large/03_00_big_2, large/03_00_big_20, large/03_00_big_21, large/03_00_big_22, large/03_00_big_23, large/03_00_big_24, large/03_00_big_25, large/03_00_big_26, large/03_00_big_27, large/03_00_big_28, large/03_00_big_29, large/03_00_big_3, large/03_00_big_30, large/03_00_big_31, large/03_00_big_32, large/03_00_big_33, large/03_00_big_34, large/03_00_big_35, large/03_00_big_36, large/03_00_big_37, large/03_00_big_38, large/03_00_big_39, large/03_00_big_4, large/03_00_big_5, large/03_00_big_6, large/03_00_big_7, large/03_00_big_8, large/03_00_big_9, large/03_01_big_random_0, large/03_01_big_random_1, large/03_01_big_random_2, large/03_01_big_random_3, large/03_01_big_random_4, large/03_01_big_random_5, medium/02_00_middle_0, medium/02_00_middle_1, medium/02_00_middle_10, medium/02_00_middle_11, medium/02_00_middle_12, medium/02_00_middle_13, medium/02_00_middle_14, medium/02_00_middle_15, medium/02_00_middle_16, medium/02_00_middle_17, medium/02_00_middle_18, medium/02_00_middle_19, medium/02_00_middle_2, medium/02_00_middle_20, medium/02_00_middle_21, medium/02_00_middle_22, medium/02_00_middle_23, medium/02_00_middle_24, medium/02_00_middle_25, medium/02_00_middle_26, medium/02_00_middle_27, medium/02_00_middle_28, medium/02_00_middle_29, medium/02_00_middle_3, medium/02_00_middle_30, medium/02_00_middle_31, medium/02_00_middle_32, medium/02_00_middle_33, medium/02_00_middle_34, medium/02_00_middle_35, medium/02_00_middle_36, medium/02_00_middle_37, medium/02_00_middle_38, medium/02_00_middle_39, medium/02_00_middle_4, medium/02_00_middle_40, medium/02_00_middle_41, medium/02_00_middle_42, medium/02_00_middle_43, medium/02_00_middle_44, medium/02_00_middle_45, medium/02_00_middle_46, medium/02_00_middle_47, medium/02_00_middle_48, medium/02_00_middle_49, medium/02_00_middle_5, medium/02_00_middle_6, medium/02_00_middle_7, medium/02_00_middle_8, medium/02_00_middle_9, medium/02_01_middle_random_0, medium/02_01_middle_random_1, medium/02_01_middle_random_2, medium/02_01_middle_random_3, small/00_manual1, small/00_manual2, small/01_small_0, small/01_small_1, small/01_small_10, small/01_small_11, small/01_small_12, small/01_small_13, small/01_small_14, small/01_small_15, small/01_small_2, small/01_small_3, small/01_small_4, small/01_small_5, small/01_small_6, small/01_small_7, small/01_small_8, small/01_small_9
Case Name Status Exec Time Memory
large/03_00_big_0 WA 20 ms 788 KB
large/03_00_big_1 AC 21 ms 792 KB
large/03_00_big_10 AC 19 ms 784 KB
large/03_00_big_11 AC 20 ms 808 KB
large/03_00_big_12 AC 19 ms 788 KB
large/03_00_big_13 WA 19 ms 792 KB
large/03_00_big_14 AC 19 ms 784 KB
large/03_00_big_15 AC 20 ms 792 KB
large/03_00_big_16 AC 21 ms 792 KB
large/03_00_big_17 AC 19 ms 808 KB
large/03_00_big_18 AC 19 ms 792 KB
large/03_00_big_19 AC 20 ms 784 KB
large/03_00_big_2 WA 20 ms 696 KB
large/03_00_big_20 WA 20 ms 796 KB
large/03_00_big_21 AC 19 ms 788 KB
large/03_00_big_22 AC 19 ms 788 KB
large/03_00_big_23 WA 19 ms 792 KB
large/03_00_big_24 AC 19 ms 784 KB
large/03_00_big_25 AC 19 ms 780 KB
large/03_00_big_26 AC 19 ms 792 KB
large/03_00_big_27 AC 19 ms 788 KB
large/03_00_big_28 WA 19 ms 776 KB
large/03_00_big_29 RE 243 ms 792 KB
large/03_00_big_3 AC 19 ms 788 KB
large/03_00_big_30 WA 20 ms 768 KB
large/03_00_big_31 AC 19 ms 792 KB
large/03_00_big_32 AC 20 ms 792 KB
large/03_00_big_33 AC 19 ms 788 KB
large/03_00_big_34 AC 21 ms 700 KB
large/03_00_big_35 AC 20 ms 812 KB
large/03_00_big_36 WA 21 ms 788 KB
large/03_00_big_37 AC 19 ms 796 KB
large/03_00_big_38 WA 19 ms 788 KB
large/03_00_big_39 AC 20 ms 792 KB
large/03_00_big_4 AC 19 ms 792 KB
large/03_00_big_5 AC 19 ms 792 KB
large/03_00_big_6 RE 246 ms 776 KB
large/03_00_big_7 AC 19 ms 796 KB
large/03_00_big_8 AC 20 ms 792 KB
large/03_00_big_9 AC 20 ms 788 KB
large/03_01_big_random_0 WA 19 ms 796 KB
large/03_01_big_random_1 WA 20 ms 692 KB
large/03_01_big_random_2 AC 19 ms 664 KB
large/03_01_big_random_3 WA 20 ms 700 KB
large/03_01_big_random_4 RE 244 ms 788 KB
large/03_01_big_random_5 AC 20 ms 700 KB
medium/02_00_middle_0 AC 20 ms 700 KB
medium/02_00_middle_1 AC 20 ms 796 KB
medium/02_00_middle_10 WA 19 ms 788 KB
medium/02_00_middle_11 AC 19 ms 788 KB
medium/02_00_middle_12 AC 20 ms 624 KB
medium/02_00_middle_13 AC 20 ms 784 KB
medium/02_00_middle_14 AC 19 ms 784 KB
medium/02_00_middle_15 AC 19 ms 784 KB
medium/02_00_middle_16 WA 21 ms 792 KB
medium/02_00_middle_17 AC 19 ms 812 KB
medium/02_00_middle_18 WA 19 ms 792 KB
medium/02_00_middle_19 AC 20 ms 788 KB
medium/02_00_middle_2 AC 20 ms 700 KB
medium/02_00_middle_20 AC 20 ms 788 KB
medium/02_00_middle_21 AC 20 ms 784 KB
medium/02_00_middle_22 AC 21 ms 800 KB
medium/02_00_middle_23 AC 20 ms 792 KB
medium/02_00_middle_24 AC 19 ms 792 KB
medium/02_00_middle_25 AC 20 ms 796 KB
medium/02_00_middle_26 AC 19 ms 780 KB
medium/02_00_middle_27 AC 19 ms 664 KB
medium/02_00_middle_28 AC 19 ms 784 KB
medium/02_00_middle_29 AC 20 ms 792 KB
medium/02_00_middle_3 AC 19 ms 788 KB
medium/02_00_middle_30 AC 19 ms 788 KB
medium/02_00_middle_31 AC 21 ms 788 KB
medium/02_00_middle_32 AC 20 ms 792 KB
medium/02_00_middle_33 AC 20 ms 796 KB
medium/02_00_middle_34 AC 20 ms 696 KB
medium/02_00_middle_35 AC 19 ms 792 KB
medium/02_00_middle_36 AC 19 ms 784 KB
medium/02_00_middle_37 AC 20 ms 788 KB
medium/02_00_middle_38 AC 19 ms 792 KB
medium/02_00_middle_39 AC 19 ms 692 KB
medium/02_00_middle_4 AC 20 ms 696 KB
medium/02_00_middle_40 WA 19 ms 820 KB
medium/02_00_middle_41 WA 19 ms 788 KB
medium/02_00_middle_42 AC 19 ms 784 KB
medium/02_00_middle_43 WA 19 ms 792 KB
medium/02_00_middle_44 AC 20 ms 784 KB
medium/02_00_middle_45 AC 19 ms 788 KB
medium/02_00_middle_46 AC 20 ms 784 KB
medium/02_00_middle_47 AC 18 ms 792 KB
medium/02_00_middle_48 AC 20 ms 692 KB
medium/02_00_middle_49 AC 20 ms 792 KB
medium/02_00_middle_5 AC 19 ms 796 KB
medium/02_00_middle_6 AC 19 ms 792 KB
medium/02_00_middle_7 AC 19 ms 792 KB
medium/02_00_middle_8 AC 19 ms 792 KB
medium/02_00_middle_9 AC 19 ms 792 KB
medium/02_01_middle_random_0 AC 20 ms 784 KB
medium/02_01_middle_random_1 AC 23 ms 788 KB
medium/02_01_middle_random_2 AC 19 ms 788 KB
medium/02_01_middle_random_3 AC 19 ms 792 KB
small/00_manual1 AC 20 ms 792 KB
small/00_manual2 AC 20 ms 772 KB
small/01_small_0 AC 20 ms 768 KB
small/01_small_1 AC 19 ms 660 KB
small/01_small_10 AC 19 ms 692 KB
small/01_small_11 AC 20 ms 784 KB
small/01_small_12 AC 19 ms 784 KB
small/01_small_13 AC 19 ms 792 KB
small/01_small_14 AC 22 ms 656 KB
small/01_small_15 AC 19 ms 788 KB
small/01_small_2 AC 19 ms 784 KB
small/01_small_3 AC 19 ms 784 KB
small/01_small_4 AC 20 ms 812 KB
small/01_small_5 AC 19 ms 788 KB
small/01_small_6 AC 19 ms 692 KB
small/01_small_7 AC 19 ms 784 KB
small/01_small_8 AC 19 ms 788 KB
small/01_small_9 AC 20 ms 788 KB