[[TableOfContents]] = 오늘의 문제 = * [https://www.acmicpc.net/problem/11657|타임머신] * [https://www.acmicpc.net/problem/111057|오르막 수] * [https://www.acmicpc.net/problem/12851|숨바꼭질2] * [https://www.acmicpc.net/problem/7576|토마토] = 참가자 = * 15이원준 = 코드 = == 15이원준 == === 타임머신 === {{{ #include #include #include using namespace std; int d[501] = {0,}; int check[501] = {0,}; vector > > vec; int main(){ vec.resize(501); int n,m; cin>>n>>m; for(int i=0; ifirst] || d[it->first] > d[j] + it->second){ update = true; check[it->first] = 1; d[it->first] = d[j] + it->second; } } } } for(int i = 2; i<=n; i++){ if(!check[i]){ cout<<-1< #include using namespace std; int arr[1001][10]; int search(int num, int pri){ if(num == 1){ return 1; } if(arr[num][pri] != -1){ return arr[num][pri]; } int ans = 0; for(int i = 0; i<=pri; i++){ ans += search(num-1, i); ans %= 10007; } arr[num][pri] = ans; return ans; } int main(){ memset(arr,-1,sizeof(arr)); int n; cin >> n; int ans = 0; for(int i = 0; i<10; i++){ ans += search(n,i); ans %= 10007; } cout<< ans < #include using namespace std; int check[100001] = {0,}; int arr[100001] = {0,}; int main(){ int n, k; cin>>n>>k; queue q; q.push(n); arr[n] = 1; int cnt = 0; while(q.size()){ int si = q.size(); while(si--){ int tmp = q.front(); q.pop(); if(tmp == k){ cout<< cnt <= 0){ if(!check[tmp-1]){ arr[tmp-1] = arr[tmp]; check[tmp-1] = cnt; q.push(tmp-1); } else if(check[tmp-1] == cnt){ arr[tmp-1] += arr[tmp]; } } if(tmp *2 <= 100000){ if(!check[tmp*2]){ arr[tmp*2] = arr[tmp]; check[tmp*2] = cnt; q.push(tmp*2); } else if(check[tmp*2] == cnt){ arr[tmp*2] += arr[tmp]; } } } cnt++; } } }}} === 토마토 === {{{ #include #include #include using namespace std; int arr[1000][1000]; queue> q; int dx[4] = {0,0,1,-1}; int dy[4] = {1,-1,0,0}; int main(){ int left = 0; int n,m; cin>>m >>n; for(int i = 0; i= n || now.second+dy[i] <0 || now.second+dy[i] >=m || arr[now.first+dx[i]][now.second+dy[i]] != 0){ continue; } q.push(make_pair(now.first+dx[i],now.second+dy[i])); arr[now.first+dx[i]][now.second+dy[i]] = 1; left--; } } if(left == 0){ cout << cnt+1 <