Submission #25934261


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
string new_order;
bool compare(string a, string b)
{
int i = 0;
while(a[i]==b[i])
{
i++;
if ( i >= a.size() ) return true;
if ( i >= b.size() ) return false;
}
int x, y;
for ( int j = 0 ; j < 26 ; j++ )
{
if ( new_order[j] == a[i] )
{
x = j;
break;
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
string new_order;
bool compare(string a, string b)
{
	int i = 0;
	while(a[i]==b[i])
	{
		i++;
		if ( i >= a.size() ) return true;
		if ( i >= b.size() ) return false;
	}
	int x, y;
	for ( int j = 0 ; j < 26 ; j++ )
	{
		if ( new_order[j] == a[i] )
		{
			x = j;
			break;
		}
	}
	for ( int j = 0 ; j < 26 ; j++ )
	{
		if ( new_order[j] == b[i] )
		{
			y = j;
			break;
		}
	}
	return x < y;
}


int main()
{
	cin >> new_order;
	int t;
	cin >> t;
	string seq[t];
	for ( int i = 0 ; i < t ; i++ ) cin >> seq[i];
	sort(seq, seq+t, compare);
	for ( int i = 0 ; i < t ; i++ ) cout << seq[i] << "\n";
}

Submission Info

Submission Time
Task C - Neo-lexicographic Ordering
User TanKaiYi0220
Language C++ (GCC 9.2.1)
Score 300
Code Size 685 Byte
Status AC
Exec Time 73 ms
Memory 5192 KB

Compile Error

./Main.cpp: In function ‘bool compare(std::string, std::string)’:
./Main.cpp:10:10: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   10 |   if ( i >= a.size() ) return true;
      |        ~~^~~~~~~~~~~
./Main.cpp:11:10: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   11 |   if ( i >= b.size() ) return false;
      |        ~~^~~~~~~~~~~
./Main.cpp:30:13: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |  return x < y;
      |             ^
./Main.cpp:30:13: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]

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 5 ms 3500 KB
example_01 AC 2 ms 3500 KB
max AC 70 ms 5164 KB
special_00 AC 72 ms 5060 KB
special_01 AC 72 ms 5068 KB
special_02 AC 72 ms 5164 KB
test_00 AC 73 ms 5192 KB
test_01 AC 34 ms 4100 KB
test_02 AC 25 ms 3852 KB
test_03 AC 31 ms 4172 KB
test_04 AC 54 ms 4740 KB
test_05 AC 69 ms 5040 KB
test_06 AC 23 ms 3956 KB
test_07 AC 46 ms 4384 KB


2025-02-28 (Fri)
11:28:10 +00:00