답안 #47303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47303 2018-04-30T12:28:34 Z rkocharyan ZigZag (COCI17_zigzag) C++14
80 / 80
81 ms 13280 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <memory>
#include <functional>
#include <numeric>
#include <sstream>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <stack>
#include <set>
#include <unordered_set>
#include <map> 
#include <unordered_map>
#include <bitset>
#include <tuple>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <climits>
#include <ctime>
using namespace std;

#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define mp make_pair
#define add push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mem(a,b) memset(a, b, sizeof(a))
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:20000007")
#pragma GCC optimize("unroll-loops")

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;

typedef pair <int, int> pii;
typedef vector <int> lnum;

const int N = (int)1e6 + 100;
const int maxn = (int)1e3 + 100;
const int base = (int)1e9;
const int mod = (int)1e9 + 7;
const int inf = INT_MAX;
const long long ll_inf = LLONG_MAX;
const long double PI = acos((long double)-1.0);
const long double eps = 1e-8;

vector <string> G[26];
vector <int> now(26, 0);

void solve() {
	int n, q; cin >> n >> q;
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		int p = s[0] - 'a';
		G[p].push_back(s);
	}
	for (int i = 0; i < 26; ++i) {
		if (!G[i].empty()) sort(all(G[i]));
	}
	for (; q; --q) {
		char ch; cin >> ch; 
		int p = ch - 'a';
		cout << G[p][now[p]] << '\n';
		now[p]++;
		if (now[p] == G[p].size()) now[p] = 0;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

	//#define Freopen
#ifdef Freopen
#ifndef _MSC_VER 
#define TASK ""
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif
#endif

	int T = 1;
	//scanf("%d", &T);

	for (; T; --T) solve();

#ifdef DEBUG
	cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n';
#endif 

	return 0;
}

Compilation message

zigzag.cpp:36:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
zigzag.cpp:37:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:20000007")
 
zigzag.cpp: In function 'void solve()':
zigzag.cpp:75:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (now[p] == G[p].size()) now[p] = 0;
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 496 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 81 ms 8132 KB Output is correct
8 Correct 77 ms 9868 KB Output is correct
9 Correct 77 ms 11496 KB Output is correct
10 Correct 77 ms 13280 KB Output is correct