티스토리 뷰
출처 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14hwZqABsCFAYD
#include <iostream>
#include <algorithm>
#include <memory.h>
using namespace std;
int N,result;
int arr[100][100];
int main()
{
int T; int t=1;
T = 10;
while (T--)
{
cin >> N; result = 0;
for (int i = 0; i < N; i++)for (int j = 0; j < N; j++) cin >> arr[i][j];
for (int j = 0; j < N; j++)
{
for (int i = 0; i < N; i++)
{
if (arr[i][j] == 2) arr[i][j] = 0;
else if (arr[i][j] == 1) break;
}
for (int i = N-1; i >=0; i--)
{
if (arr[i][j] == 1) arr[i][j] = 0;
else if (arr[i][j] == 2) break;
}
}
for (int j = 0; j < N; j++)
{
int flag = 0;
for (int i = 0; i < N; i++)
{
if (arr[i][j] == 1)
{
if (flag == 0)flag = 1;
}
else if (arr[i][j] == 2)
{
if (flag == 1)
{
flag = 0; result += 1;
}
}
}
}
cout << "#" << t++ << " " << result << endl;
}
return 0;
}
'알고리즘 > SWEA' 카테고리의 다른 글
[SWEA 1222] 계산기1 (0) | 2018.08.10 |
---|---|
[SWEA 1221] GNS (0) | 2018.08.10 |
[SWEA 1219] 길찾기 (0) | 2018.08.10 |
[SWEA 1218] 괄호 짝짓기 (0) | 2018.08.10 |
[SWEA 1217] 거듭 제곱 (0) | 2018.08.10 |
- Total
- Today
- Yesterday
- 17837
- 17142
- 삼성
- DFS
- 17779
- 17143
- 새로운 게임 2
- SW Expert Academy
- 2018 KAKAO BLIND RECRUITMENT
- 게리맨더링 2
- 역량 테스트
- 트렌드
- 시간 복잡도
- STL
- 팁
- scanf
- boj
- 백준
- 2018 카카오 블라인드 채용
- 연구소 3
- 입출력
- hackerrank
- 17140
- string
- 미세먼지 안녕!
- 이차원 배열과 연산
- 알고리즘
- 17144
- DP
- SWEA
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |