Submission #37978

#TimeUsernameProblemLanguageResultExecution timeMemory
37978wasylZigZag (COCI17_zigzag)C++11
56 / 80
196 ms7396 KiB
#include <vector>
#include <iostream>
#include <algorithm>
#define d(...) __VA_ARGS__
#define all(x) (x).begin(), (x).end()
#define eb(...) emplace_back(__VA_ARGS__)
using namespace std;using ll=long long;
template<class t>using V = vector< t >;

int n, k;
V< string > tab [26];

int main()
{
	ios::sync_with_stdio(false);
	cin >> k >> n;
	for ( int i = 0; i < k; ++i )
	{
		string z; cin >> z;
		tab[z[0] - 'a'].eb( move( z ) );
	}
	V< int > pt( 26 );
	
	for ( int i = 0; i < 26; ++i )
		sort( all( tab[i] ) );

	for ( int i = 0; i < n; ++i )
	{
		char c; cin >> c;
		c -= 'a';
		if ( pt[c] == tab[c].size() )
			pt[c] = 0;
		cout << tab[c][pt[c]] << '\n';
		++pt[c];
	}
}

Compilation message (stderr)

zigzag.cpp: In function 'int main()':
zigzag.cpp:31:22: warning: array subscript has type 'char' [-Wchar-subscripts]
   if ( pt[c] == tab[c].size() )
                      ^
zigzag.cpp:31:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if ( pt[c] == tab[c].size() )
              ^
zigzag.cpp:33:16: warning: array subscript has type 'char' [-Wchar-subscripts]
   cout << tab[c][pt[c]] << '\n';
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...