코딩테스트
정올 uniqueness(c++)
leeeehhjj
2024. 2. 25. 17:47
https://jungol.co.kr/problem/1133
JUNGOL
history 최근 본 문제
jungol.co.kr
#include <iostream>
#include <cstring>
using namespace std;
int N;
char S[10000+10][20+10];
int used[10010];
void InputData(){
cin >> N;
for (int i=1; i<=N; i++){
cin >> S[i];
}
}
void solve() {
bool unique = true;
for (int i=1; i<N; i++) {
bool first = true;
if(used[i] == 1) continue;
for (int j=i+1; j<=N; j++) {
if (used[j] == 1) continue;
if (strcmp(S[i], S[j]) == 0) {
unique = false;
if (first) {
first = false;
cout << S[i] << " " << i << " " << j;
}
else {
cout << " " << j;
}
used[j] = 1;
}
}
if (!first) cout << "\n";
}
if (unique)
cout << "unique";
}
int main(){
InputData();// 입력받는 부분
// 여기서부터 작성
solve();
return 0;
}