QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#322313#6768. Nihongo wa Muzukashii Desumshcherba#AC ✓1ms3804kbC++201.1kb2024-02-06 20:10:332024-02-06 20:10:33

Judging History

你现在查看的是最新测评结果

  • [2024-02-06 20:10:33]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3804kb
  • [2024-02-06 20:10:33]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

string f(const string& s, string t)
{
	if (SZ(s) >= SZ(t) && s.substr(SZ(s) - SZ(t), SZ(t)) == t)
		return s.substr(0, SZ(s) - SZ(t));
	return "";
}

void solve()
{
	string s;
	cin >> s;
	if (s == "ikimasu")
	{
		cout << "itte\n";
		return;
	}
	vector<vector<string>> masu = {{"chimasu", "rimasu"}, {"mimasu", "bimasu", "nimasu"}, {"kimasu"}, {"gimasu"}, {"shimasu"}};
	vector<string> te = {"tte", "nde", "ite", "ide", "shite"};
	FOR(i, 0, 5)
	{
		string t;
		for (string r : masu[i])
			t += f(s, r);
		if (!t.empty())
		{
			cout << t << te[i] << "\n";
			return;
		}
	}
	assert(false);
}

int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3804kb

input:

10
machimasu
kaerimasu
nomimasu
yobimasu
shinimasu
kakimasu
ikimasu
kikimasu
isogimasu
kashimasu

output:

matte
kaette
nonde
yonde
shinde
kaite
itte
kiite
isoide
kashite

result:

ok 10 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

63
machimasu
kaerimasu
nomimasu
yobimasu
shinimasu
kakimasu
ikimasu
isogimasu
kashimasu
hatarakimasu
yasumimasu
owarimasu
yomimasu
kikimasu
torimasu
okurimasu
kirimasu
karimasu
arimasu
kakarimasu
asobimasu
oyogimasu
kawakimasu
sukimasu
mochimasu
hanashimasu
hurimasu
hairimasu
suwarimasu
tachimasu
ke...

output:

matte
kaette
nonde
yonde
shinde
kaite
itte
isoide
kashite
hataraite
yasunde
owatte
yonde
kiite
totte
okutte
kitte
katte
atte
kakatte
asonde
oyoide
kawaite
suite
motte
hanashite
hutte
haitte
suwatte
tatte
keshite
shitte
sunde
omoikishite
oite
utte
tsukutte
notte
oshite
oroshite
dashite
kaeshite
meide...

result:

ok 63 lines