본문 바로가기

시뮬레이션

BOJ)1063 킹 문제: icpc.me/1063 조건에 맞게 시뮬레이션을 돌려주면 된다. 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include #include #include #include using namespace std;string mov[] = { "R","L","B","T","RT","LT","RB","LB" };string a;int dx[] = { 0,0,-1,1,1,1,-1,-1 };int dy[] = { 1,-1,0,0,1,-1,1,-1 };int n, kx, ky, sx, sy;int chk(int x, int y) { return 1 > n; ky = x[0] - 'A' + 1; kx =.. 더보기
BOJ)14503 로봇 청소기 문제: icpc.me/14503 주어진 조건대로 로봇을 작동시킬 때 청소를 몇칸까지 할 수 있는지 판단하는 문제이다. 청소한 빈칸을 2 청소안한 빈칸을 0 벽을 1으로 설정한 뒤 시키는대로 시뮬레이션을 돌려주면 된다.12345678910111213141516171819202122232425262728293031323334353637383940414243#include #include using namespace std;int n, m, a[51][51], x, y, h, r;int dx[] = { 0,-1,0,1 };int dy[] = { -1,0,1,0 };int main() { scanf("%d%d", &n, &m); scanf("%d%d%d", &x, &y, &h); for (int i = 0; i 더보기
BOJ)14499 주사위 굴리기 문제: icpc.me/14499 문제에서 주어진 조건에 맞게 주사위를 시뮬레이션해주면 된다. 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980#include #include using namespace std;int n, m, x, y, k, a[21][21], dice[6], q;bool chk(int cx, int cy) { return 0 더보기
BOJ)12842 튀김 소보루 문제: icpc.me/12842 m명의 사람이 튀김 소보루를 먹는 시간이 주어졌을 때 n번째 튀김 소보루를 누가 먹었는지 출력하는 문제이다. n과 m이 10만이고 개인이 소보루를 먹는 시간 t가 최대 1000이여서 시뮬레이션을 돌려도 시간내에 AC 받을 수 있었다. 123456789101112131415161718192021222324#include #include #include using namespace std;int n, s, m, x, r, t;int a[100010];int main() { scanf("%d%d%d", &n, &s, &m); for (int i = 1; i 더보기