이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> encode(vector<pair<int, int>> P) {
vector<int> codigo;
for (auto [x, y] : P) {
codigo.push_back(x + 1000000000);
codigo.push_back(y + 1000000000);
}
sort(codigo.begin(), codigo.end());
vector<int>codigos=codigo;
vector<int> result;
for (auto [x, y] : P) {
int pos_x = lower_bound(codigo.begin(), codigo.end(), x + 1000000000) - codigo.begin();
int pos_y = lower_bound(codigo.begin(), codigo.end(), y + 1000000000) - codigo.begin();
codigo[pos_x]--;
codigo[pos_y]--;
result.push_back(pos_x + 100000 + ((pos_y / 100) * 1000000));
result.push_back(pos_x + ((pos_y % 100) * 1000000));
}
for(int numero:result){
codigos.push_back(numero);
}
return codigos;
}
vector<pair<int, int>> decode(vector<int> S) {
sort(S.begin(), S.end());
int pos;
for(pos=0;pos<S.size();pos++){
if(S[pos]>=1000000000){
break;
}
}
map<int, pair<int, int>> mp;
for (int i = 0; i < pos; i++) {
int xx = S[i] % 100000;
int y_val = ((S[i] / 100000)%10);
if (y_val== 1) {
mp[xx].first = (S[i] / 1000000);
} else {
mp[xx].second = (S[i] / 1000000);
}
}
vector<pair<int, int>> cords;
for (auto &p : mp) {
int x = p.first;
int y1 = p.second.first;
int y2 = p.second.second;
cords.push_back({S[x+pos]-1000000000, S[y1 * 100 + y2+pos]-1000000000});
}
return cords;
}
컴파일 시 표준 에러 (stderr) 메시지
treasure.cpp: In function 'std::vector<std::pair<int, int> > decode(std::vector<int>)':
treasure.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(pos=0;pos<S.size();pos++){
| ~~~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |