-
#include<iostream> #include<vector> using namespace std; struct shark { int r; int c; int s;//속도 int d;//방향 1 위 2 아래 3 오른쪽, 4 왼쪽임 int z;//크기 bool life = true; shark(int q, int w, int speed, int t, int y) { r = q; c = w; s = speed; d = t; z = y; } }; int ans; vector<shark> v[101]; int r, c,m; void check(int al) { for (int i = 0; i < v[al].size(); i++) { if (v[al][i].z == 0) continue; int max = v[al][i].z; vector<int> index; index.push_back(i); for (int j = i + 1; j < v[al].size(); j++) { if (v[al][i].r == v[al][j].r && v[al][i].c == v[al][j].c) { if (max < v[al][j].z) { max = v[al][j].z; } index.push_back(j); } } for (int j = 0; j < index.size(); j++) { if (v[al][index[j]].z < max) { v[al][index[j]].z = 0; v[al][index[j]].life = false; } } } for (int j = 0; j < v[al].size(); j++) { if (v[al][j].life == true) { v[al + 1].push_back(v[al][j]); } } } void move(int al) { for (int j = 0; j < v[al].size(); j++) { if (v[al][j].z == 0) continue; for (int i = 1; i <= v[al][j].s; i++) { if (v[al][j].d == 1) { v[al][j].r -= 1; if (v[al][j].r == 0) { v[al][j].d = 2; v[al][j].r = 1; v[al][j].r += 1; } } else if (v[al][j].d == 2) { v[al][j].r += 1; if (v[al][j].r == r + 1) { v[al][j].d = 1; v[al][j].r = r; v[al][j].r -= 1; } } else if (v[al][j].d == 3) { v[al][j].c += 1; if (v[al][j].c == c + 1) { v[al][j].d = 4; v[al][j].c = c; v[al][j].c -= 1; } } else if (v[al][j].d == 4) { v[al][j].c -= 1; if (v[al][j].c == 0) { v[al][j].d = 3; v[al][j].c = 1; v[al][j].c += 1; } } } } } void naksi(int al) { int x = 10000; int y = 0; bool f = false; for (int i = 0; i < v[al-1].size(); i++) { if (v[al - 1][i].c == al) { f = true; if (x > v[al - 1][i].r) { x = v[al - 1][i].r; y = i; } } } if(f) { ans += v[al-1][y].z; v[al - 1][y].z = 0; v[al-1][y].life = false; } } int main() { cin >> r >> c >> m; for (int i = 0; i < m; i++) { int r, c, s, d, z; cin >> r >> c >> s >> d >> z; v[0].push_back(shark(r, c, s, d, z)); } for (int i = 0; i < c; i++) { if(v[i].size() == 0) break; naksi(i + 1); move(i); check(i); } cout<<ans<<endl; return 0; }
전형적인 삼성스러운 시뮬레이션문제?
난이도는 하..
속도제한이 생긴다면 많이어려워질지도모르겠다
움직임 함수 + 낚시함수 + 잡아먹히는거 체크함수 + 메인 끝..