-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
15-kangrae-jo #57
base: main
Are you sure you want to change the base?
15-kangrae-jo #57
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ κ° μ μΌ μ½ν λ¬Έμμ΄ + ꡬν λ¬Έμ λ€μ. cppμ μ¬μ©νλ μ λ‘μλ νκΈ°κ° μ«λκ΅°μ.. κ·Έλ§νΌ λμ΄λλ λ¬Έμ λΌλ κ±°κ²μ£ .?
μ λ μ΄ λ¬Έμ λ 30λΆ μμ νμ§ λͺ»νμ΅λλ€. κ·Όλ° λμ΄λ μ체λ μ΄λ ΅μ§ μμ 보μ¬μ κ³μ ꡬνν΄λ³΄μμ΄μ. κ°λλμ΄ μ€λͺ νμ μ½λλ₯Ό 보λ μκ°μ νλμ μ μλ‘ νκΈ°νμ¬ λμ λΉκ΅λ₯Ό κ°λ¨ν ν μ μλλ‘ νλ μ°μ°μ΄ κ°μ₯ μ ννκ² λ¬Έμ λ₯Ό ν μ μμκ² κ°μ΅λλ€.
νμ§λ§ μ μ½λλ κ·Έλ₯ stringμ μ§μ§κ³ λ³Άμμ΅λλ€. κ°μ¬ν©λλ€.
code
#include <string>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
bool isOpening(string pos, string start, string end) {
if(start.substr(0,2) > pos.substr(0,2)) return false;
if(start.substr(0,2) == pos.substr(0,2) && start.substr(3,2) > pos.substr(3,2)) return false;
if(end.substr(0,2) < pos.substr(0,2)) return false;
if(end.substr(0,2) == pos.substr(0,2) && end.substr(3,2) < pos.substr(3,2)) return false;
return true;
}
string jump(string pos, int step) {
int min = stoi(pos.substr(3,2)) + step;
int hour = stoi(pos.substr(0,2));
if(min > 59) {
hour += 1;
min -= 60;
}
if(min < 0) {
if(hour <= 0) return "00:00";
hour -=1;
min += 60;
}
string format = "00:00";
format[0] += hour/10;
format[1] += hour%10;
format[3] += min/10;
format[4] += min%10;
return format;
}
bool isOver(string video, string pos) {
if(video.substr(0,2) < pos.substr(0,2)) return true;
if(video.substr(0,2) == pos.substr(0,2) && video.substr(3,2) < pos.substr(3,2)) return true;
return false;
}
string solution(string video_len, string pos, string op_start, string op_end, vector<string> commands) {
if(isOpening(pos, op_start, op_end)) pos = op_end;
for(string& command : commands) {
if(command == "next") pos = jump(pos, 10);
else pos = jump(pos, -10);
if(isOver(video_len, pos)) pos = video_len; // μμμ κΈΈμ΄λ₯Ό λμ λ
if(isOpening(pos, op_start, op_end)) pos = op_end; // μ€νλμΌ λ
}
return pos;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λΆμ μ΄λ‘ λ§λ€κ³ , prevμ nextλ₯Ό ν¨μλ‘ λ§λ€μ΄ κ³μ°νλκ²κΉμ§λ κ΅μ₯ν μ½κ³ μμνκ² μ§νλμμ΅λλ€.
κ·Έλ¬λ μ κ° μ΄ν΄λ₯Ό μλͺ»νκ±΄μ§ λ¬Έμ κ° λͺ¨νΈνλκ±΄μ§ prevκ° μ λ₯Ό λ―ΈμΉκ² λ§λ€μμ΅λλ€.
λ¨ νλμ ν
μ€νΈμΌμ΄μ€κ° κ³μ λΉλκ°λλ° κ²°κ΅ κΌΌκΌΌν μκ°ν΄λ³΄λ
μ€νλμ΄ 10μ΄ λ―Έλ§μΌλ, μ€νλμμμ prevλ₯Ό λλ μλλ₯Ό μκ°λͺ»νμ΅λλ€.
μ€νλμ΄ 10μ΄κ° λλλ€λ©΄, μ€νλμμμ prevλ₯Ό λλ μλ μ€νλ건λλ°κΈ°λ‘ μ€νλ λλλμμ μΌλ‘ κ°λκ² λ§μ§λ§,
μ€νλμ΄ 10μ΄λ₯Ό λκΈ°μ§ μλλ€λ©΄, μ€νλμ λμ§μ μμ 10μ‘° μ΄μ μΌλ‘ λμκ°λκ²μ΄ λ§λ κ²μ΄μμ΅λλ€. (μ¬λ¬ μλλμ μμλμ΅λλ€)
λ°λΌμ μ½λλ λ€μκ³Ό κ°μ΅λλ€,, μ κ° λ§κ² μκ°νκ³ μλκ±΄μ§ νλ² ν¬λ‘μ€μ²΄νΉ λΆνλ립λλ€...
def solution(video_len, pos, op_start, op_end, commands):
def time_to_seconds(time):
minutes, seconds = map(int, time.split(":"))
return minutes * 60 + seconds
def seconds_to_time(seconds):
minutes = seconds // 60
seconds = seconds % 60
return f"{minutes:02}:{seconds:02}"
def prev(video_len, current, start, end):
if start <= current <= end: # μ€νλ ꡬκ°
if end > 10 and end - start < 10:
current = end - 10
else:
current = end
elif end + 10 >= current > end: # μ€νλ λ€μμ μμΌλ‘ λ€μ΄κ° κ²½μ°
current = end
elif current <= 10: # μμ μμ 10μ΄ λ―Έλ§
current = 0
else:
current -= 10 # μΌλ°μ μΈ κ²½μ° 10μ΄ λ€λ‘ μ΄λ
return current
def next(video_len, current, start, end):
if current > video_len - 10: # μ’
λ£κΉμ§ 10μ΄ λ―Έλ§μΌλ‘ λ¨μμ κ²½μ°
current = video_len
elif start <= current <= end: # μ€νλ μμμ nextλ₯Ό λλ μ κ²½μ°
if end + 10 > video_len:
current = video_len
else: current = end + 10
elif start - 10 <= current < start: # μ€νλ μ μμ μμΌλ‘ λ€μ΄κ° κ²½μ°
current = end
else: # μΌλ°μ μΈ κ²½μ°
current += 10
return current
# λ¬Έμμ΄ μκ°μ μ΄ λ¨μλ‘ λ³ν
video_len = time_to_seconds(video_len) # video_len λ³ν μΆκ°
current = time_to_seconds(pos)
start = time_to_seconds(op_start)
end = time_to_seconds(op_end)
# λͺ
λ Ήμ΄ μ²λ¦¬
for command in commands:
if command == 'prev':
current = prev(video_len, current, start, end)
elif command == 'next':
current = next(video_len, current, start, end)
answer = seconds_to_time(current)
return answer
π λ¬Έμ λ§ν¬
[λμμ μ¬μκΈ°]
βοΈ μμλ μκ°
48m
β¨ μλ μ½λ
PCCP κΈ°μΆ 1λ¨κ³ λ¬Έμ λ₯Ό λ€κ³ μμ΅λλ€.
μ΄ λ¬Έμ λ μ½μΌλ©΄μ λμμ λ¬Έμ λ₯Ό μ΄λ κ² νμ΄μΌκ² λ€λ μκ°μ΄ λλ μΌλ°μ μΈ
ꡬν
λ¬Έμ λΌκ³ μκ°νμ΅λλ€.κ·Έλμ λΉ λ₯΄κ² μ½κ³ 30λΆμμ λ¬Έμ λ₯Ό νκ³ μΆμ΄μ λμ΄λΈνκ² μκ°μ΄ λλ λλ‘ μ½λλ₯Ό μ¨λ΄λ €κ°μ΅λλ€.
λ¬Έμ νμ΄ μμλ λ€μκ³Ό κ°μ΅λλ€.
κ°λ¨νμ£ ? μλ§
c++
μ μμ°λ λΆλ€μ λ μ½κ² λκ»΄μ‘μ κ²λλ€.κ·Όλ°... λ§μ μ½λ€κ³ νκ³ 30λΆμμ λ¬Έμ λ₯Ό νκ²μ΄λΌ μκ°λ νλλ° μ€μ λ‘ κ±Έλ¦°μκ°μ 48λΆμ μ½λλ μλ§μ λλ€...
μ μ½λκ° μ μλ§μ΄λΌκ³ λκΌλλ©΄,
string
λ³μλ₯Όint
ν μκ° λ³μλ‘ λ°μμ¬ λλΆ
μλ60
μ κ³±νκ³ ,μ΄
λ κ·Έλλ‘ λνλ€λ©΄ 볡μ‘ν ννλ‘ λΉκ΅λ₯Ό ν νμκ° μμμ΅λλ€.λΆ
κ³Όμ΄
λ₯Ό λ°λ‘ λ€λ£¨λ λ°©μμ μ΄ν΄νκΈ°λ μ½λ€κ³ λλ μ μμ§λ§,μκ°μ λμλ₯Ό, κ·Έλ¦¬κ³ μ¦κ°μ μ λλ‘ λ€λ£¨κΈ°μλ μ λΉνμ§ μμλ€κ³ μκ°ν©λλ€!
κ·Έλ¦¬κ³ λ¬΄μ보λ€... μκ°μ΄ μ΄λ κ² μ€λ²λ μ΄μ λν λ€λ£¨λ λ³μκ° λ무 λ§μμ μ€νλ₯Ό μ°Ύκ³ κ³ μΉκΈ° μ΄λ €μ κΈ° λλ¬Έμ λλ€.
μ¬λ¬λΆμ λ¬Έμ κ° μ½λ€κ³ μκ°λμ΄λ κΌ λ°©ν₯μ νλ²μ© μ κ²ν΄λ³΄μκ³ κ³μ λμκ°μκΈΈ... λ°λλλ€...!
π μλ‘κ² μκ²λ λ΄μ©
λ€λ₯Έ μ¬λμ νμ΄λ₯Ό ν λ² λ΄€μ΅λλ€.
μ κ° μκΉ λ§νκ² μ΄κ±°μ λλ€.
λΆ
μλ 미리60
μ κ³±νλ κ·Έλ° λ‘μ§μ λλ€.(μ΄λ κ² ν΄λμΌλ©΄ μκ°μ λμ λΉκ΅μ μ¦κ°μ΄ μ½κ² μ£ ??)
그리κ³
stoi
λ₯Ό μ¬μ©νλ©΄"11:30"
μμint
κ° μλ λ¬Έμ":"
λ₯Ό λ§λ λ κΉμ§string
ν λ©λλ€.(μ²μ μμλ€μ©)
λ€λ₯Έ μ¬λ νμ΄ μ°Έκ³