슈콩

[SWEA] 5일차 - Magnetic 본문

Algorithms/SWEA

[SWEA] 5일차 - Magnetic

shukong 2025. 11. 4. 21:29

 

 

 

[문제]

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14hwZqABsCFAYD

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

 

[소스 코드]

import java.util.*;
import java.io.*;
public class Solution {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		for(int tc=1;tc<=10;tc++) {
			int n = Integer.parseInt(br.readLine());
			int[][] table = new int[100][100];
			for(int i=0;i<100;i++) {
				st = new StringTokenizer(br.readLine());
				for(int j=0;j<100;j++) {
					table[i][j] = Integer.parseInt(st.nextToken());
				}
			}
			int result = 0;
			for(int j=0;j<100;j++) {
				boolean pair = false;
				for(int i=0;i<100;i++) {
					if(table[i][j]==1) {
						pair = true;
					}
					if(pair && table[i][j]==2) {
						result++;
						pair = false;
					}
				}
			}
			System.out.println("#"+tc+" "+result);
		}
	}
}

'Algorithms > SWEA' 카테고리의 다른 글

[SWEA] 최장 경로  (0) 2025.11.05
[SWEA] 부분 수열의 합  (0) 2025.11.04
[SWEA] 3일차 - 회문 1  (0) 2025.11.04
[SWEA] 농작물 수확하기  (0) 2025.11.03
[SWEA] N-Queen  (0) 2025.10.30