[NOIP2017 提高组] 时间复杂度
2024年12月25日小于 1 分钟
27 分
#include <bits/stdc++.h>
using namespace std;
int t;
int l;
string tim; // 时间复杂度
int timInt; // n^timInt 时间复杂度
char op, ii;
string x, y;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> t;
while (t--)
{
cin >> l >> tim;
timInt = 0;
if (tim != "O(1)")
{
timInt = 0;
for (int i = 4; i <= (int)tim.size() - 1; i++)
if ('0' <= tim[i] && tim[i] <= '9')
timInt = timInt * 10 + tim[i] - '0';
else
break;
}
int cntN = 0;
for (int i = 1; i <= l / 2; i++)
{
cin >> op >> ii >> x >> y;
if (y == "n")
cntN++;
}
for (int i = 1; i <= l / 2; i++)
cin >> op; // 吃掉后面的 E;
if (cntN == timInt)
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}