Submission #24866289
Source Code Expand
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")*/
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX_N = 100005;
int h, w, n;
tuple<int, int, int> c[MAX_N];
int row[MAX_N];
int col[MAX_N];
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> h >> w >> n;
for (int i = 0; i < n; i++)
{
int a, b;
cin >> a >> b;
c[i] = { a, b, i };
}
sort(c, c + n, [](const auto& t1, const auto& t2)
{
return get<0>(t1) < get<0>(t2);
});
for (int i = 0; i < n; i++)
{
if (i == 0)
row[get<2>(c[i])] = 1;
else if (get<0>(c[i]) == get<0>(c[i - 1]))
row[get<2>(c[i])] = row[get<2>(c[i - 1])];
else
row[get<2>(c[i])] = row[get<2>(c[i - 1])] + 1;
}
sort(c, c + n, [](const auto& t1, const auto& t2)
{
return get<1>(t1) < get<1>(t2);
});
for (int i = 0; i < n; i++)
{
if (i == 0)
col[get<2>(c[i])] = 1;
else if (get<1>(c[i]) == get<1>(c[i - 1]))
col[get<2>(c[i])] = col[get<2>(c[i - 1])];
else
col[get<2>(c[i])] = col[get<2>(c[i - 1])] + 1;
}
for (int i = 0; i < n; i++)
cout << row[i] << ' ' << col[i] << '\n';
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Reorder Cards |
| User | artsin6 |
| Language | C++ (GCC 9.2.1) |
| Score | 300 |
| Code Size | 1269 Byte |
| Status | AC |
| Exec Time | 52 ms |
| Memory | 5564 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt |
| All | hand_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt, sample_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hand_01.txt | AC | 7 ms | 3536 KiB |
| random_01.txt | AC | 2 ms | 3528 KiB |
| random_02.txt | AC | 2 ms | 3576 KiB |
| random_03.txt | AC | 43 ms | 5140 KiB |
| random_04.txt | AC | 43 ms | 5040 KiB |
| random_05.txt | AC | 52 ms | 5564 KiB |
| random_06.txt | AC | 43 ms | 5500 KiB |
| random_07.txt | AC | 44 ms | 5432 KiB |
| random_08.txt | AC | 46 ms | 5488 KiB |
| random_09.txt | AC | 44 ms | 5560 KiB |
| random_10.txt | AC | 23 ms | 4116 KiB |
| random_11.txt | AC | 3 ms | 3568 KiB |
| random_12.txt | AC | 3 ms | 3660 KiB |
| random_13.txt | AC | 10 ms | 3808 KiB |
| random_14.txt | AC | 3 ms | 3692 KiB |
| random_15.txt | AC | 4 ms | 3668 KiB |
| random_16.txt | AC | 2 ms | 3648 KiB |
| sample_01.txt | AC | 2 ms | 3540 KiB |
| sample_02.txt | AC | 3 ms | 3544 KiB |