Submission #1047202


Source Code Expand

//#define USEPB_DS
#define USETR1
#define CPPELEVEN
#define GPP

/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <list>
#include <iomanip>
#include <math.h>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <climits>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <tuple>

using namespace std;

#ifndef CPPELEVEN
#ifdef USETR1
#include <tr1/unordered_map>
#include <tr1/unordered_set>
using namespace tr1;
#endif
#else
#include <unordered_map>
#include <unordered_set>
#endif

#ifdef USEPB_DS
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// binomial_heap_tag, rc_binomial_heap_tag, thin_heap_tag, binary_heap_tag
typedef __gnu_pbds::priority_queue<int, greater<int>, pairing_heap_tag> pq_type;
// splay_tree_tag, ov_tree_tag
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> tree_type;
#endif

#define mpr make_pair
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <double> vd;
typedef vector <string> vs;
typedef map <string, int> mpsi;
typedef map <double, int> mpdi;
typedef map <int, int> mpii;

const double pi = acos(0.0) * 2.0;
const long double eps = 1e-10;
const int step[8][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};

template <class T> inline T abs1(T a) {return a < 0 ? -a : a;}

#ifndef CPPELEVEN
template <class T> inline T max1(T a, T b) { return b < a ? a : b; }
template <class T> inline T max1(T a, T b, T c) { return max1(max1(a, b), c); }
template <class T> inline T max1(T a, T b, T c, T d) { return max1(max1(a, b, c), d); }
template <class T> inline T max1(T a, T b, T c, T d, T e) { return max1(max1(a, b, c, d), e); }
template <class T> inline T min1(T a, T b) { return a < b ? a : b; }
template <class T> inline T min1(T a, T b, T c) { return min1(min1(a, b), c); }
template <class T> inline T min1(T a, T b, T c, T d) { return min1(min1(a, b, c), d); }
template <class T> inline T min1(T a, T b, T c, T d, T e) { return min1(min1(a, b, c, d), e); }
#else
template <typename t, typename t1>
t min1(t a, t1 b) { return a < b ? a : b; }
template <typename t, typename... arg>
t min1(t a, arg... arr) { return min1(a, min1(arr...)); }
template <typename t, typename t1>
t max1(t a, t1 b) { return a > b ? a : b; }
template <typename t, typename... arg>
t max1(t a, arg... arr) { return max1(a, max1(arr...)); }
#endif

inline int jud(double a, double b){
	if(abs(a) < eps && abs(b) < eps) return 0;
	else if(abs1(a - b) / max(abs1(a), abs1(b)) < eps) return 0;
	if(a < b) return -1;
	return 1;
}
template <typename t> inline int jud(t a, t b){
	if(a < b) return -1;
	if(a == b) return 0;
	return 1;
}

// f_lb == 1代表返回相同的一串的左边界,f_small == 1代表返回如果没有寻找的值返回小的数
template <typename it, typename t1>
inline int find(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1){
	if(na == 0) return 0;
	int be = 0, en = na - 1;
	if(*a <= *(a + na - 1)){
		if(f_lb == 0) while(be < en){
			int mid = (be + en + 1) / 2;
			if(jud(*(a + mid), val) != 1) be = mid;
			else en = mid - 1;
		}else while(be < en){
			int mid = (be + en) / 2;
			if(jud(*(a + mid), val) != -1) en = mid;
			else be = mid + 1;
		}
		if(f_small && jud(*(a + be), val) == 1) be--;
		if(!f_small && jud(*(a + be), val) == -1) be++;
	} else {
		if(f_lb) while(be < en){
			int mid = (be + en + 1) / 2;
			if(jud(*(a + mid), val) != -1) be = mid;
			else en = mid - 1;
		}else while(be < en){
			int mid = (be + en) / 2;
			if(jud(*(a + mid), val) != 1) en = mid;
			else be = mid + 1;
		}
		if(!f_small && jud(*(a + be), val) == -1) be--;
		if(f_small && jud(*(a + be), val) == 1) be++;
	}
	return be;
}

template <class T> inline T lowb(T num) {return num & (-num); }
#ifdef GPP
inline int bitnum(ui nValue) { return __builtin_popcount(nValue); }
inline int bitnum(int nValue) { return __builtin_popcount(nValue); }
inline int bitnum(ull nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }
inline int bitnum(ll nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }
inline int bitmaxl(ui a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }
inline int bitmaxl(int a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }
inline int bitmaxl(ull a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }
inline int bitmaxl(ll a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }
#else
#endif

long long pow(long long n, long long m, long long mod = 0){
	if(m < 0) return 0;
	long long ans = 1;
	long long k = n;
	while(m){
		if(m & 1) {
			ans *= k;
			if(mod) ans %= mod;
		}
		k *= k;
		if(mod) k %= mod;
		m >>= 1;
	}
	return ans;
}

#define  MOD 1000000007
template <class t1, class t2>
inline void add(t1 &a, t2 b, int mod = -1) {
	if(mod == -1) mod = MOD;
	a += b;
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
}
template <class t>
void output1(t arr) {
	for(int i = 0; i < (int)arr.size(); i++)
		cerr << arr[i] << ' ';
	cerr << endl;
}
template <class t>
void output2(t arr) {
	for(int i = 0; i < (int)arr.size(); i++)
		output1(arr[i]);
}

//....................密..........封..........线..........下..........禁..........止..........hack...............................................

const int mod = MOD;
const int maxn = 310;
int rk, n;
int arr[maxn][maxn];
ll dp[2][maxn][maxn];
ll mi[maxn];

int gauss() {
	int have = 0;
	for(int i = 0; i < n; i++) {
		int no = -1;
		for(int j = have; j < n; j++) if(arr[j][i])
			no = j;
		if(no == -1) continue;
		for(int j = 0; j < n; j++)
			swap(arr[have][j], arr[no][j]);
		for(int j = 0; j < n; j++) if(j != have && arr[j][i]) {
			for(int k = 0; k < n; k++)
				arr[j][k] ^= arr[have][k];
		}
		have++;
	}
	return have;
}

int main() {


//............................不要再忘了检查maxn大小了!!!!BSBandme你个SB!!!!...................................................

	ios_base::sync_with_stdio(0);
	#ifdef DEBUG //......................................................................................................
	freopen("input.txt", "r", stdin);
	int __size__ = 256 << 20; // 256MB
	char *__p__ = (char*)malloc(__size__) + __size__;
	__asm__("movl %0, %%esp\n" :: "r"(__p__));
	#endif //...........................................................................................................

	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			scanf("%d", arr[i] + j);

	rk = gauss();
	memset(dp, 0, sizeof(dp));
	dp[0][0][0] = 1;
	mi[0] = 1;
	for(int j = 1; j < maxn; j++) {
		mi[j] = mi[j - 1]	 * 2 % mod;
	}
	int now = 0, nxt = 1;
	for(int i = 0; i < n; i++) {
		memset(dp[nxt], 0, sizeof(dp[nxt]));
		for(int j = 0; j <= min(rk, i); j++) for(int k = j; k <= i; k++) if(dp[now][j][k]) {
			add(dp[nxt][j + 1][k + 1], dp[now][j][k] * (mi[rk] - mi[j]) % mod * mi[k - j] % mod);
			add(dp[nxt][j][k + 1], dp[now][j][k] * (mi[n] - mi[k] - (mi[rk] - mi[j]) * mi[k - j] % mod) % mod);
			add(dp[nxt][j][k], dp[now][j][k] * mi[k] % mod);
		}
		swap(now, nxt);
	}

	int ans = 0;
	for(int i = rk; i <= n; i++)
		add(ans, dp[now][rk][i] * pow(mi[n - i], n, mod) % mod);

	cout << ans << endl;


    return 0;
}

Submission Info

Submission Time
Task H - AB=C Problem
User BSBandme
Language C++14 (GCC 5.4.1)
Score 1500
Code Size 8122 Byte
Status AC
Exec Time 110 ms
Memory 2176 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:240:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:243:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", arr[i] + j);
                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1500 / 1500
Status
AC × 2
AC × 42
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 4 ms 1792 KB
001.txt AC 4 ms 1792 KB
002.txt AC 4 ms 1792 KB
003.txt AC 4 ms 1792 KB
004.txt AC 4 ms 1792 KB
005.txt AC 4 ms 1792 KB
006.txt AC 4 ms 1792 KB
007.txt AC 4 ms 1792 KB
008.txt AC 4 ms 1792 KB
009.txt AC 4 ms 1792 KB
010.txt AC 4 ms 1792 KB
011.txt AC 4 ms 1792 KB
012.txt AC 4 ms 1792 KB
013.txt AC 4 ms 1792 KB
014.txt AC 13 ms 1920 KB
015.txt AC 14 ms 1920 KB
016.txt AC 9 ms 1792 KB
017.txt AC 16 ms 2048 KB
018.txt AC 8 ms 1792 KB
019.txt AC 5 ms 1792 KB
020.txt AC 23 ms 1920 KB
021.txt AC 105 ms 2176 KB
022.txt AC 8 ms 1792 KB
023.txt AC 60 ms 2176 KB
024.txt AC 51 ms 2176 KB
025.txt AC 110 ms 2176 KB
026.txt AC 101 ms 2176 KB
027.txt AC 103 ms 2176 KB
028.txt AC 38 ms 2176 KB
029.txt AC 110 ms 2176 KB
030.txt AC 105 ms 2176 KB
031.txt AC 109 ms 2176 KB
032.txt AC 25 ms 2176 KB
033.txt AC 92 ms 2176 KB
034.txt AC 23 ms 2176 KB
035.txt AC 17 ms 2048 KB
036.txt AC 38 ms 2176 KB
037.txt AC 33 ms 2048 KB
038.txt AC 29 ms 2176 KB
039.txt AC 41 ms 2176 KB
example0.txt AC 4 ms 1792 KB
example1.txt AC 5 ms 1792 KB