# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287834 | 2020-09-01T03:53:34 Z | chubyxdxd | ZigZag (COCI17_zigzag) | C++17 | 301 ms | 6608 KB |
#include <bits/stdc++.h> #define all(a) a.begin(),a.end() #define allr(a) a.rbegin(),a.rend() #define ff first #define sc second #define INF 3000000000 #define SINF 2*(1e18) #define inf -10000000 #define pb push_back #define forr(i,p,n) for(int i=p;i<n;i++) #define mpk make_pair #define upb(a,s) upper_bound(a.begin(),a.end(),s) #define lwb(a,s) lower_bound(a.begin(),a.end(),s) #define mem(a,val) memset(a,val,sizeof a) #define cc continue #define eb emplace_back #define bb break #define mostbit(n) 32-__builtin_clz(n)-1 #define time_to_forget cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n" using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef pair<ll,ll> ii; typedef vector<ii> vii; typedef vector<ll> vi; typedef vector<vi> vvi; int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(); ll a,b,c,d,n,t,m,k; cin>>n>>m; map<char,vector<string>> mp; map<char,int> mo; string s; char ch; forr(i,0,n){ cin>>s; mp[s[0]].pb(s); } for(auto it=mp.begin();it!=mp.end();it++){ sort(all(mp[(*it).ff])); mo[(*it).ff]=0; } forr(i,0,m){ cin>>ch; cout<<mp[ch][mo[ch]]<<endl; mo[ch]++; mo[ch]%=mp[ch].size(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 294 ms | 6520 KB | Output is correct |
8 | Correct | 301 ms | 6608 KB | Output is correct |
9 | Correct | 294 ms | 6520 KB | Output is correct |
10 | Correct | 299 ms | 6520 KB | Output is correct |