[C#] 백준 10811번 : 바구니 뒤집기
using System;
class Program
{
static void Main()
{
int[] nm = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
int n = nm[0];
int m = nm[1];
int[] bowls = new int[n];
int temp = 0;
for (int x = 0; x < bowls.Length; x++)
{
bowls[x] = x + 1;
}
for (int y = 0; y < m; y++)
{
int[] ij = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
int ii = ij[0] - 1;
int jj = ij[1] - 1;
while(ii < jj)
{
temp = bowls[ii];
bowls[ii] = bowls[jj];
bowls[jj] = temp;
ii++;
jj--;
}
}
Console.WriteLine(string.Join(" ", bowls));
}
}
반응형
'백준 > C#' 카테고리의 다른 글
[C#] 백준 27866번 : 문자와 문자열 (0) | 2025.02.05 |
---|---|
[C#] 백준 1546번 : 평균 (0) | 2025.02.04 |
[C#] 백준 3052번 : 나머지 (0) | 2025.02.04 |
[C#] 백준 5597번 : 과제 안 내신 분..? (0) | 2025.02.04 |
[C#] 백준 10813번 : 공 바꾸기 (0) | 2025.01.24 |