QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#570410#9320. Find the Easiest ProblemNiiuAC ✓20ms6984kbC++148.0kb2024-09-17 15:42:192024-09-17 15:42:24

Judging History

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

  • [2024-09-17 15:42:24]
  • 评测
  • 测评结果:AC
  • 用时:20ms
  • 内存:6984kb
  • [2024-09-17 15:42:19]
  • 提交

answer

#include <bits/stdc++.h>
#define IOS                      \
	ios::sync_with_stdio(false); \
	cin.tie(nullptr);
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
using namespace std;
using i32 = int;
using i64 = long long;
using i128 = __int128;

template <typename T>
T read()
{
	T sum = 0, fl = 1;
	int ch = getchar();
	for (; !isdigit(ch); ch = getchar())
		if (ch == '-')
			fl = -1;
	for (; isdigit(ch); ch = getchar())
		sum = sum * 10 + ch - '0';
	return sum * fl;
}

template <typename T>
void write(T x)
{
	if (x < 0)
	{
		x = -x;
		putchar('-');
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}

template <typename T>
constexpr T power(T a, i64 b)
{
    T res = 1;
    for (; b; b /= 2, a *= a) {
        if (b % 2) {
            res *= a;
        }
    }
    return res;
}

constexpr i64 mul(i64 a, i64 b, i64 p)
{
    i64 res = a * b - i64(1.L * a * b / p) * p;
    res %= p;
    if (res < 0) {
        res += p;
    }
    return res;
}
template <i64 P>
struct MLong {
    i64 x;
    constexpr MLong()
        : x {}
    {
    }
    constexpr MLong(i64 x)
        : x { norm(x % getMod()) }
    {
    }

    static i64 Mod;
    constexpr static i64 getMod()
    {
        if (P > 0) {
            return P;
        } else {
            return Mod;
        }
    }
    constexpr static void setMod(i64 Mod_)
    {
        Mod = Mod_;
    }
    constexpr i64 norm(i64 x) const
    {
        if (x < 0) {
            x += getMod();
        }
        if (x >= getMod()) {
            x -= getMod();
        }
        return x;
    }
    constexpr i64 val() const
    {
        return x;
    }
    explicit constexpr operator i64() const
    {
        return x;
    }
    constexpr MLong operator-() const
    {
        MLong res;
        res.x = norm(getMod() - x);
        return res;
    }
    constexpr MLong inv() const
    {
        assert(x != 0);
        return power(*this, getMod() - 2);
    }
    constexpr MLong& operator*=(MLong rhs) &
    {
        x = mul(x, rhs.x, getMod());
        return *this;
    }
    constexpr MLong& operator+=(MLong rhs) &
    {
        x = norm(x + rhs.x);
        return *this;
    }
    constexpr MLong& operator-=(MLong rhs) &
    {
        x = norm(x - rhs.x);
        return *this;
    }
    constexpr MLong& operator/=(MLong rhs) &
    {
        return *this *= rhs.inv();
    }
    friend constexpr MLong operator*(MLong lhs, MLong rhs)
    {
        MLong res = lhs;
        res *= rhs;
        return res;
    }
    friend constexpr MLong operator+(MLong lhs, MLong rhs)
    {
        MLong res = lhs;
        res += rhs;
        return res;
    }
    friend constexpr MLong operator-(MLong lhs, MLong rhs)
    {
        MLong res = lhs;
        res -= rhs;
        return res;
    }
    friend constexpr MLong operator/(MLong lhs, MLong rhs)
    {
        MLong res = lhs;
        res /= rhs;
        return res;
    }
    friend constexpr std::istream& operator>>(std::istream& is, MLong& a)
    {
        i64 v;
        is >> v;
        a = MLong(v);
        return is;
    }
    friend constexpr std::ostream& operator<<(std::ostream& os, const MLong& a)
    {
        return os << a.val();
    }
    friend constexpr bool operator==(MLong lhs, MLong rhs)
    {
        return lhs.val() == rhs.val();
    }
    friend constexpr bool operator!=(MLong lhs, MLong rhs)
    {
        return lhs.val() != rhs.val();
    }
};

template <>
i64 MLong<0LL>::Mod = 1;

template <int P>
struct MInt {
    int x;
    constexpr MInt()
        : x {}
    {
    }
    constexpr MInt(i64 x)
        : x { norm(x % getMod()) }
    {
    }

    static int Mod;
    constexpr static int getMod()
    {
        if (P > 0) {
            return P;
        } else {
            return Mod;
        }
    }
    constexpr static void setMod(int Mod_)
    {
        Mod = Mod_;
    }
    constexpr int norm(int x) const
    {
        if (x < 0) {
            x += getMod();
        }
        if (x >= getMod()) {
            x -= getMod();
        }
        return x;
    }
    constexpr int val() const
    {
        return x;
    }
    explicit constexpr operator int() const
    {
        return x;
    }
    constexpr MInt operator-() const
    {
        MInt res;
        res.x = norm(getMod() - x);
        return res;
    }
    constexpr MInt inv() const
    {
        assert(x != 0);
        return power(*this, getMod() - 2);
    }
    constexpr MInt& operator*=(MInt rhs) &
    {
        x = 1LL * x * rhs.x % getMod();
        return *this;
    }
    constexpr MInt& operator+=(MInt rhs) &
    {
        x = norm(x + rhs.x);
        return *this;
    }
    constexpr MInt& operator-=(MInt rhs) &
    {
        x = norm(x - rhs.x);
        return *this;
    }
    constexpr MInt& operator/=(MInt rhs) &
    {
        return *this *= rhs.inv();
    }
    friend constexpr MInt operator*(MInt lhs, MInt rhs)
    {
        MInt res = lhs;
        res *= rhs;
        return res;
    }
    friend constexpr MInt operator+(MInt lhs, MInt rhs)
    {
        MInt res = lhs;
        res += rhs;
        return res;
    }
    friend constexpr MInt operator-(MInt lhs, MInt rhs)
    {
        MInt res = lhs;
        res -= rhs;
        return res;
    }
    friend constexpr MInt operator/(MInt lhs, MInt rhs)
    {
        MInt res = lhs;
        res /= rhs;
        return res;
    }
    friend constexpr std::istream& operator>>(std::istream& is, MInt& a)
    {
        i64 v;
        is >> v;
        a = MInt(v);
        return is;
    }
    friend constexpr std::ostream& operator<<(std::ostream& os, const MInt& a)
    {
        return os << a.val();
    }
    friend constexpr bool operator==(MInt lhs, MInt rhs)
    {
        return lhs.val() == rhs.val();
    }
    friend constexpr bool operator!=(MInt lhs, MInt rhs)
    {
        return lhs.val() != rhs.val();
    }
};

template <>
int MInt<0>::Mod = 1;

template <int V, int P>
constexpr MInt<P> CInv = MInt<P>(V).inv();

constexpr int P = 1e9 + 7;//改取模数
using Z = MInt<P>;

struct Comb {
    int n;
    std::vector<Z> _fac;
    std::vector<Z> _invfac;
    std::vector<Z> _inv;

    Comb()
        : n { 0 }
        , _fac { 1 }
        , _invfac { 1 }
        , _inv { 0 }
    {
    }
    Comb(int n)
        : Comb()
    {
        init(n);
    }

    void init(int m)
    {
        if (m <= n)
            return;
        _fac.resize(m + 1);
        _invfac.resize(m + 1);
        _inv.resize(m + 1);

        for (int i = n + 1; i <= m; i++) {
            _fac[i] = _fac[i - 1] * i;
        }
        _invfac[m] = _fac[m].inv();
        for (int i = m; i > n; i--) {
            _invfac[i - 1] = _invfac[i] * i;
            _inv[i] = _invfac[i] * _fac[i - 1];
        }
        n = m;
    }

    Z fac(int m)
    {
        if (m > n)
            init(2 * m);
        return _fac[m];
    }
    Z invfac(int m)
    {
        if (m > n)
            init(2 * m);
        return _invfac[m];
    }
    Z inv(int m)
    {
        if (m > n)
            init(2 * m);
        return _inv[m];
    }
    Z binom(int n, int m)
    {
        if (n < m || m < 0)
            return 0;
        return fac(n) * invfac(m) * invfac(n - m);
    }
} comb;


void solve()
{
	map<pair<string,string>,int>mp;
    vector<int> ch(26,0);
    int n;
    cin>>n;
    while(n--)
    {
        string team,s1,s2;
        cin>>team>>s1>>s2;
        if(s2[0]=='a')
        {
            if(mp[{team,s1}])continue;
            mp[{team,s1}]++;
            ch[s1[0]-'A']++;
        }
    }
    int ans=0;
    char res;
    for(int i=0;i<26;i++)
    {
        if(ans<ch[i])
        {
            ans=ch[i];
            res=i+'A';
        }
    }
    cout<<res<<'\n';
}

signed main()
{
	IOS 
	int T = 1;
	cin>>T;
	while (T--)
	{
		solve();
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

input:

2
5
teamA A accepted
teamB B rejected
teamC A accepted
teamB B accepted
teamD C accepted
4
teamA A rejected
teamB A accepted
teamC B accepted
teamC B accepted

output:

A
A

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 11ms
memory: 3828kb

input:

1000
44
WaiooyIXa O accepted
WaiooyIXa P accepted
ZYYsNWag P accepted
DPIawQg D rejected
IzPdjnM Z rejected
Ra D rejected
kwQyGxLo I rejected
DPIawQg L accepted
kwQyGxLo I accepted
mmWxDuADCB D rejected
PXwVAOgwiz P rejected
ZYYsNWag U accepted
IzPdjnM Z accepted
TgBNO P rejected
kwQyGxLo J accepted...

output:

Z
E
Z
I
B
I
G
H
S
K
J
I
H
R
Z
C
K
O
I
P
A
B
I
A
A
N
A
B
A
O
F
O
R
T
H
G
K
E
S
D
F
D
R
C
U
V
W
P
A
O
J
E
A
B
U
M
C
T
L
G
V
A
Z
N
E
O
Q
F
B
G
J
I
E
M
A
A
E
A
K
J
J
S
E
W
Z
K
F
I
S
P
M
H
G
G
H
W
I
P
T
D
O
A
F
N
C
S
Y
Z
S
G
J
F
Q
F
O
C
B
B
U
C
I
A
E
I
P
K
C
R
X
N
D
N
L
Q
L
I
X
I
H
U
J
Z
D
K
G
F
T
F
B
H
...

result:

ok 1000 lines

Test #3:

score: 0
Accepted
time: 12ms
memory: 3564kb

input:

1000
39
OnYbTl Y accepted
m I accepted
NJN T accepted
lTGE D accepted
mi K accepted
ttcHrVD W accepted
hvGveRIr J rejected
zTwvbWhhQT S rejected
VlAcLAHas E accepted
hM H accepted
wltR G rejected
JJWtQ H accepted
zVwBtj L rejected
ZVqAWCsj I rejected
BwuM B accepted
IpUXa R rejected
OdSv D rejected
...

output:

H
R
M
I
S
J
D
D
A
E
X
S
I
D
D
A
I
N
G
O
F
G
G
B
A
J
E
H
D
I
G
M
O
N
C
G
F
L
V
D
C
S
B
U
H
W
L
J
C
O
B
D
L
N
D
V
K
M
Z
C
T
H
K
U
I
T
R
R
Q
D
B
E
F
A
Q
O
F
M
C
T
M
E
Y
L
K
Q
K
E
A
O
E
J
O
B
N
R
A
E
D
I
A
Q
W
A
M
A
Z
W
K
M
I
J
B
F
L
X
E
R
G
A
I
H
Q
P
T
E
K
L
Q
U
C
A
F
C
A
S
N
G
G
U
L
J
J
A
A
J
A
B
A
E
...

result:

ok 1000 lines

Test #4:

score: 0
Accepted
time: 11ms
memory: 3664kb

input:

1000
15
vCproSIO G rejected
vCproSIO H rejected
ySoEaGKbVz R rejected
ySoEaGKbVz M accepted
vCproSIO Z rejected
ySoEaGKbVz C rejected
YVCmuO H accepted
XHHVYm Y rejected
YVCmuO H rejected
vCproSIO S accepted
ySoEaGKbVz J accepted
YVCmuO P rejected
ySoEaGKbVz E rejected
XHHVYm O accepted
vCproSIO T r...

output:

H
A
F
A
N
J
B
C
H
T
B
L
G
Z
J
H
F
A
B
H
A
O
V
E
B
O
L
B
J
D
I
Y
M
B
Q
B
F
E
T
B
T
C
C
X
E
P
S
M
A
Q
G
D
A
A
H
I
H
E
D
C
A
A
V
C
B
C
D
E
B
F
I
D
C
M
J
P
N
F
V
K
E
K
K
B
B
F
Q
L
B
E
Q
A
R
E
V
C
Y
D
I
C
H
N
H
G
G
M
A
H
E
D
U
N
N
M
R
K
C
B
F
O
H
V
I
A
U
R
Y
D
A
A
A
G
E
N
N
L
C
A
E
C
B
Z
P
W
K
U
D
H
D
V
...

result:

ok 1000 lines

Test #5:

score: 0
Accepted
time: 10ms
memory: 4696kb

input:

1
27400
RPRPRNWL O accepted
UTqhXsDpY R rejected
BabD A rejected
eNM Y rejected
HzIyx S accepted
phWEJVQ N rejected
NbisS Q accepted
cTIsPKm Y rejected
sElDxdT T accepted
BJuQR Q rejected
vfPJs W rejected
eF Z accepted
KyOHzFtXm B accepted
wZlyz T accepted
acDVjN C accepted
M X rejected
sW A accepte...

output:

P

result:

ok single line: 'P'

Test #6:

score: 0
Accepted
time: 5ms
memory: 3676kb

input:

1
29702
Wsfzx N rejected
yZkJOvtRG B rejected
Wsfzx A accepted
yZkJOvtRG C rejected
F G accepted
kyUxIv U accepted
li R rejected
F Q rejected
F Y accepted
F I accepted
yZkJOvtRG J rejected
Wsfzx C rejected
Wsfzx V accepted
yZkJOvtRG L rejected
F X rejected
kyUxIv K accepted
li G accepted
Wsfzx Z acc...

output:

A

result:

ok single line: 'A'

Test #7:

score: 0
Accepted
time: 7ms
memory: 3852kb

input:

1
99584
I Y rejected
I F accepted
I Z rejected
I G accepted
I J rejected
I A rejected
I C rejected
I R rejected
I J accepted
I L rejected
I A rejected
I L accepted
I E rejected
I O accepted
I P accepted
I F rejected
I O accepted
I E accepted
I W accepted
I X rejected
I G accepted
I R rejected
I A re...

output:

A

result:

ok single line: 'A'

Test #8:

score: 0
Accepted
time: 10ms
memory: 5004kb

input:

1
26160
QmDDKxIel A rejected
gmxZDM O rejected
thXodr Z accepted
sznPsL Z accepted
VynmaLp B rejected
MfJQRamC T rejected
W W accepted
WFqnF T accepted
QRys Y accepted
Q H accepted
XUiMDH H accepted
fPcwpz U rejected
oEqrrOAv D rejected
aeW O accepted
M B accepted
JYzynly O accepted
JJqNf G rejected...

output:

E

result:

ok single line: 'E'

Test #9:

score: 0
Accepted
time: 10ms
memory: 3572kb

input:

1000
81
pnnCvDUIH B rejected
rdcJWGYGhk B accepted
VBFvmoYLn B accepted
jdMRRJuIpZ B rejected
WLewtGWJw A rejected
zGAkWsrfG A accepted
MDzQocBGr A rejected
XufUaIWaKT A accepted
JachfkiYL A rejected
zvDlkMINf B rejected
NMfFDEVhG A rejected
axiTyJnXu B accepted
wLkSOTqqV A rejected
amkUqtOyMB B rej...

output:

B
B
B
B
B
A
B
A
A
A
B
B
B
A
A
B
B
A
B
A
A
A
B
A
A
B
B
B
A
A
A
B
B
A
A
B
A
B
B
B
A
B
A
B
B
A
B
A
A
A
A
A
B
A
B
B
A
A
A
A
B
A
B
A
A
A
B
A
A
B
B
A
A
A
B
B
A
A
B
B
B
A
A
A
A
A
A
B
A
B
B
B
B
A
A
B
B
B
B
B
A
B
A
A
B
A
A
B
A
A
B
A
B
A
A
A
B
B
A
A
B
A
B
B
A
B
A
B
A
A
A
B
B
A
A
A
B
B
A
A
A
A
B
A
B
A
A
A
A
A
...

result:

ok 1000 lines

Test #10:

score: 0
Accepted
time: 20ms
memory: 6984kb

input:

1
61839
BGQriOTlZ B rejected
ZIqGhTsmH B rejected
DxIVjUqBr A rejected
afbRvvloO A accepted
LskKGrpIx A rejected
zGnHxzKmA B rejected
bHSaQfYtu A rejected
xPTMHyQgD B rejected
xWrkTqLhH B accepted
tGUVjSpmjI A accepted
bBBZKwbsw A accepted
IAaiNrLMLe B accepted
bglBZRQuk B accepted
DtLTczAkJo A reje...

output:

B

result:

ok single line: 'B'

Extra Test:

score: 0
Extra Test Passed