/*
.@@
.@@@@
:--:::::::-----==: %%@@@%
:*++*+==--========----------:-==: @%@@@@.
.:. ..-=+=+*+==---=----------------------:*@%@@@@ .:..
.::::-----==+++====+***#+----=------:--------:-=%%@@@#+%@@@@@@@@@@@@@@@@@@@@@@@
:+%@@@@@@@@@@@@@@%::::=*=+++++=++==*%*=-:=*#+##=-----------------:::-@%@@@@@@@@@@@@@@@@@@@@@@@@@@@*
%%%%%%%%%%%%@@@@@@= .:=%@@@@@%#+=+++%@@@%+-==--++-=*=-------------:-----:*@@@@@@@@@@@@@@@@@@@@@@@@@@%
.@%%%%%%%%%@@@@%- .-+%@@@%@%%%####%#*#%%%%==----+=:-++-::------=----:::-:=@@@@@@@@@@@@@@@@@@@@@@@@%
%%%%%%%%@%@@+ .::*%@@@@%#**#####******+*%+===---+=..:==---------:---::::-@@@@@@@@@@@@@@@@@@@@@@@
%%%@%@%@@@: .:.%%%%%#=+*+*+*#*+=+***+*#+##=--=-:-+. ==--------::::--::-@@@@@@@@@@@@@@@@@@@@@
.#%%%@%@% . -@%%%*==+*++++**+++=+*++=++=+#--=----=: +---:-::::::::--:-%@@@@@@@@@@@@@@@@@@=
:@%%%@= . =%%%#---======+=========++=====*+--=-=--=. --::::::::::::--=@@@@@@@@@@@@@@@@@@@:
@%@# . -%%*+---========-:===++======-==-==--=-----: :-::::::::::::-=@@@@@@@@@@@@@@@@@@@=
@#. . .#*=+.-=-==-==-=-::===+=-==-=--=--==+=:------= .-:::::::-:--:--#@@@@@@@@@@@@@@@@@@#
- #+=-.:----=------.:-=-*===----==--==-+=-:::-::-: :-::::::::::::==+@@@@@@@@@@@@@@@@@@
. -==:..-=--==--:--:.-===+====----=====--=--::::::-- ::::::::::--:=%*=*@@@@@@@@@@@@@@@@.
.+: . .==-. :----==-::--:.---==-===---:------:----::::::-+ -:::------=--+#+#@@@@@@@@@@@@@@@@.
. . - ::--. .::---:-:.-=-: :--==--==:=--:-::::::--=-:::-:::*. :::-==-==--:--**@@@@@@@%@@@@@@@@@=
:.: :::.. .--:::::: --::.:-:---:--:--:::::::::--:==:::::::+. -:-=-=------:*+@@@@@@@@+ #@@@@@@
#-. -::.. .=+:::::-:.--:-:.::::::::::+:::::::::::::=-:::::::=. :=-=---------=%@@@@@@@@@ :@@@@
=@-. :=.. -=::::-:=.:::::-.::::::::::%.::::::::::::-=:::::::-+- *%+=-------::%@@@@@@@@@: :.
#@*. +-.. :-:::::::-..::::::.:::::::::%:-==:..::::::--+:::-:-==== :*%*+--------@@@@@@@@@@@
.@@# :=: .::::::::-:.::::::-.::::::.::#.:-=-.:..::-.::-+:-=--===-= -#++*+===-:#@@@@@@@@@@@@
*@@*. . --. .:::::::::-..::::.:::.::..:..-+:: :.......=-.::==--==-====- .**++++++=*@@@@@@@@@@@@@@:
=@@@==. .: .=-. ::::::.:::= .::::...::.-.....+::. - :....:*::--==--=======- -*++=+=++@@@@@@@@@@@@@@@@@@%-
+@@@@::- . .:- :=-. .::::::.::=- .::......=.=.....+ :. : ... - -:-==+---==-=--*: . .*++++=+%@@@@@@@@@@@@@@@
:@@@@%.=.. : :--.-=:..:.::.:....- ......... --: ::.:. . :::.- ----=#+====-==-*. :*++=++@@@@@@@@@@@@@.
+*#-- :.:: :-::==..::.:..:...:: .:....... . :: :. :. -::. ..:#=-=+-==-===-=+.+ .. -+=++%#=-+=%@@@@#
. ...::.--::==: ::........-:..=- : . . . .:. :-*- .:=-+====-==--=-+# :. +++++==+++++*@@*
:.::.::-.-==-.=-:...--.: :.::-. : .: :+--:. ::.==+===---=-=+--%. +@@=. :=*+++++++*++*
.::::::::==---=-:.. =- . ..: :..: .:... : -. .+. -*=:.+@@@@@@@@*====---=+*:**. . =@@**%+:-+*%*++***+=
. ...::::::-+=--+-=:--.+:. .. :.-.:::::. .: :.*. :-:+#@@%#++=%:-@##+===-==-=+--==+ .. .###*+++**#@%#+*+++*=
..::::::::.*+--:=-----:=:-....::=:--=:....:..=. :. ..+@@@*+==---#-=@*+*====-===+:-=*@% :: *#*+*#+*++#%%%%##*+++-
.::.:::::::%=--:-------: . : -:-+#+-....= ..: -*#::%+-:=+---:+**-+==-===-=-+-=@@@@ -# =***#%#+*+#%==*+
:.:::::::::-+=:---=-----. . :. ::=..:..: . : -=--:..:--+#-:-+=======-%==#@@@@:.@= :#***%%#*+=#-==
:-::-::::.:--*:---=-=---: . ..-+*#%#=-+:...:. :+-....-+=::::#=======-*%-+@@@%@@-%%- .#++*%%#*+#*+-
. =-:::=:::::-:+.:--=-=--:- .=**+-:::+++%-..:. . ::..--:....:=#-=====-#@+=@@@%*%@%%@%- -*+#%:*%++*=
=:::---:------::-:==-=--+. ....: :.:. . ......::*=-====-*@#-%@@%#*%%%%%%@*. +**- .*#**=
+:::. :---=--=:=:-:==-==-:@. .....:. ..:. ...::...--:*=====-+@@-*@%%*##%%*###+#*= +- ::-:**
::-: .:---.#:=.:-==-==-:%% .... ..: : := ==-+==-*@@=*@%#**#%#****##*++**- .: .
.-- .:--:=:=-.-==-==-:%@+ .... .: :: :=--===#@@**%%**#*##***++**+=+*- ::
:. :----=.- -=-====-%@@: ... . . . :---==-@@@#%%%#*#*******+++***+# :
. -:--: .:-+--==-:%@@@ . #%:-===@@@#%##*##**+++#*+*+*+****-
::-: *:%==----*+%@% . . #@%--+=*@%@%%##**#**+++%#*==+*++*+=
-=:-. #:+#+---:#%++%#. . .:. .:+ ..#@@@--**%%%%%###*+#++*++*--+*==+++-+.
. =:: -==%@--=-=%**%%+ =@+ .....:.:.:. .*:@@%--%%@%%%####**#++*+++--: .+*-==
:---+**%%---:@**%%#+ . :@%%%::.:::::..:.: .-::%%%-:@%%%%%###**#*+++=*+-:: :==:-=
. :=-+*##*#:-:**+*%**@: =@#*:.:::::::::: .:...:@%%-+%%%%%###**+%*==+=%=:-. .. :.
. +*=+**%**-:=***##*+%%. . .*%.:::::::::.. :. ....@%%=%%%#*#####+#%+===+:-:-. .
.+-++**#+** +*-*++++%%%. .. --:.::.::: =: . .%%#+%%####*+@*++%+=-+. .:-
--++=**#*+*-++==+++%%%#@+.. .:::. :=. . .%%%#*#*##*#+#=++#===: .-
. . =-=+****+**+#:+==++#%%#%%%@%=. .. :-: . %#%###%*##.:*+==#++- :
. :-=+=++***++#-:+++*++*#%%%%@@%=.. .. :---. #@@%@@@@= := .+-+-
. . :.-===++**+==*+::+#++++*#%%%%%%%%-. .*=:-:. *%%%##*==+**#*+==*+=
: -::====++*=+=+*==*=-=#**##%#%%%%%*+-:%#--:-. .. .%#*=-==-*#*++==++-=#*:
:*::**=====+**==+=++*##*+++**##%%%%%%. :::.:. .. .:=--===+@#*+++=+*+=-=+=*#=
#-=+==*=-++++#++==-++++*++++*#%%%%%%=- .:.... . . -=--=+@#*#%@@%+==+=====+*+
..*++==+**+:=*++%++++#++++++*+**#%%%%#-=. .:........ .@-=+++#%%@@%@=======++*@+
.+-.-+*==*++#+-:=++*%+=**++++++*++**%%%%--=-.::.......... .: ==++*%@@%@+========+*#@@+
-:--.=-*+*+++++=:.:-+*#+++*****=+*##%+#%==---::........... : .+%@@@%@#+======++*#%%@@#%=
+::-:==--=*==**=#=:::-+#**+*+**++**%=.-++-:::--... .. .... :. ..-@@@*++====++++*#%@@@%*=+.
=---.=--:*+=+#*+=:-:--=++=**+++++*#+:=-.--:.:::.......... + ..*%-+=-====+++*###@@@#+=+#*
=----==-*+===@%:..-=---++##=+++***#-. .:=::...:.......... := :*:==-=====+++*%#%@@*++++##@*
.+=-=*=+#*---==%:.:-=%+#+-:--+++*+*%:.. -::............. :. .--==-=======+*#*%@%+++==+##@#%+
-:=##*+=-::-===+:.--+*#---::+*++++#+ ....- .:......... .. . :+. . =============+**#*++++===*%%#%###.
:--*#@*+-::::-==-:-=#=.---:-+*==+#-......-: .......... :. +============+*##**++====*%%%#**+=+
.:---%=@*+-::--:-:.-*=:=:--=#++*@%-... . .-:.... ...... .:. .=-===========+**+++===-===*#***+++=-:
..:-==+*#+*=:-::--.=+=::-=+*+%@+#@%.... ..-:. ......... .- .+============++========--===++**++==--
.:----++%**-:: .+=+=++++++*%#+@@@%......-:. . =. . .+-===-===-==++==--===------==+++====--:
..:--=*#%*+= .=%##-:-+++*##+@@@@@.... -:. . ..- -+==-======++*=======------==++======+*#*
.::=-=#+#- .::=#-:-:=++=+##*@@@@@@.. .::. . -: . .=+==-==+-==++=:=---=----========+**+=----:=
.::--=+#=.:::-*=:::::++=+*#*%.#@@@@:..::. . . .+ .=#*++++*+=====--=-=---=--=+**##*+=====-------:-
..::-=*+::::=:.::::--===**+*. -@@@@:.:: ... . -.. . . .-%@@@*+*#*#*+====--=-:----*##*+==--==---======----:
..:-:+:-:--:::--:::-+#*+++: @@@@+:- .. . +. .. -@@@@@@@*@%*###*======*+-=-=%#=-=======-====-=======-:-+
..:=::::::::::-:**++=-++. .@@@@#= . . :+ :#@@@@@@@@@%##%%%%#+++==#@%%@=**+==========-------=====-=+==
. .:::::::--+==----+#++. .@@@@@ .. ..:::+#%@%@@@@@@@#@%%%%%%@%*=+#@@@%@#%@=============------=====++++=+
.... ..::=-:----+*=+**=++@@@@@:.-*@@%%%%%@@@@*:. .@@%%@%%@%**%@@@@@##@@*========--------=====+++*#*+==
. ...::=:--==++=+++=+++%@@@@@@@%%@%@@#- :%#%%%%@%#@@@@@@@%#@*@@+--===-----------======*##**=--
...:.--:--=*+===++=++=#@@@@@%%%#*++=. :%%%@@%%@@@@@@@@+@@#+*@@+===-----------====+++*##**+=-:
....:+=:-==#++===+++===%@@%#*+==+++++++*##@@@%@@@@@@@@@**%##+=-%@#=-------------====+++*##*++=-:.
..:-+#===+# .-:=+=*+*+#*+==+++++++++**%@@@@@@@@@@@*-@@#+=+==+@@=--------------===+++*##*+=-:.
..:=%+==+% =#*-##*#+=%+++=++*+#%@@@@@@@@@@:%@#*=+=-+=#@@+-=-------------====+*#*++=-:.
.=*===* .--#:..-#@@-. .:=**@@@@@@@@*@@@%+%+@@=--#@%=--:----------------=+++==-:.
=::-- :*-##==-. -@@@@@@@@@@@@@@@@@@@@@%+=::::::::::::::::::--====-:..
... *%=-..... %@@@@@@@@@@@@@@@@@@@@@*-::..:.............:::--:.. .-:
:: ==. ..... +@%@@@@@@@@@@@@@@@@@@@@*.:. . ... .... . =@*-:
::..:---::... :#*#@@@@@@@@@%%@@@@@@@@@@+ . :* ##+%+:
...::::*-:::@@@@@@%##%%%%@@@@@@@# -+. *+ = -:
.. .#@@%%%%##*+*#%@@@%%%= . : ::
@@@%%%######%%%%#####%= = #
@@@@@%@@%%%###*##*- . . =
:@@%%%%###******+=- .
*@###***+**+++:
-*- =*++*:
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int sz = 500;
map<char,pair<int,int>> mov;
map<int,set<int>>vis[sz][sz];
bool get(int x,int y){
return x >= 0 && y >= 0 && x < sz && y < sz;
}
void solve() {
mov['S'] = {1, 0};
mov['E'] = {0, 1};
mov['W'] = {0, -1};
mov['N'] = {-1, 0};
int n;
cin >> n;
for(int i = 0, x, y; i < n; ++i){
char c;
cin >> x >> y >> c;
int tim = 0;
while(get(x + mov[c].first, y + mov[c].second)){
x += mov[c].first;
y += mov[c].second;
tim++;
vis[x][y][tim].insert(i);
}
}
set<int>ans;
for(int i = 0; i < n; ++i){
ans.insert(i);
}
for(int tim = 0; tim < sz; ++ tim){
for(int i = 0; i < sz; ++i){
for(int j = 0; j < sz; ++j){
for(auto l : vis[i][j][tim]){
if(ans.find(l) == ans.end()){
vis[i][j][tim].erase(l);
}
}
if(vis[i][j][tim].size() > 1){
for(auto l : vis[i][j][tim]){
if(ans.find(l) != ans.end()){
ans.erase(l);
}
}
vis[i][j][tim].clear();
}
}
}
}
for(auto i : ans){
cout << i + 1 << endl;
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int T = 1;
while(T--){
solve();
}
}
# | 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... |