Submission #1275233

#TimeUsernameProblemLanguageResultExecution timeMemory
1275233SmuggingSpunZigZag (COCI17_zigzag)C++20
80 / 80
62 ms6892 KiB
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>>pq[26];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	int k, n;
	cin >> k >> n;
	for(int i = 0; i < k; i++){
		string s;
		cin >> s;
		pq[s[0] - 'a'].emplace(0, s);
	}
	for(int i = 0; i < n; i++){
		char c;
		cin >> c;
		pair<int, string>s = pq[c -= 'a'].top();
		pq[c].pop();
		pq[c].emplace(s.first + 1, s.second);
		cout << s.second << "\n";
	}
}

Compilation message (stderr)

zigzag.cpp: In function 'int main()':
zigzag.cpp:8:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...