Submission #3537909


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <unordered_map>
#include <utility>
#include <algorithm>

using namespace std;

void outputNum(long num) {
  if (num < 0) cout << "000000";
  else if (num < 10) cout << "00000" << num;
  else if (num < 100) cout << "0000" << num;
  else if (num < 1000) cout << "000" << num;
  else if (num < 10000) cout << "00" << num;
  else if (num < 100000) cout << "0" << num;
  else cout << num;
}

int main(void) {
  long N, M; // N: 県の数, M: 市の数
  cin >> N >> M;

  unordered_map< long, vector< long > > data;
  vector< pair< long, long > > memo;

  for (long i = 0; i < M; i++) {
    long P, Y;
    cin >> P >> Y;
    data[P].push_back(Y);
    memo.push_back(make_pair(P, Y));
  }

  for (auto it = data.begin(); it != data.end(); ++it) {
    sort(it->second.begin(), it->second.end());
/*
    cout << it->first << " : ";
    for (auto x : it->second) {
      cout << x << ", ";
    }
    cout << endl;
*/
  }

  for (auto it : memo) {
    long P = it.first;
    long Y = it.second;

/*
    cout << "P = " << P << ", Y = " << Y << endl;

    cout << P << " : ";
    for (auto x : data[P]) {
      cout << x << ", ";
    }
    cout << endl;
*/

    auto lower = lower_bound(data[P].begin(), data[P].end(), Y);
//    cout << "lower: " << lower - data[P].begin() << endl;
    outputNum(P);
    outputNum(lower - data[P].begin() + 1);
    cout << endl;
  }

  return 0;
}

Submission Info

Submission Time
Task C - ID
User set0gut1
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1483 Byte
Status
Exec Time 276 ms
Memory 11800 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 300 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt 269 ms 9588 KB
02.txt 249 ms 4072 KB
03.txt 1 ms 256 KB
04.txt 1 ms 256 KB
05.txt 258 ms 4072 KB
06.txt 259 ms 11800 KB
07.txt 4 ms 384 KB
08.txt 251 ms 5232 KB
09.txt 265 ms 11380 KB
10.txt 259 ms 4720 KB
11.txt 236 ms 3952 KB
12.txt 168 ms 3172 KB
13.txt 245 ms 4208 KB
14.txt 267 ms 9588 KB
15.txt 268 ms 9588 KB
16.txt 267 ms 9588 KB
17.txt 267 ms 9588 KB
18.txt 276 ms 9588 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB