# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
381355 |
2021-03-25T06:56:18 Z |
ikg |
ZigZag (COCI17_zigzag) |
C++14 |
|
367 ms |
23916 KB |
// by ikg
#include <bits/stdc++.h>
using namespace std;
const int E9 = 1e9;
const int E8 = 1e8;
const int E7 = 1e7;
const int E6 = 1e6;
const int E5 = 1e5;
const int E4 = 1e4;
const int E3 = 1e3;
const int N = 5e5+7;
const long long INF = 1e18;
#define gcd __gcd
#define ll long long
#define pb push_back
#define re return
#define fi first
#define se second
#define ld long double
#define debug cout<<"bug "
#define endl cout<<'\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sd(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define sld(x) scanf("%lf",&x)
#define pd(x) printf("%d",x)
#define pll(x) printf("%lld",x)
#define pld(x) printf("%lf",x)
string s[N];
map<char, vector<string> > mp;
map<char, int> us, k;
int main ()
{
int n, q;
cin >> n >> q;
for (int i = 1; i <= n; ++i)
{
cin >> s[i];
k[s[i][0]]++;
}
endl;
sort(s+1,s+1+n);
for (int i = 1; i <= n; ++i)
{
mp[s[i][0]].pb(s[i]);
}
while (q--)
{
char c;
cin >> c;
us[c]++;
if (us[c]>k[c])
{
cout << mp[c][0];
}
else
{
cout << mp[c][us[c]-1];
}
endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
16000 KB |
Output is correct |
2 |
Incorrect |
12 ms |
15980 KB |
Output isn't correct |
3 |
Correct |
12 ms |
15980 KB |
Output is correct |
4 |
Correct |
13 ms |
15980 KB |
Output is correct |
5 |
Incorrect |
12 ms |
15980 KB |
Output isn't correct |
6 |
Incorrect |
13 ms |
15980 KB |
Output isn't correct |
7 |
Incorrect |
359 ms |
23660 KB |
Output isn't correct |
8 |
Incorrect |
365 ms |
23788 KB |
Output isn't correct |
9 |
Incorrect |
367 ms |
23788 KB |
Output isn't correct |
10 |
Incorrect |
361 ms |
23916 KB |
Output isn't correct |