Submission #1104486

#TimeUsernameProblemLanguageResultExecution timeMemory
1104486aaaaaarrozTreasure (IOI24_treasure)C++17
60 / 100
397 ms8504 KiB
#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; }

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...