提出 #6671938


ソースコード 拡げる

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;
}




提出情報

提出日時
問題 L - じゃんけん
ユーザ hamayanhamayan
言語 C++14 (GCC 5.4.1)
得点 0
コード長 2247 Byte
結果 WA
実行時間 286 ms
メモリ 16256 KB

ジャッジ結果

セット名 Sample Subtask1
得点 / 配点 0 / 0 0 / 500
結果
AC × 2
AC × 33
WA × 11
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
in01.txt AC 1 ms 384 KB
in02.txt AC 1 ms 384 KB
in03.txt AC 1 ms 384 KB
in04.txt AC 1 ms 384 KB
in05.txt AC 1 ms 384 KB
in06.txt AC 1 ms 384 KB
in07.txt AC 1 ms 384 KB
in08.txt WA 1 ms 384 KB
in09.txt AC 1 ms 384 KB
in10.txt WA 1 ms 384 KB
in11.txt AC 159 ms 16128 KB
in12.txt AC 159 ms 16128 KB
in13.txt WA 160 ms 16128 KB
in14.txt AC 157 ms 16128 KB
in15.txt WA 155 ms 16128 KB
in16.txt WA 157 ms 16128 KB
in17.txt AC 155 ms 16128 KB
in18.txt WA 160 ms 16128 KB
in19.txt AC 155 ms 16128 KB
in20.txt AC 153 ms 16128 KB
in21.txt AC 282 ms 16128 KB
in22.txt AC 284 ms 16128 KB
in23.txt AC 284 ms 16128 KB
in24.txt AC 286 ms 16128 KB
in25.txt AC 283 ms 16128 KB
in26.txt AC 285 ms 16128 KB
in27.txt AC 283 ms 16128 KB
in28.txt AC 284 ms 16128 KB
in29.txt AC 282 ms 16128 KB
in30.txt AC 286 ms 16128 KB
in31.txt WA 45 ms 16128 KB
in32.txt AC 49 ms 16128 KB
in33.txt WA 48 ms 16128 KB
in34.txt AC 59 ms 14592 KB
in35.txt AC 60 ms 14592 KB
in36.txt AC 61 ms 14592 KB
in37.txt AC 220 ms 16128 KB
in38.txt AC 222 ms 16256 KB
in39.txt AC 221 ms 16128 KB
in40.txt WA 103 ms 16128 KB
in41.txt WA 102 ms 16128 KB
in42.txt WA 105 ms 16128 KB
sample_01.txt AC 1 ms 384 KB
sample_02.txt AC 1 ms 384 KB