시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 32 5 5 41.667%

문제

N행, M열로 이루어진 표에 32비트 부호있는 정수가 저장되어 있다. 제일 왼쪽 열은 1이고, 오른쪽으로 갈 수록 번호가 1씩 증가한다.

Ai(1 ≤ i ≤ M)를 i번 열에 있는 모든 수의 곱으로 정의하자. 이때, 가장 큰 값을 갖는 열의 번호를 찾는 프로그램을 작성하시오. 그러한 열이 여러개라면, 번호가 가장 큰 열을 출력한다.

입력

첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스의 첫째 줄에는 M과 N이 주어진다. (1 ≤ M ≤ 20, 1 ≤ N ≤ 1000) 다음 N개 줄에는 M개의 32비트 부호있는 정수가 주어진다.

출력

각 테스트 케이스에 대해서 한 줄에 하나씩 가장 큰 곱을 갖는 열의 번호를 출력한다.

예제 입력 1

2
3 3
20 10 30
15 20 20
30 30 20
3 2
2 -2 2
2 -2 2

예제 출력 1

3
3
W3sicHJvYmxlbV9pZCI6IjM3MjQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQ0NWMiLCJkZXNjcmlwdGlvbiI6IjxwPk5cdWQ1ODksIE1cdWM1ZjRcdWI4NWMgXHVjNzc0XHViOGU4XHVjNWI0XHVjOWM0IFx1ZDQ1Y1x1YzVkMCAzMlx1YmU0NFx1ZDJiOCBcdWJkODBcdWQ2MzhcdWM3ODhcdWIyOTQgXHVjODE1XHVjMjE4XHVhYzAwIFx1YzgwMFx1YzdhNVx1YjQxOFx1YzViNCBcdWM3ODhcdWIyZTQuIFx1YzgxY1x1Yzc3YyBcdWM2N2NcdWNhYmQgXHVjNWY0XHVjNzQwIDFcdWM3NzRcdWFjZTAsIFx1YzYyNFx1Yjk3OFx1Y2FiZFx1YzczY1x1Yjg1YyBcdWFjMDggXHVjMjE4XHViODVkIFx1YmM4OFx1ZDYzOFx1YWMwMCAxXHVjNTI5IFx1Yzk5ZFx1YWMwMFx1ZDU1Y1x1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W0gb2YgdGhlc2UgcHJvZHVjdHMgYW5kIHByaW50IHRoZSBjb2x1bW4gbnVtYmVyIHdoZXJlIHRoaXMgbWF4aW11bSBwcm9kdWN0IGlzIGFjaGlldmVkLiBJZiB0aGVyZSBhcmUgbWFueSBzdWNoIGNvbHVtbnMsIHByaW50IHRoZSBsYXJnZXN0IG51bWJlciBvZiB0aGUgY29sdW1uLjxcL3A+XHJcbiIsImlucHV0IjoiPHA+Q29uc2lzdHMgb2YgbXVsdGlwbGUgdGVzdHMuIEVhY2ggdGVzdCBiZWdpbnMgd2l0aCBhIGxpbmUgd2l0aCB0d28gaW50ZWdlcnMgbSBhbmQgbiAoMSAmbGU7IG0gJmxlOyAyMCwgMSAmbGU7IG4gJmxlOyAxMDAwKS4gRWFjaCBvZiB0aGUgbmV4dCBuIGxpbmVzIGNvbnRhaW5zIG0gMzItYml0IHNpZ25lZCBpbnRlZ2Vycy48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5Gb3IgZWFjaCB0ZXN0IGNhc2UgcHJpbnQgb24gYSBzZXBhcmF0ZSBsaW5lIHRoZSBjb2x1bW4gbnVtYmVyIHdpdGggdGhlIG1heGltdW0gcHJvZHVjdC4gSWYgdGhlcmUgYXJlIHNldmVyYWwgb2YgdGhlbSAmbmRhc2g7IHByaW50IHRoZSBsYXJnZXN0IG51bWJlciBvZiBzdWNoIGNvbHVtbi48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

ACM-ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2010 A번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: wider93