이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
.:-=++***#***+=:.
.:-==+**##**%########***#####*=:.
.-+#%%#*****############**#******#####+=:
.-*%#####********###########*********#######*+-:
:+#######**********########*****+********##########+-.
:+##########**###******##********************###########+:
:+##########*****#*******###**********************###***####*:
.=###########***###*******#***************************#****#####*:
:*#################******************************************######=
-###################***************+****************************#####*:
.=###################******************************************#****#####+.
:*###################*******************************+************#*****#####:
=#############**######*****#*******************++***++++++***************#####=
.*###########******####*****#************+++*+**+++***++++++++***#**********#####+
-############********###*****%*+****+++++++++++++++++***++++++++***#*****#****#####*
=############********###+++++##++++++++++++++++*++++++****++++******##*+++*#****#####*.
.+#*##########*********###+++++%*++==++++++++++++*+++++*#************#*##*+++##****#####*.
.*#=-##########********###*++++*%*+++++++++++++*****+******#***********#*##*+++####*######*.
.:-: .*#: *#########*********###+++++##****++*******************#*#**********##*#*****####*#%###%*.
.--:++=+. .**. ##########********##*#++***%#****+*************=#*****#*#**********##*##*##*####**#%###%*:
:++===== .**. -###########******##*##+****%#*****#************-********#**********#***%####*###***#%######=:
.-=++= =*. +############****###*##*****%#*****%####*####**#:=#***#**#**********#=##*###**####***#%########+:
. .#. .####################*##*****%#####*%#****##****#.:#***#*#**********#%:##*+##***%###***############+:
-- -###################**#*****####****##****##*****..#*****#**********#*.*#+ +##**#####***##############+-.
-=+++-. = +###################**#*****###**********#*#***#: .***#*#***********#:.*#- :**#*######***#######%%%####%%#=:
.++====++ = ####################**##*****###***#+****#=#**** .+*###************+ ## +***######****##########+--+#%%%%+:
.---:=+======+: +. ##################%#***#*****####****#**#+-####. .+###***##*******# .#: :***########***##%%%####%#=. .:=*%%
---==++=======+= -= .%#################%****#*****######-#*##*.=%#*. +=---:::.......: =: =**#########***#%%%%%%%%%%%=. .-
:-:===========+= .#. :%################%%****#*****#####= :-+***#*=. .*#########%%#**#*=%%%%%%%%%%=.
.---=========+= :*. -#################%%****#*****%#+-.-*#%%%@###*= +##########%%%***:+-#%%%#####*:
.:=++++====+- =*.=###%############%@%****#*****#. =###%%%@@@+ ###########%%%%#*#: -*########=
..:::::-. +*+###%####%######%%+******#****#=##= -@@@@@@@+ =*###########%%%%##+ :*#######+
=%##+%####%######%+.******#*****%%#-:+@@@@%-=* +..###########%##%%%*. -#######
%##=#####%###%%#%:=******#*****%*.**##*+=: . -+**####*=: - .=###############%%*: .+#####
.%###%########%%%%:.#*****##*****= .+: . :-::.:--=++- : .-*##################+: :####
:##.*###########%@# #************+ .:.-==-- . +**###+*##############*: .*##
-%- ############%@@-#*###*#=##***#. :. =*++*#**++*##############*- .##
=# ############@@@######*#:###*##= :..+*++++***+++++*##############=.+#
+: ###########%@%%%%######.=###### .=+#+++++++***+++++****##############
.+ *##########%%%%%%######::######= =+++#*+++++++*#+++++******###########
+: =%#%######%%%##%@######:-+######. .:------== :*++++**+++++++*#*+++++********#######
-* :%%%%#####%%%##%%%#####***######* -=--------=: -*+++++++*++++++++*#**+++*=:=******+==*
.*+ +%%%%###%%####%%%#####**+#######= -........:=: -++++++++++*#**##***+******++- .-******=.
-*= *%%%%##%%%%%%%#%#####**++#######. :.........- .=#%%%######%##########%#+*******. .-++++*+
-*+ .*%%%%#%%#######%#####*++++######*: ......... :=#%@@%%%%%%#################*++*****=. .-++++
:**. :###%%%#%%########%####*++++*#######=-:.. -+#%%%###########################++++****#=. .-++
-*+ .######%%%%#########%###@@@%%%%######+...:----:. :*%################################%*+++++*+###- .+
:*+.=########%%%%###########%%%%%%%%######-........:------::.+%%%%%###############%#############%*+++++*.:*##+. .
-+####****##%%%%%%%%###%########%%@%#####:.......:::::::...=@@%%%@###############%############%*+++++*. =##+
+#*##*****####%%%%##%%%%#########%@%#####:.....-:....:..::=*=++++############################%#*+++++ -##.
=%**********#######%%###############%*#####=...=. . :-=-: .###############%#******####%#####+= +*
*#************#############%%#######**+*%####-.- .-:=##############%*********##%#######=: .+.
*#****************##**######%%%###*: ::*#####: -:: .-+####%%%####%*********#%##########*-:
=#***********************######%*- .--:=:. =. :--: .-=*###%###*********#######*#######+-
.#**************************###= .:. ::... .=. +***#%##*******#########***#######+:
=##**************************: :-:--. .. .+..... + =******#%#####%##########***#####**#
####**********************+. . :#########+-=:.... -: +***********##%%#***######****##****
.#%####******************- *##########*:....... ...:. #**************##*********###*##****
:#%@%%%###************* =#*******####+....... :-. *#***************%************#%#****
.#**###%%%%%######****#. =#***********#=....:-. :*#****************##*************####*
*#**#****#####%%%%##### =#*************+=: .=-::..:-*#*****************##*****************##
-#***#*******######%%%%= :=*#**********: ... ##*##%##*******************#********************
.%*****#*********######%. ....:-=*- :++: =#****##%####*************###********************
:. +#*****#**********####%+ ..-*#***#+=##*******##%%###********####*********************
.:-:. .%#*****#**********#%%%* :=+**##########******###********#%%%%%%##****###***********************
-- =%#******#*********@#%%-. :#%%%%%%%%%%%%%%###*****###*****#%%##%%%#%@#####*************************
=-. .=. ##*******#********#%#**###*+=-:.: -######%##%###%####%%%%%##########%####%%%%##%*************####************
==== .= :%#*******#********%%***************++#%%#%#######%###%#######%%%%%%%########%%%%####%#************####***********
==== -: *%#*******#********@#********************#%#######%###%###########%%%%%#####%%%#######%%#**********#####**********
:+=+. = .%###*******#******#%#*******************#%#############%##############%%%##%######***####%%#*******######*********
*/
#include <bits/stdc++.h>
using namespace std;
int solve(int N, int M, vector<int> F, vector<vector<int>> S)
{
deque<int> toprocess;
unordered_set<int> globalseen = {0};
vector<unordered_set<int>> seen = {{},{},{},{},{}};
vector<int> processed = {1,1,1,1,1};
vector<int> tempchildren;
for(int i=0; i<N; i++)
{
tempchildren.push_back(0);
}
for(int i=1; i<N; i++)
{
tempchildren[F[i]]+=1;
}
vector<vector<int>> children;
for(int i=0; i<M; i++)
{
vector<int> temparr;
temparr = tempchildren;
children.push_back(temparr);
}
int ans = 0;
for(int j=0; j<(N-1); j++)
{
bool check = true;
for(int i=0; i<M; i++)
{
//i
int num = S[i][j];
deque<int>().swap(toprocess);
globalseen.insert(num);
seen[i].insert(num);
toprocess.push_back(num);
while(toprocess.size())
{
num = toprocess[0];
toprocess.pop_front();
if(children[i][num] == 0)
{
children[i][F[num]] -=1 ;
processed[i] += 1;
if(children[i][F[num]] == 0 && seen[i].find(F[num])!=seen[i].end())
{
toprocess.push_back(F[num]);
}
}
}
check &= (processed[i]==globalseen.size());
}
if(check)
{
ans++;
}
}
return ans;
};
/*
int main()
{
cout << solve(3, 1, {-1, 0, 0}, {{1, 2}}) << endl;
cout << solve(5, 2, {-1, 0, 0, 1, 1}, {{1, 2, 3, 4}, {4, 1, 2, 3}}) << endl;
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:123:36: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::unordered_set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
123 | check &= (processed[i]==globalseen.size());
# | 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... |