BOJ 18870 좌표 압축

1 개요[ | ]

BOJ 18870 좌표 압축


2 C++[ | ]

#include <bits/stdc++.h>
using namespace std;

int N, temp, cnt, a[1000000];
set<int> s;
map<int, int> m;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> temp;
        a[i] = temp;
        s.insert(temp);
    }
    cnt = 0;
    for(int i: s) {
        m[i] = cnt;
        cnt++;
    }
    for(int i=0; i<N; i++) {
        cout << m[a[i]] << ' ';
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}