[programmers] Lv.3 경주로 건설(c++)
더보기 #include #include #include #include using namespace std; struct Node{ int x, y; int cost; int dir; Node(int x=0, int y=0, int cost=0, int dir=4) : x{x}, y{y}, cost{cost}, dir{dir}{} }; int solution(vector board) { vector x_dir = {-1, 1, 0, 0}; vector y_dir = {0, 0, -1, 1}; vector possible_dir = {{0, 2, 3}, {1, 2, 3}, {0, 1, 2}, {0, 1, 3}, {1, 3}}; int N = board.size(); vector dp(N, vector(N,..
2022. 5. 3.
[programmers] Lv.3 추석 트래픽(c++)
다시 한번 풀기 더보기 #include using namespace std; pair time_difference(string s, int t){ long t_sec = 0; istringstream iss(s); string buff; int i = 2; while(getline(iss, buff, ':')){ buff.erase(remove(buff.begin(), buff.end(), '.'), buff.end()); t_sec += pow(60, i)*stoi(buff); if(i==1) t_sec *= 1000; i--; } return {t_sec - t + 1, t_sec}; } vector logs; int compute(long start, long end){ int cnt = 0, id..
2022. 4. 25.