11660 1

[Baekjoon] 11660_๊ตฌ๊ฐ„ ํ•ฉ ๊ตฌํ•˜๊ธฐ 5

Silver I๋ฌธ์ œ(์ถœ์ฒ˜: https://www.acmicpc.net/problem/11660)๋ฌธ์ œ  N×N๊ฐœ์˜ ์ˆ˜๊ฐ€ N×N ํฌ๊ธฐ์˜ ํ‘œ์— ์ฑ„์›Œ์ ธ ์žˆ๋‹ค. (x1, y1)๋ถ€ํ„ฐ (x2, y2)๊นŒ์ง€ ํ•ฉ์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. (x, y)๋Š” xํ–‰ y์—ด์„ ์˜๋ฏธํ•œ๋‹ค.์˜ˆ๋ฅผ ๋“ค์–ด, N = 4์ด๊ณ , ํ‘œ๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™์ด ์ฑ„์›Œ์ ธ ์žˆ๋Š” ๊ฒฝ์šฐ๋ฅผ ์‚ดํŽด๋ณด์ž.1234234534564567์—ฌ๊ธฐ์„œ (2, 2)๋ถ€ํ„ฐ (3, 4)๊นŒ์ง€ ํ•ฉ์„ ๊ตฌํ•˜๋ฉด 3+4+5+4+5+6 = 27์ด๊ณ , (4, 4)๋ถ€ํ„ฐ (4, 4)๊นŒ์ง€ ํ•ฉ์„ ๊ตฌํ•˜๋ฉด 7์ด๋‹ค.ํ‘œ์— ์ฑ„์›Œ์ ธ ์žˆ๋Š” ์ˆ˜์™€ ํ•ฉ์„ ๊ตฌํ•˜๋Š” ์—ฐ์‚ฐ์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ด๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.  ์ž…๋ ฅ ์ฒซ์งธ ์ค„์— ํ‘œ์˜ ํฌ๊ธฐ N๊ณผ ํ•ฉ์„ ๊ตฌํ•ด์•ผ ํ•˜๋Š” ํšŸ์ˆ˜ M์ด ์ฃผ์–ด์ง„๋‹ค. (1 ≤ N ≤ 1024, 1 ≤ M ..