Submission #25939806


Source Code Expand

#include <bits/stdc++.h>
#define ll long long 
#define ft first
#define sec second
#define pb push_back
#define pf push_front
#define pr pair<ll,ll>
#define bged(a) a.begin(),a.end()
#define ISCC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#pragma optimize("Ofast","unroll-loop")
using namespace std;
const int MOD = 1e9+7; 
int t ,n ,m ,k ,pos[30];
string a[500005] ,s ,ans;
bool cmp(string x ,string y)
{
	int lx=x.size() ,ly=y.size();	
	for(int i=0 ;i<min(lx ,ly) ;i++)
	{
		if(pos[x[i]-'a'] < pos[y[i]-'a']) return true;
		else if(pos[x[i]-'a'] > pos[y[i]-'a']) return false;
	} 
	if(lx != ly) return lx<ly;
	return false;
}
int main()
{ 	
	
	cin >> s;
	cin >> n;
	for(int i=0 ;i<n ;i++) cin >> a[i];
	for(int i=0 ;i<26 ;i++) pos[s[i]-'a'] = i;
	sort(a ,a+n ,cmp);
	for(int i=0 ;i<n ;i++) cout << a[i] << '\n';
	return 0;
}

Submission Info

Submission Time
Task C - Neo-lexicographic Ordering
User ck1080012
Language C++ (GCC 9.2.1)
Score 300
Code Size 868 Byte
Status AC
Exec Time 66 ms
Memory 19264 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 14
Set Name Test Cases
Sample example_00, example_01
All example_00, example_01, max, special_00, special_01, special_02, test_00, test_01, test_02, test_03, test_04, test_05, test_06, test_07
Case Name Status Exec Time Memory
example_00 AC 17 ms 19260 KiB
example_01 AC 18 ms 19160 KiB
max AC 60 ms 19180 KiB
special_00 AC 66 ms 19128 KiB
special_01 AC 65 ms 19260 KiB
special_02 AC 62 ms 19252 KiB
test_00 AC 64 ms 19064 KiB
test_01 AC 40 ms 19188 KiB
test_02 AC 27 ms 19164 KiB
test_03 AC 37 ms 19160 KiB
test_04 AC 52 ms 19224 KiB
test_05 AC 60 ms 19264 KiB
test_06 AC 31 ms 19068 KiB
test_07 AC 45 ms 19104 KiB