이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
// #include "september.h"
int solve(int N, int M, vector<int> F, vector<vector<int>> S)
{
vector<int> freq(N);
int ans = 0;
for (int i = 1; i < N; i++)
freq[F[i]]++;
map<int, int> mp;
int cnt = 0;
set<int> need;
for (int i = 0; i < N - 1; i++)
{
for (int j = 0; j < M; j++)
{
mp[S[j][i]]++;
if (mp[S[j][i]] == 1)
cnt++;
if (mp[S[j][i]] == M)
cnt--;
}
if (cnt == 0)
{
for (auto &[key, val] : mp)
{
freq[F[key]]--;
if (freq[F[key]] == 0)
need.erase(F[key]);
if (freq[key] != 0)
need.insert(key);
}
ans += need.size() == 0;
mp.clear();
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |