Submission #888332

# Submission time Handle Problem Language Result Execution time Memory
888332 2023-12-17T01:41:10 Z hwy Fortune Telling 2 (JOI14_fortune_telling2) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, k;
	vector<pair<ll, ll>> cards;
	vector<ll> ops;
	ll ans = 0;
	ll curr_num;
	
	for (ll i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		cards.push_back({a, b});
	}
	
	for (ll i = 0; i < k; i++) {
		ll temp;
		cin >> temp;
		ops.push_back(temp);
	}
	
	for (ll i = 0; i < n; i++) {
		curr_num = cards[i].first;
		for (ll j = 0; j < k; j++) {
			if (curr_num <= ops[j]) {
				if (curr_num == cards[i].first)
					curr_num = cards[i].second;
				else if (curr_num == cards[i].second)
					curr_num = cards[i].first;
			}
		}
		ans += curr_num;
	}
	cout << ans;
	return 0;
}
				

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:15:19: warning: 'n' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |  for (ll i = 0; i < n; i++) {
      |                 ~~^~~
fortune_telling2.cpp:21:19: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |  for (ll i = 0; i < k; i++) {
      |                 ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -