Submission #6671938


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/










int N, M, K, X, Y;
vector<int> E[2020];
char C[2020];
int D[2010];
int dp[2010][2010];
//---------------------------------------------------------------------------------------------------
inline int get(char me, char you) {
	if (me == you) return 0;
	if (me == 'G' and you == 'C') return X;
	if (me == 'C' and you == 'P') return X;
	if (me == 'P' and you == 'G') return X;
	return Y;
}
void _main() {
	cin >> N >> M >> K >> X >> Y;
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	rep(i, 0, N) cin >> C[i];
	rep(i, 0, K) {
		cin >> D[i];
		D[i]--;
	}

	rep(k, 0, K + 1) rep(cu, 0, N) dp[k][cu] = -inf;
	dp[0][0] = 0;
	rep(k, 0, K) rep(cu, 0, N) if (0 <= dp[k][cu]) {
		chmax(dp[k + 1][cu], dp[k][cu] + get(C[cu], C[D[k]]));
		fore(to, E[cu]) chmax(dp[k + 1][to], dp[k][cu] + get(C[to], C[D[k]]));
	}

	int ans = 0;
	rep(cu, 0, N) chmax(ans, dp[K][cu]);
	cout << ans << endl;
}




Submission Info

Submission Time
Task L - じゃんけん
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2247 Byte
Status
Exec Time 286 ms
Memory 16256 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 0 / 500
Status
× 2
× 33
× 11
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
Subtask1 sample_01.txt, sample_02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in40.txt, in41.txt, in42.txt
Case Name Status Exec Time Memory
in01.txt 1 ms 384 KB
in02.txt 1 ms 384 KB
in03.txt 1 ms 384 KB
in04.txt 1 ms 384 KB
in05.txt 1 ms 384 KB
in06.txt 1 ms 384 KB
in07.txt 1 ms 384 KB
in08.txt 1 ms 384 KB
in09.txt 1 ms 384 KB
in10.txt 1 ms 384 KB
in11.txt 159 ms 16128 KB
in12.txt 159 ms 16128 KB
in13.txt 160 ms 16128 KB
in14.txt 157 ms 16128 KB
in15.txt 155 ms 16128 KB
in16.txt 157 ms 16128 KB
in17.txt 155 ms 16128 KB
in18.txt 160 ms 16128 KB
in19.txt 155 ms 16128 KB
in20.txt 153 ms 16128 KB
in21.txt 282 ms 16128 KB
in22.txt 284 ms 16128 KB
in23.txt 284 ms 16128 KB
in24.txt 286 ms 16128 KB
in25.txt 283 ms 16128 KB
in26.txt 285 ms 16128 KB
in27.txt 283 ms 16128 KB
in28.txt 284 ms 16128 KB
in29.txt 282 ms 16128 KB
in30.txt 286 ms 16128 KB
in31.txt 45 ms 16128 KB
in32.txt 49 ms 16128 KB
in33.txt 48 ms 16128 KB
in34.txt 59 ms 14592 KB
in35.txt 60 ms 14592 KB
in36.txt 61 ms 14592 KB
in37.txt 220 ms 16128 KB
in38.txt 222 ms 16256 KB
in39.txt 221 ms 16128 KB
in40.txt 103 ms 16128 KB
in41.txt 102 ms 16128 KB
in42.txt 105 ms 16128 KB
sample_01.txt 1 ms 384 KB
sample_02.txt 1 ms 384 KB