답안 #255183

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255183 2020-07-31T13:51:31 Z shayan_p parentrises (BOI18_parentrises) C++14
50 / 100
158 ms 115320 KB
// And you curse yourself for things you never done

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 310, mod = 1e9 + 7, inf = 1e9 + 10;

int dp[maxn][2 * maxn][maxn]; // n // 2o - c // o - 2c
int ans[maxn];
	     
void add(int &A, int B){
    A = (A + B) % mod;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int P;
    cin >> P;
    assert(P == 2);

    dp[0][0][0] = 1;
    for(int n = 0; n < maxn - 5; n++){
	for(int sm = 0; sm <= 2 * n; sm++){
	    for(int mx = 0; mx <= n; mx++){
		add(dp[n + 1][sm + 2][max(int(0), mx + 1)], dp[n][sm][mx]);
		if(sm > 0)
		    add(dp[n+1][sm - 1][max(int(0), mx - 2)], dp[n][sm][mx]);
	    }
	    add(ans[n], dp[n][sm][0]);
	}
    }
    
    int q;
    cin >> q;
    while(q--){
	int n;
	cin >> n;
	cout << ans[n] << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 115320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 115320 KB Output is correct
2 Correct 158 ms 115184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 115320 KB Output is correct
2 Correct 158 ms 115184 KB Output is correct
3 Correct 153 ms 115192 KB Output is correct