problem_id
stringlengths 6
6
| language
stringclasses 2
values | original_status
stringclasses 3
values | original_src
stringlengths 19
243k
| changed_src
stringlengths 19
243k
| change
stringclasses 3
values | i1
int64 0
8.44k
| i2
int64 0
8.44k
| j1
int64 0
8.44k
| j2
int64 0
8.44k
| error
stringclasses 270
values | stderr
stringlengths 0
226k
|
---|---|---|---|---|---|---|---|---|---|---|---|
p03221 | Python | Runtime Error | from collections import defaultdict
N, M = map(int, input().split())
P, Y = [], []
ylist = defaultdict(list)
pset = set()
for i in range(M):
p, y = map(int, input().split())
P.append(p)
Y.append(y)
ylist[p].append(y)
pset.add(p)
cdict = defaultdict(dict)
for p in pset:
syear = sorted(ylist[p])
for i, y in enumerate(syear):
cdict[p][y] = i + 1
for i in range(M):
p = P[i]
y = Y[i]
rank = cdict[p][y]
print(f"{p:06}{rank:06}")
| from collections import defaultdict
N, M = map(int, input().split())
P, Y = [], []
ylist = defaultdict(list)
pset = set()
for i in range(M):
p, y = map(int, input().split())
P.append(p)
Y.append(y)
ylist[p].append(y)
pset.add(p)
cdict = defaultdict(dict)
for p in pset:
syear = sorted(ylist[p])
for i, y in enumerate(syear):
cdict[p][y] = i + 1
for i in range(M):
p = P[i]
y = Y[i]
rank = cdict[p][y]
print("{:06}{:06}".format(p, rank))
| replace | 23 | 24 | 23 | 24 | 0 | |
p03221 | Python | Runtime Error | N, M = [int(i) for i in input().split(" ")]
p = list()
y = list()
yd = {}
for i in range(0, M):
pi, yi = [int(i) for i in input().split(" ")]
p.append(pi)
y.append(yi)
if pi in yd.keys():
yd[pi].append(yi)
else:
yd[pi] = [yi]
ydid = {}
for i in yd.keys():
num = 1
for j in sorted(yd[p[i]]):
ydid[j] = num
num = num + 1
for i in range(0, M):
print("{:06}{:06}".format(p[i], ydid[y[i]]))
| N, M = [int(i) for i in input().split(" ")]
p = list()
y = list()
yd = {}
for i in range(0, M):
pi, yi = [int(i) for i in input().split(" ")]
p.append(pi)
y.append(yi)
if pi in yd.keys():
yd[pi].append(yi)
else:
yd[pi] = [yi]
ydid = {}
for i in yd.keys():
num = 1
for j in sorted(yd[i]):
ydid[j] = num
num = num + 1
for i in range(0, M):
print("{:06}{:06}".format(p[i], ydid[y[i]]))
| replace | 16 | 17 | 16 | 17 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int64_t INF = 1'000'000'000'000'000;
int64_t N, ans;
int main() {
int N, M;
cin >> N >> M;
vector<int64_t> P(M), Y(M);
for (int i = 0; i < M; i++)
cin >> P[i] >> Y[i];
vector<vector<int64_t>> sorted(N, vector<int64_t>());
for (int i = 0; i < M; i++) {
sorted[P[i] - 1].push_back(Y[i]);
sort(sorted[P[i] - 1].begin(), sorted[P[i] - 1].end());
}
for (int i = 0; i < M; i++) {
printf("%012lld\n", (int64_t)(P[i] * 1000000 +
lower_bound(sorted[P[i] - 1].begin(),
sorted[P[i] - 1].end(), Y[i]) -
sorted[P[i] - 1].begin() + 1));
}
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int64_t INF = 1'000'000'000'000'000;
int64_t N, ans;
int main() {
int N, M;
cin >> N >> M;
vector<int64_t> P(M), Y(M);
for (int i = 0; i < M; i++)
cin >> P[i] >> Y[i];
vector<vector<int64_t>> sorted(N, vector<int64_t>());
for (int i = 0; i < M; i++) {
sorted[P[i] - 1].push_back(Y[i]);
}
for (int i = 0; i < N; i++) {
sort(sorted[i].begin(), sorted[i].end());
}
for (int i = 0; i < M; i++) {
printf("%012lld\n", (int64_t)(P[i] * 1000000 +
lower_bound(sorted[P[i] - 1].begin(),
sorted[P[i] - 1].end(), Y[i]) -
sorted[P[i] - 1].begin() + 1));
}
} | replace | 21 | 22 | 21 | 24 | TLE | |
p03221 | C++ | Runtime Error | /*Function Template*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
ll Len(ll n) {
ll s = 0;
while (n != 0)
s++, n /= 10;
return s;
}
ll Sint(ll n) {
ll m = 0, s = 0, a = n;
while (a != 0)
s++, a /= 10;
for (ll i = s - 1; i >= 0; i--)
m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10;
return m;
}
ll Svec(vector<ll> v) {
ll n = 0;
for (ll i = 0; i < v.size(); i++)
n += v[i];
return n;
}
ll GCD(ll a, ll b) {
ll r, tmp;
/*自然数 a > b を確認・入替*/
if (a < b) {
tmp = a, a = b, b = tmp;
}
/*ユークリッドの互除法*/
r = a % b;
while (r != 0) {
a = b, b = r, r = a % b;
}
return b;
}
ll LCM(ll a, ll b) {
ll c = a, d = b, r, tmp;
/*自然数 a > b を確認・入替*/
if (a < b) {
tmp = a, a = b, b = tmp;
}
/*ユークリッドの互除法*/
r = a % b;
while (r != 0) {
a = b, b = r, r = a % b;
}
return c / b * d;
}
ll Factorial(ll n) {
ll m = 1;
while (n >= 1)
m *= n, n--;
return m;
}
vector<pair<char, ll>> runlength(string s, vector<pair<char, ll>> p) {
ll x = 1;
if (s.size() == 1) {
p.push_back(pair<char, ll>(s[0], 1));
return p;
}
for (ll i = 0; i < s.size() - 1; i++) {
if (s[i] == s[i + 1]) {
x++;
if (i == s.size() - 2) {
p.push_back(pair<char, ll>(s[i], x));
}
} else {
p.push_back(pair<char, ll>(s[i], x));
x = 1;
if (i == s.size() - 2) {
p.push_back(pair<char, ll>(s[s.size() - 1], x));
}
}
}
return p;
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
ll n, m, a[100000], b[100000];
cin >> n >> m;
vector<ll> v[100000];
rep(i, m) {
cin >> a[i] >> b[i];
v[a[i]].push_back(b[i]);
}
rep(i, n) { sort(ALL(v[i + 1])); }
rep(i, m) {
printf("%012lld\n",
(ll)(a[i] * 1000000) +
(lower_bound(ALL(v[a[i]]), b[i]) - v[a[i]].begin()) + 1);
}
} | /*Function Template*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
ll Len(ll n) {
ll s = 0;
while (n != 0)
s++, n /= 10;
return s;
}
ll Sint(ll n) {
ll m = 0, s = 0, a = n;
while (a != 0)
s++, a /= 10;
for (ll i = s - 1; i >= 0; i--)
m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10;
return m;
}
ll Svec(vector<ll> v) {
ll n = 0;
for (ll i = 0; i < v.size(); i++)
n += v[i];
return n;
}
ll GCD(ll a, ll b) {
ll r, tmp;
/*自然数 a > b を確認・入替*/
if (a < b) {
tmp = a, a = b, b = tmp;
}
/*ユークリッドの互除法*/
r = a % b;
while (r != 0) {
a = b, b = r, r = a % b;
}
return b;
}
ll LCM(ll a, ll b) {
ll c = a, d = b, r, tmp;
/*自然数 a > b を確認・入替*/
if (a < b) {
tmp = a, a = b, b = tmp;
}
/*ユークリッドの互除法*/
r = a % b;
while (r != 0) {
a = b, b = r, r = a % b;
}
return c / b * d;
}
ll Factorial(ll n) {
ll m = 1;
while (n >= 1)
m *= n, n--;
return m;
}
vector<pair<char, ll>> runlength(string s, vector<pair<char, ll>> p) {
ll x = 1;
if (s.size() == 1) {
p.push_back(pair<char, ll>(s[0], 1));
return p;
}
for (ll i = 0; i < s.size() - 1; i++) {
if (s[i] == s[i + 1]) {
x++;
if (i == s.size() - 2) {
p.push_back(pair<char, ll>(s[i], x));
}
} else {
p.push_back(pair<char, ll>(s[i], x));
x = 1;
if (i == s.size() - 2) {
p.push_back(pair<char, ll>(s[s.size() - 1], x));
}
}
}
return p;
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
ll n, m, a[100000], b[100000];
cin >> n >> m;
vector<ll> v[100001];
rep(i, m) {
cin >> a[i] >> b[i];
v[a[i]].push_back(b[i]);
}
rep(i, n) { sort(ALL(v[i + 1])); }
rep(i, m) {
printf("%012lld\n",
(ll)(a[i] * 1000000) +
(lower_bound(ALL(v[a[i]]), b[i]) - v[a[i]].begin()) + 1);
}
} | replace | 97 | 98 | 97 | 98 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1 << 29;
typedef long long int ll;
struct fuck {
int y;
int p;
int rank;
};
int main() {
int N, M;
cin >> N >> M;
vector<vector<pair<int, int>>> a(N + 2);
vector<fuck> F(N + 2);
rep(i, M) {
cin >> F[i].p >> F[i].y;
--F[i].p;
a[F[i].p].push_back(pair<int, int>(F[i].y, i));
}
rep(i, N) {
if (!a[i].empty())
sort(a[i].begin(), a[i].end());
}
rep(i, N) {
if (!a[i].empty()) {
int k = 1;
for (pair<int, int> j : a[i]) {
F[j.second].rank = k;
++k;
}
}
}
rep(i, M) {
cout << setw(6) << setfill('0') << F[i].p + 1 << setw(6) << setfill('0')
<< F[i].rank << endl;
}
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1 << 29;
typedef long long int ll;
struct fuck {
int y;
int p;
int rank;
};
int main() {
int N, M;
cin >> N >> M;
vector<vector<pair<int, int>>> a(N);
vector<fuck> F(M);
rep(i, M) {
cin >> F[i].p >> F[i].y;
--F[i].p;
a[F[i].p].push_back(pair<int, int>(F[i].y, i));
}
rep(i, N) {
if (!a[i].empty())
sort(a[i].begin(), a[i].end());
}
rep(i, N) {
if (!a[i].empty()) {
int k = 1;
for (pair<int, int> j : a[i]) {
F[j.second].rank = k;
++k;
}
}
}
rep(i, M) {
cout << setw(6) << setfill('0') << F[i].p + 1 << setw(6) << setfill('0')
<< F[i].rank << endl;
}
}
| replace | 24 | 26 | 24 | 26 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int n, m;
cin >> n;
cin >> m;
vector<int> p(m);
vector<int> y(m);
// cout << m << endl;
for (int i = 0; i < m; i++) {
cin >> p[i];
cin >> y[i];
}
vector<vector<int>> pre(n + 1, vector<int>(0));
// cout << pre.size() << endl;
// cout << pre[0].size() << endl;
for (int i = 0; i < m; i++) {
pre[p[i]].push_back(y[i]);
}
for (int i = 1; i < n + 1; i++) {
sort(pre[i].begin(), pre[i].end());
for (int j = 0; j < pre[i].size(); j++) {
// cout << pre[i][j] << " ";
}
// cout << endl;
}
for (int i = 0; i < m; i++) {
auto itr = find(pre[p[i]].begin(), pre[p[i]].end(), y[i]);
// cout << distance(pre[p[i]].begin(),itr)+1 << endl;
auto d = distance(pre[p[i]].begin(), itr) + 1;
cout << setfill('0') << right << setw(6) << p[i];
cout << setfill('0') << right << setw(6) << d;
cout << endl;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int n, m;
cin >> n;
cin >> m;
vector<int> p(m);
vector<int> y(m);
// cout << m << endl;
for (int i = 0; i < m; i++) {
cin >> p[i];
cin >> y[i];
}
vector<vector<int>> pre(n + 1, vector<int>(0));
// cout << pre.size() << endl;
// cout << pre[0].size() << endl;
for (int i = 0; i < m; i++) {
pre[p[i]].push_back(y[i]);
}
for (int i = 1; i < n + 1; i++) {
sort(pre[i].begin(), pre[i].end());
for (int j = 0; j < pre[i].size(); j++) {
// cout << pre[i][j] << " ";
}
// cout << endl;
}
for (int i = 0; i < m; i++) {
// auto itr = find(pre[p[i]].begin(),pre[p[i]].end(),y[i]);
auto itr = lower_bound(pre[p[i]].begin(), pre[p[i]].end(), y[i]);
// cout << distance(pre[p[i]].begin(),itr)+1 << endl;
auto d = distance(pre[p[i]].begin(), itr) + 1;
cout << setfill('0') << right << setw(6) << p[i];
cout << setfill('0') << right << setw(6) << d;
cout << endl;
}
return 0;
}
| replace | 45 | 46 | 45 | 47 | TLE | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
int cnt[100100];
int ans0[100100];
int ans1[100100];
string get_string(int x) {
string ans;
for (int d = 100000; d >= 1; d /= 10) {
ans += to_string(x / d);
x -= x / d;
}
return ans;
}
int main() {
int n, m;
cin >> n >> m;
vector<tuple<int, int, int>> v;
for (int city_id = 0; city_id < m; city_id++) {
int p, y;
cin >> p >> y;
v.push_back({p, y, city_id});
}
sort(v.begin(), v.end());
for (auto vv : v) {
int p = get<0>(vv);
int city_id = get<2>(vv);
cnt[p]++;
ans0[city_id] = p;
ans1[city_id] = cnt[p];
}
for (int city_id = 0; city_id < m; city_id++) {
string s1 = get_string(ans0[city_id]);
string s2 = get_string(ans1[city_id]);
assert(s1.size() == 6 && s2.size() == 6);
cout << s1 << s2;
if (city_id + 1 != m)
cout << '\n';
}
} | #include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
int cnt[100100];
int ans0[100100];
int ans1[100100];
string get_string(int x) {
string ans;
for (int d = 100000; d >= 1; d /= 10) {
ans += to_string(x / d);
x -= (x / d) * d;
}
return ans;
}
int main() {
int n, m;
cin >> n >> m;
vector<tuple<int, int, int>> v;
for (int city_id = 0; city_id < m; city_id++) {
int p, y;
cin >> p >> y;
v.push_back({p, y, city_id});
}
sort(v.begin(), v.end());
for (auto vv : v) {
int p = get<0>(vv);
int city_id = get<2>(vv);
cnt[p]++;
ans0[city_id] = p;
ans1[city_id] = cnt[p];
}
for (int city_id = 0; city_id < m; city_id++) {
string s1 = get_string(ans0[city_id]);
string s2 = get_string(ans1[city_id]);
assert(s1.size() == 6 && s2.size() == 6);
cout << s1 << s2;
if (city_id + 1 != m)
cout << '\n';
}
}
| replace | 31 | 32 | 31 | 32 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
ll to;
ll cost;
};
int main() {
int N, M;
cin >> N >> M;
vector<map<int, int>> p(N + 1);
vector<string> S(N + 1);
REP(i, M) {
int a, b;
cin >> a >> b;
p[a][b] = i;
}
for (int i = 1; i <= N; i++) {
int id = 1;
for (auto s : p[i]) {
string tmpl = to_string(i);
string tmpr = to_string(id);
reverse(tmpl.begin(), tmpl.end());
reverse(tmpr.begin(), tmpr.end());
while (tmpl.size() < 6) {
tmpl.push_back('0');
}
while (tmpr.size() < 6) {
tmpr.push_back('0');
}
reverse(tmpl.begin(), tmpl.end());
reverse(tmpr.begin(), tmpr.end());
S[s.second] = tmpl + tmpr;
id++;
}
}
REP(i, S.size()) { cout << S[i] << "\n"; }
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
ll to;
ll cost;
};
int main() {
int N, M;
cin >> N >> M;
vector<map<int, int>> p(N + 1);
vector<string> S(M);
REP(i, M) {
int a, b;
cin >> a >> b;
p[a][b] = i;
}
for (int i = 1; i <= N; i++) {
int id = 1;
for (auto s : p[i]) {
string tmpl = to_string(i);
string tmpr = to_string(id);
reverse(tmpl.begin(), tmpl.end());
reverse(tmpr.begin(), tmpr.end());
while (tmpl.size() < 6) {
tmpl.push_back('0');
}
while (tmpr.size() < 6) {
tmpr.push_back('0');
}
reverse(tmpl.begin(), tmpl.end());
reverse(tmpr.begin(), tmpr.end());
S[s.second] = tmpl + tmpr;
id++;
}
}
REP(i, S.size()) { cout << S[i] << "\n"; }
} | replace | 18 | 19 | 18 | 19 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M);
vector<int> Y(M);
for (int i = 0; i < N; i++) {
cin >> P[i] >> Y[i];
P[i]--;
}
vector<vector<int>> val(N);
for (int i = 0; i < M; i++) {
val[P[i]].push_back(Y[i]);
}
for (int j = 0; j < N; j++) {
sort(val[j].begin(), val[j].end());
}
for (int i = 0; i < M; i++) {
int v = P[i];
cout << setw(6) << setfill('0') << v + 1;
int id = lower_bound(val[v].begin(), val[v].end(), Y[i]) - val[v].begin();
cout << setw(6) << setfill('0') << id + 1 << endl;
}
return 0;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M);
vector<int> Y(M);
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
P[i]--;
}
vector<vector<int>> val(N);
for (int i = 0; i < M; i++) {
val[P[i]].push_back(Y[i]);
}
for (int j = 0; j < N; j++) {
sort(val[j].begin(), val[j].end());
}
for (int i = 0; i < M; i++) {
int v = P[i];
cout << setw(6) << setfill('0') << v + 1;
int id = lower_bound(val[v].begin(), val[v].end(), Y[i]) - val[v].begin();
cout << setw(6) << setfill('0') << id + 1 << endl;
}
return 0;
}
| replace | 13 | 14 | 13 | 14 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int n, m;
cin >> n >> m;
vector<int> p(m), y(m), l(m), num(n);
vector<pair<int, int>> post(m);
vector<pair<int, int>> city(m);
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
post[i] = make_pair(y[i], p[i]);
city[i] = make_pair(y[i], i);
}
for (int i = 0; i < m; i++)
num[i] = 0;
sort(post.begin(), post.end());
sort(city.begin(), city.end());
// for (int i = 0; i < m; i++) cout << city[i].second << "," <<
// post[i].second << "," << post[i].first << endl;
for (int i = 0; i < m; i++) {
num[post[i].second]++; // 県番号
l[city[i].second] = num[post[i].second];
}
for (int j = 0; j < m; j++) {
int tmp = 0, pp = p[j];
while (pp != 0) {
tmp++;
pp /= 10;
}
for (int i = 0; i < 6 - tmp; i++)
cout << "0";
cout << p[j];
tmp = 0;
int ll = l[j];
while (ll != 0) {
tmp++;
ll /= 10;
}
for (int i = 0; i < 6 - tmp; i++)
cout << "0";
cout << l[j] << endl;
}
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main(void) {
int n, m;
cin >> n >> m;
vector<int> p(m), y(m), l(m), num(n);
vector<pair<int, int>> post(m);
vector<pair<int, int>> city(m);
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
post[i] = make_pair(y[i], p[i]);
city[i] = make_pair(y[i], i);
}
for (int i = 0; i < n; i++)
num[i] = 0;
sort(post.begin(), post.end());
sort(city.begin(), city.end());
// for (int i = 0; i < m; i++) cout << city[i].second << "," <<
// post[i].second << "," << post[i].first << endl;
for (int i = 0; i < m; i++) {
num[post[i].second]++; // 県番号
l[city[i].second] = num[post[i].second];
}
for (int j = 0; j < m; j++) {
int tmp = 0, pp = p[j];
while (pp != 0) {
tmp++;
pp /= 10;
}
for (int i = 0; i < 6 - tmp; i++)
cout << "0";
cout << p[j];
tmp = 0;
int ll = l[j];
while (ll != 0) {
tmp++;
ll /= 10;
}
for (int i = 0; i < 6 - tmp; i++)
cout << "0";
cout << l[j] << endl;
}
}
| replace | 18 | 19 | 18 | 19 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define cinf(n, x, y) \
for (int i = 0; i < (n); i++) \
cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(m), y(m);
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
p[i]--;
}
vector<vector<int>> pre(n);
for (int i = 0; i < m; i++)
pre[p[i]].push_back(y[i]);
for (int i = 0; i < n; i++)
sort(pre[i].begin(), pre[i].end());
for (int i = 0; i < m; i++) {
int num = p[i];
printf("%06d", num + 1);
int id = lower_bound(pre[i].begin(), pre[i].end(), y[i]) - pre[i].begin();
printf("%06d\n", id + 1);
}
} | #include <bits/stdc++.h>
#define cinf(n, x, y) \
for (int i = 0; i < (n); i++) \
cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(m), y(m);
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
p[i]--;
}
vector<vector<int>> pre(n);
for (int i = 0; i < m; i++)
pre[p[i]].push_back(y[i]);
for (int i = 0; i < n; i++)
sort(pre[i].begin(), pre[i].end());
for (int i = 0; i < m; i++) {
int num = p[i];
printf("%06d", num + 1);
int id =
lower_bound(pre[num].begin(), pre[num].end(), y[i]) - pre[num].begin();
printf("%06d\n", id + 1);
}
} | replace | 25 | 26 | 25 | 27 | -11 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> v(n);
vector<vector<int>> c(100000, vector<int>());
for (int i = 0; i < m; i++) {
int p, y;
cin >> p >> y;
p--;
v[i] = make_pair(p, y);
c[p].push_back(y);
}
for (int i = 0; i < n; i++)
sort(c[i].begin(), c[i].end());
for (int i = 0; i < m; i++) {
int p = v[i].first;
int y = find(c[p].begin(), c[p].end(), v[i].second) - c[p].begin();
p++;
y++;
printf("%06d%06d\n", p, y);
}
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> v(m);
vector<vector<int>> c(100000, vector<int>());
for (int i = 0; i < m; i++) {
int p, y;
cin >> p >> y;
p--;
v[i] = make_pair(p, y);
c[p].push_back(y);
}
for (int i = 0; i < n; i++)
sort(c[i].begin(), c[i].end());
for (int i = 0; i < m; i++) {
int p = v[i].first;
int y = find(c[p].begin(), c[p].end(), v[i].second) - c[p].begin();
p++;
y++;
printf("%06d%06d\n", p, y);
}
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
typedef long long ll;
const int Inf = 100100100;
const double EPS = 1e-9;
int gcd(int a, int b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int bitCount(long bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> city[m];
vector<int> p(m), y(m);
rep(i, m) {
cin >> p[i] >> y[i];
city[p[i]].push_back(y[i]);
}
rep(i, n + 1) { sort(city[i].begin(), city[i].end()); }
rep(i, m) {
int index;
auto it = lower_bound(city[p[i]].begin(), city[p[i]].end(), y[i]);
index = it - city[p[i]].begin() + 1;
cout << setfill('0') << right << setw(6) << p[i];
cout << setfill('0') << right << setw(6) << index << '\n';
}
return 0;
}
| #include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
typedef long long ll;
const int Inf = 100100100;
const double EPS = 1e-9;
int gcd(int a, int b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int bitCount(long bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> city[100001];
vector<int> p(m), y(m);
rep(i, m) {
cin >> p[i] >> y[i];
city[p[i]].push_back(y[i]);
}
rep(i, n + 1) { sort(city[i].begin(), city[i].end()); }
rep(i, m) {
int index;
auto it = lower_bound(city[p[i]].begin(), city[p[i]].end(), y[i]);
index = it - city[p[i]].begin() + 1;
cout << setfill('0') << right << setw(6) << p[i];
cout << setfill('0') << right << setw(6) << index << '\n';
}
return 0;
}
| replace | 88 | 89 | 88 | 89 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
std::vector<int> P(M), Y(M);
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
P[i]--;
}
std::vector<map<int, int>> m(N);
for (int i = 0; i < M; i++)
m[P[i]][Y[i]] = 0;
for (int i = 0; i < N; i++) {
int k = 1;
for (auto &p : m[P[i]])
p.second = k++;
}
for (int i = 0; i < M; i++) {
cout << setfill('0') << right << setw(6) << P[i] + 1;
cout << setfill('0') << right << setw(6) << m[P[i]][Y[i]] << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
std::vector<int> P(M), Y(M);
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
P[i]--;
}
std::vector<map<int, int>> m(N);
for (int i = 0; i < M; i++)
m[P[i]][Y[i]] = 0;
for (int i = 0; i < N; i++) {
int k = 1;
for (auto &p : m[i])
p.second = k++;
}
for (int i = 0; i < M; i++) {
cout << setfill('0') << right << setw(6) << P[i] + 1;
cout << setfill('0') << right << setw(6) << m[P[i]][Y[i]] << endl;
}
}
| replace | 16 | 17 | 16 | 17 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
int p[m], y[m];
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
}
vector<vector<pair<int, int>>> vec_y;
vec_y.resize(n);
for (int i = 0; i < m; i++) {
vec_y[p[i] - 1].push_back(make_pair(y[i], i));
}
for (int i = 0; i < n; i++) {
if (vec_y[i].size() != 0) {
sort(vec_y[i].begin(), vec_y[i].end());
}
}
vector<tuple<int, int, int>> vec_ans;
for (int i = 0; i < n; i++) {
for (int j = 0; j < vec_y[i].size(); j++) {
// cout << vec_y[i][j].first << " " << vec_y[i][j].second << endl;
vec_ans.push_back(make_tuple(vec_y[i][j].second, p[i], j + 1));
}
}
sort(vec_ans.begin(), vec_ans.end());
for (int i = 0; i < m; i++) {
cout << setfill('0') << setw(6) << get<1>(vec_ans[i]);
cout << setfill('0') << setw(6) << get<2>(vec_ans[i]) << endl;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
int p[m], y[m];
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
}
vector<vector<pair<int, int>>> vec_y;
vec_y.resize(n);
for (int i = 0; i < m; i++) {
vec_y[p[i] - 1].push_back(make_pair(y[i], i));
}
for (int i = 0; i < n; i++) {
if (vec_y[i].size() != 0) {
sort(vec_y[i].begin(), vec_y[i].end());
}
}
vector<tuple<int, int, int>> vec_ans;
for (int i = 0; i < n; i++) {
for (int j = 0; j < vec_y[i].size(); j++) {
// cout << vec_y[i][j].first << " " << vec_y[i][j].second << endl;
vec_ans.push_back(make_tuple(vec_y[i][j].second, i + 1, j + 1));
}
}
sort(vec_ans.begin(), vec_ans.end());
for (int i = 0; i < m; i++) {
cout << setfill('0') << setw(6) << get<1>(vec_ans[i]);
cout << setfill('0') << setw(6) << get<2>(vec_ans[i]) << endl;
}
return 0;
} | replace | 43 | 44 | 43 | 44 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for (int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for (int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;
const double eps = 1e-10;
template <typename A, typename B> inline void chmin(A &a, B b) {
if (a > b)
a = b;
}
template <typename A, typename B> inline void chmax(A &a, B b) {
if (a < b)
a = b;
}
int32 N, M, K;
vector<int64> A, B;
string s;
double abss(double x) {
if (x < 0)
return x * -1;
return x;
}
int main(void) {
cin >> N >> M;
A = vector<int64>(N, 0);
using T = tuple<int32, int32, int32>;
vector<T> C(M);
REP(i, M) {
int32 a, b, c;
cin >> b >> a;
c = i;
C[i] = T(a, b, c);
}
sort(all(C));
vector<PII> res(M);
REP(i, M) {
int32 a, b, c;
tie(b, a, c) = C[i];
res[c] = PII(a, (A[a]++) + 1);
}
REP(i, M) {
cout << setw(6) << setfill('0') << res[i].fs << setw(6) << setfill('0')
<< res[i].sc << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for (int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for (int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;
const double eps = 1e-10;
template <typename A, typename B> inline void chmin(A &a, B b) {
if (a > b)
a = b;
}
template <typename A, typename B> inline void chmax(A &a, B b) {
if (a < b)
a = b;
}
int32 N, M, K;
vector<int64> A, B;
string s;
double abss(double x) {
if (x < 0)
return x * -1;
return x;
}
int main(void) {
cin >> N >> M;
A = vector<int64>(N + 1, 0);
using T = tuple<int32, int32, int32>;
vector<T> C(M);
REP(i, M) {
int32 a, b, c;
cin >> b >> a;
c = i;
C[i] = T(a, b, c);
}
sort(all(C));
vector<PII> res(M);
REP(i, M) {
int32 a, b, c;
tie(b, a, c) = C[i];
res[c] = PII(a, (A[a]++) + 1);
}
REP(i, M) {
cout << setw(6) << setfill('0') << res[i].fs << setw(6) << setfill('0')
<< res[i].sc << endl;
}
}
| replace | 41 | 42 | 41 | 42 | 0 | |
p03221 | C++ | Runtime Error | // long time no ac
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)
#define repe(i, I1, I2) for (i = I1; i < I2; i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
#define mod 1000000007
ll cd(ll n) {
ll count = 0;
while (n != 0) {
n = n / 10;
++count;
}
return count;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n, k, t, c = 0, i, m, x, y;
t = 1;
// cin>>t;
while (t--) {
cin >> n >> m;
vector<pair<ll, pair<ll, ll>>> h(n);
pair<ll, ll> a[n];
rep(i, m) {
cin >> x >> y;
a[i].first = x;
a[i].second = y;
h[i].first = x;
h[i].second.first = y;
h[i].second.second = i;
}
sort(h.begin(), h.end());
ll prev = h[0].first;
rep(i, m) {
if (h[i].first == prev) {
c++;
} else {
prev = h[i].first;
c = 1;
}
a[h[i].second.second].second = c;
}
rep(i, m) {
x = cd(a[i].first);
// cout<<x<<"#\n";
while (x < 6) {
x++;
cout << "0";
}
cout << a[i].first;
x = cd(a[i].second);
// cout<<x<<"#\n";
while (x < 6) {
x++;
cout << "0";
}
cout << a[i].second << "\n";
}
if (t != 0)
cout << "\n";
}
return 0;
} | // long time no ac
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vi vector<int>
#define rep(i, n) for (i = 0; i < n; i++)
#define repe(i, I1, I2) for (i = I1; i < I2; i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
#define mod 1000000007
ll cd(ll n) {
ll count = 0;
while (n != 0) {
n = n / 10;
++count;
}
return count;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n, k, t, c = 0, i, m, x, y;
t = 1;
// cin>>t;
while (t--) {
cin >> n >> m;
vector<pair<ll, pair<ll, ll>>> h(m);
pair<ll, ll> a[m];
rep(i, m) {
cin >> x >> y;
a[i].first = x;
a[i].second = y;
h[i].first = x;
h[i].second.first = y;
h[i].second.second = i;
}
sort(h.begin(), h.end());
ll prev = h[0].first;
rep(i, m) {
if (h[i].first == prev) {
c++;
} else {
prev = h[i].first;
c = 1;
}
a[h[i].second.second].second = c;
}
rep(i, m) {
x = cd(a[i].first);
// cout<<x<<"#\n";
while (x < 6) {
x++;
cout << "0";
}
cout << a[i].first;
x = cd(a[i].second);
// cout<<x<<"#\n";
while (x < 6) {
x++;
cout << "0";
}
cout << a[i].second << "\n";
}
if (t != 0)
cout << "\n";
}
return 0;
} | replace | 33 | 35 | 33 | 35 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, p[100000 + 1], y[100000 + 1];
vector<int> num_list[100000];
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d%d", &p[i], &y[i]);
num_list[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; i++) {
sort(num_list[i].begin(), num_list[i].end());
}
for (int i = 0; i < m; i++) {
printf("%06d", p[i]);
auto tmp =
1 + find(num_list[p[i] - 1].begin(), num_list[p[i] - 1].end(), y[i]) -
num_list[p[i] - 1].begin();
printf("%06ld\n", tmp);
}
}
| #include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, p[100000 + 1], y[100000 + 1];
vector<int> num_list[100000];
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d%d", &p[i], &y[i]);
num_list[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; i++) {
sort(num_list[i].begin(), num_list[i].end());
}
for (int i = 0; i < m; i++) {
printf("%06d", p[i]);
int tmp = 1 +
lower_bound(num_list[p[i] - 1].begin(), num_list[p[i] - 1].end(),
y[i]) -
num_list[p[i] - 1].begin();
printf("%06d\n", tmp);
}
}
| replace | 18 | 22 | 18 | 23 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
#define rep(i, n) for (int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main() {
int n, m;
int p[m], y[m];
scanf("%d%d", &n, &m);
pair<ll, ll> Pair;
vector<int> v[100001];
rep(i, m) {
scanf("%d%d", &p[i], &y[i]);
v[p[i]].push_back(y[i]);
}
rep(i, n) { sort(v[i + 1].begin(), v[i + 1].end()); }
rep(i, m) {
printf("%012lld\n",
ll(p[i]) * 1000000 +
int(lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]) -
v[p[i]].begin()) +
1);
}
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
#define rep(i, n) for (int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main() {
int n, m;
int p[100000], y[100000];
scanf("%d%d", &n, &m);
pair<ll, ll> Pair;
vector<int> v[100001];
rep(i, m) {
scanf("%d%d", &p[i], &y[i]);
v[p[i]].push_back(y[i]);
}
rep(i, n) { sort(v[i + 1].begin(), v[i + 1].end()); }
rep(i, m) {
printf("%012lld\n",
ll(p[i]) * 1000000 +
int(lower_bound(v[p[i]].begin(), v[p[i]].end(), y[i]) -
v[p[i]].begin()) +
1);
}
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
int main() {
int N, M;
scanf("%d", &N);
scanf("%d", &M);
std::vector<int> to(M + 5);
std::vector<int> order(M + 5);
int P, Y;
std::vector<std::map<int, int>> mp(M + 5);
for (int i = 0; i < M; i++) {
scanf("%d", &P);
scanf("%d", &Y);
P--;
to[i] = P;
mp[P].insert(std::make_pair(Y, i));
}
for (int i = 0; i < N; i++) {
// printf("i=%d\n", i);
int counter = 0;
for (auto entry : mp[i]) {
order[entry.second] = counter;
// printf("order[%d]=%d\n", entry.second, counter);
counter++;
}
/* for (int j=0; j<mp[i].size(); j++){
order[mp[i][j].second]=j;
}*/
}
for (int i = 0; i < M; i++) {
printf("%06d%06d\n", to[i] + 1, order[i] + 1);
}
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
int main() {
int N, M;
scanf("%d", &N);
scanf("%d", &M);
std::vector<int> to(M + 5);
std::vector<int> order(M + 5);
int P, Y;
std::vector<std::map<int, int>> mp(N + 5);
for (int i = 0; i < M; i++) {
scanf("%d", &P);
scanf("%d", &Y);
P--;
to[i] = P;
mp[P].insert(std::make_pair(Y, i));
}
for (int i = 0; i < N; i++) {
// printf("i=%d\n", i);
int counter = 0;
for (auto entry : mp[i]) {
order[entry.second] = counter;
// printf("order[%d]=%d\n", entry.second, counter);
counter++;
}
/* for (int j=0; j<mp[i].size(); j++){
order[mp[i][j].second]=j;
}*/
}
for (int i = 0; i < M; i++) {
printf("%06d%06d\n", to[i] + 1, order[i] + 1);
}
return 0;
}
| replace | 18 | 19 | 18 | 19 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
struct node {
int x;
int y;
int z;
};
int cmp(node a, node b) {
if (a.x == b.x) {
return a.y < b.y;
} else {
return a.x < b.x;
}
}
int main() {
int n, m;
node r[1000];
bool vis[10000] = {0};
int book[10000] = {0};
node a[1000], b[1000];
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a[i].x >> a[i].y;
a[i].z = i;
book[a[i].x]++;
}
sort(a, a + m, cmp);
int num = 1;
for (int i = 0; i < m; i++) {
r[a[i].z].x = a[i].x;
r[a[i].z].y = num;
num++;
if (a[i].x != a[i + 1].x)
num = 1;
}
for (int i = 0; i < m; i++) {
printf("%06d", r[i].x);
printf("%06d\n", r[i].y);
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
struct node {
int x;
int y;
int z;
};
int cmp(node a, node b) {
if (a.x == b.x) {
return a.y < b.y;
} else {
return a.x < b.x;
}
}
int main() {
int n, m;
node r[100008];
int book[100008] = {0};
node a[100008], b[100008];
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a[i].x >> a[i].y;
a[i].z = i;
book[a[i].x]++;
}
sort(a, a + m, cmp);
int num = 1;
for (int i = 0; i < m; i++) {
r[a[i].z].x = a[i].x;
r[a[i].z].y = num;
num++;
if (a[i].x != a[i + 1].x)
num = 1;
}
for (int i = 0; i < m; i++) {
printf("%06d", r[i].x);
printf("%06d\n", r[i].y);
}
return 0;
} | replace | 16 | 20 | 16 | 20 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define NMAX 110000
struct info {
int p;
int y;
int x;
};
int main(void) {
int n, m;
cin >> n >> m;
info py[NMAX];
for (int i = 0; i < m; i++) {
cin >> py[i].p >> py[i].y;
}
vector<int> mp[NMAX];
for (int i = 0; i < m; i++) {
mp[py[i].p].emplace_back(py[i].y);
}
for (int i = 0; i <= n; i++) {
sort(mp[i].begin(), mp[i].end());
}
for (int i = 0; i < m; i++) {
auto itr = find(mp[py[i].p].begin(), mp[py[i].p].end(), py[i].y);
py[i].x = (int)(itr - mp[py[i].p].begin()) + 1;
cout << setw(6) << setfill('0') << py[i].p;
cout << setw(6) << setfill('0') << py[i].x << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define NMAX 110000
struct info {
int p;
int y;
int x;
};
int main(void) {
int n, m;
cin >> n >> m;
info py[NMAX];
for (int i = 0; i < m; i++) {
cin >> py[i].p >> py[i].y;
}
vector<int> mp[NMAX];
for (int i = 0; i < m; i++) {
mp[py[i].p].emplace_back(py[i].y);
}
for (int i = 0; i <= n; i++) {
sort(mp[i].begin(), mp[i].end());
}
for (int i = 0; i < m; i++) {
auto itr = lower_bound(mp[py[i].p].begin(), mp[py[i].p].end(), py[i].y);
py[i].x = (int)distance(mp[py[i].p].begin(), itr) + 1;
cout << setw(6) << setfill('0') << py[i].p;
cout << setw(6) << setfill('0') << py[i].x << endl;
}
return 0;
}
| replace | 27 | 29 | 27 | 29 | TLE | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using P = pair<int, int>;
int main() {
int N, M;
cin >> N >> M;
vector<int> City[N + 1];
int P[M], Y[M];
for (int i = 0; i < M; i++) {
int p, y;
cin >> p >> y;
City[p].push_back(y);
P[i] = p, Y[i] = y;
}
for (int i = 0; i < N + 1; i++)
sort(all(City[P[i]]));
for (int i = 0; i < M; i++) {
auto iter = upper_bound(all(City[P[i]]), Y[i]);
cout << setfill('0') << right << setw(6) << P[i] << setfill('0') << right
<< setw(6) << iter - City[P[i]].begin() << endl;
}
return 0;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using P = pair<int, int>;
int main() {
int N, M;
cin >> N >> M;
vector<int> City[N + 1];
int P[M], Y[M];
for (int i = 0; i < M; i++) {
int p, y;
cin >> p >> y;
City[p].push_back(y);
P[i] = p, Y[i] = y;
}
for (int i = 0; i < N + 1; i++)
sort(all(City[i]));
for (int i = 0; i < M; i++) {
auto iter = upper_bound(all(City[P[i]]), Y[i]);
cout << setfill('0') << right << setw(6) << P[i] << setfill('0') << right
<< setw(6) << iter - City[P[i]].begin() << endl;
}
return 0;
}
| replace | 22 | 23 | 22 | 23 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repi(i, a, b) for (int i = a; i <= (b); ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define pr(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int, int> P;
struct aaa {
aaa() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(20);
};
} aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N, M, y, p, ix;
int main() {
cin >> N >> M;
vector<pair<int, pair<int, int>>> city;
vector<string> ans(M);
rep(i, M) cin >> p >> y, city.pb(mp(p, mp(y, i + 1)));
sort(ALL(city));
int k = 1;
rep(i, M) {
int num = city[i].second.second;
string ps = to_s(city[i].first);
string s = "";
rep(i, 6 - sz(ps)) s += "0";
s += ps;
rep(i, 6 - sz(to_s(k))) s += "0";
s += to_s(k);
ans[num] = s;
if (i < M - 1 && city[i + 1].first == city[i].first)
++k;
else
k = 1;
}
rep1(i, M) pr(ans[i]);
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repi(i, a, b) for (int i = a; i <= (b); ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define pr(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int, int> P;
struct aaa {
aaa() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(20);
};
} aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N, M, y, p, ix;
int main() {
cin >> N >> M;
vector<pair<int, pair<int, int>>> city;
vector<string> ans(M + 1);
rep(i, M) cin >> p >> y, city.pb(mp(p, mp(y, i + 1)));
sort(ALL(city));
int k = 1;
rep(i, M) {
int num = city[i].second.second;
string ps = to_s(city[i].first);
string s = "";
rep(i, 6 - sz(ps)) s += "0";
s += ps;
rep(i, 6 - sz(to_s(k))) s += "0";
s += to_s(k);
ans[num] = s;
if (i < M - 1 && city[i + 1].first == city[i].first)
++k;
else
k = 1;
}
rep1(i, M) pr(ans[i]);
} | replace | 36 | 37 | 36 | 37 | -11 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
const int MAX = 510000;
const int MOD = 1000000007;
int main() {
int N, M;
cin >> N >> M;
vector<P1> a(M);
rep(i, M) cin >> a[i].fi >> a[i].sc.fi;
rep(i, M) a[i].sc.sc = i;
SORT(a);
vector<int> num(M);
int cnt = 1;
num[0] = cnt;
rep(i, M) {
if (a[i].fi == a[i + 1].fi)
num[i + 1] = ++cnt;
else {
cnt = 1;
num[i + 1] = cnt;
}
}
vector<P1> b(M);
rep(i, M) {
b[i].fi = a[i].sc.sc;
b[i].sc.fi = a[i].fi;
b[i].sc.sc = num[i];
}
SORT(b);
rep(i, M) {
printf("%06d", b[i].sc.fi);
printf("%06d", b[i].sc.sc);
cout << endl;
}
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (int i = 0; i < x; i++)
#define repn(i, x) for (int i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
const int MAX = 510000;
const int MOD = 1000000007;
int main() {
int N, M;
cin >> N >> M;
vector<P1> a(M);
rep(i, M) cin >> a[i].fi >> a[i].sc.fi;
rep(i, M) a[i].sc.sc = i;
SORT(a);
vector<int> num(M);
int cnt = 1;
num[0] = cnt;
rep(i, M - 1) {
if (a[i].fi == a[i + 1].fi)
num[i + 1] = ++cnt;
else {
cnt = 1;
num[i + 1] = cnt;
}
}
vector<P1> b(M);
rep(i, M) {
b[i].fi = a[i].sc.sc;
b[i].sc.fi = a[i].fi;
b[i].sc.sc = num[i];
}
SORT(b);
rep(i, M) {
printf("%06d", b[i].sc.fi);
printf("%06d", b[i].sc.sc);
cout << endl;
}
}
| replace | 43 | 44 | 43 | 44 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<vector<int>> PN(N);
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
PN[P[i] - 1].push_back(Y[i]);
}
for (auto &pn : PN)
sort(pn.begin(), pn.end());
for (int i = 0; i < M; i++) {
int index;
for (int j = 0; j < PN[P[i] - 1].size(); j++) {
if (PN[P[i] - 1][j] == Y[i]) {
index = j;
break;
}
}
printf("%06d%06d\n", P[i], index + 1);
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<vector<int>> PN(N);
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
PN[P[i] - 1].push_back(Y[i]);
}
for (auto &pn : PN)
sort(pn.begin(), pn.end());
for (int i = 0; i < M; i++) {
auto itr = lower_bound(PN[P[i] - 1].begin(), PN[P[i] - 1].end(), Y[i]);
printf("%06d%06d\n", P[i], 1 + distance(PN[P[i] - 1].begin(), itr));
}
return 0;
} | replace | 19 | 27 | 19 | 22 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
int main() {
int n, m;
std::cin >> n >> m;
std::vector<int> p(m), y(m);
std::vector<std::vector<int>> vec(n + 1);
for (int i = 0; i < m; i++) {
std::cin >> p[i] >> y[i];
vec[p[i]].push_back(y[i]);
}
for (int i = 1; i <= n; i++) {
std::sort(vec[i].begin(), vec[i].end());
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < vec[p[i]].size(); j++) {
if (vec[p[i]][j] == y[i]) {
std::cout << std::setfill('0') << std::right << std::setw(6) << p[i]
<< std::setfill('0') << std::right << std::setw(6) << j + 1
<< std::endl;
}
}
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
int main() {
int n, m;
std::cin >> n >> m;
std::vector<int> p(m), y(m);
std::vector<std::vector<int>> vec(n + 1);
for (int i = 0; i < m; i++) {
std::cin >> p[i] >> y[i];
vec[p[i]].push_back(y[i]);
}
for (int i = 1; i <= n; i++) {
std::sort(vec[i].begin(), vec[i].end());
}
for (int i = 0; i < m; i++) {
auto itr = std::lower_bound(vec[p[i]].begin(), vec[p[i]].end(), y[i]);
std::cout << std::setfill('0') << std::right << std::setw(6) << p[i]
<< std::setfill('0') << std::right << std::setw(6)
<< std::distance(vec[p[i]].begin(), itr) + 1 << std::endl;
}
return 0;
}
| replace | 25 | 32 | 25 | 29 | TLE | |
p03221 | C++ | Runtime Error | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
int gcd(int x, int y) {
x = std::abs(x);
y = std::abs(y);
int a = std::max(x, y), b = std::min(x, y);
int r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
long long lcm(int x, int y) { return (long long)x * y / gcd(x, y); }
int main(void) {
int N, M;
scanf("%d %d", &N, &M);
std::vector<std::pair<int, int>> cities(M), sorted(M);
for (int i = 0; i < M; ++i) {
scanf("%d %d", &(cities[i].first), &(cities[i].second));
sorted[i] = cities[i];
}
sort(sorted.begin(), sorted.end());
int c = 0, n = 0;
std::vector<std::pair<int, int>> ids(M);
for (int i = 0; i < M; ++i) {
if (sorted[i].first != c) {
c = sorted[i].first;
n = 0;
}
ids[i].first = c;
ids[i].second = ++n;
}
for (int i = 0; i < M; ++i) {
std::vector<std::pair<int, int>>::iterator it =
std::lower_bound(sorted.begin(), sorted.end(), cities[i]);
int idx = it - cities.begin();
printf("%06d%06d\n", ids[idx].first, ids[idx].second);
}
return 0;
} | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
int gcd(int x, int y) {
x = std::abs(x);
y = std::abs(y);
int a = std::max(x, y), b = std::min(x, y);
int r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
long long lcm(int x, int y) { return (long long)x * y / gcd(x, y); }
int main(void) {
int N, M;
scanf("%d %d", &N, &M);
std::vector<std::pair<int, int>> cities(M), sorted(M);
for (int i = 0; i < M; ++i) {
scanf("%d %d", &(cities[i].first), &(cities[i].second));
sorted[i] = cities[i];
}
sort(sorted.begin(), sorted.end());
int c = 0, n = 0;
std::vector<std::pair<int, int>> ids(M);
for (int i = 0; i < M; ++i) {
if (sorted[i].first != c) {
c = sorted[i].first;
n = 0;
}
ids[i].first = c;
ids[i].second = ++n;
}
for (int i = 0; i < M; ++i) {
std::vector<std::pair<int, int>>::iterator it =
std::lower_bound(sorted.begin(), sorted.end(), cities[i]);
int idx = it - sorted.begin();
printf("%06d%06d\n", ids[idx].first, ids[idx].second);
}
return 0;
} | replace | 51 | 52 | 51 | 52 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
struct Edge {
long long to;
long long cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
const long long INF = 1LL << 60;
long long modpow(long long a, long long n, long long m) {
long long ans = 1;
while (n) {
if (n & 1) {
ans = (ans * a) % m;
}
a = (a * a) % m;
n >>= 1;
}
return ans;
}
long long combi(long long n, long long a) {
long long ans = 1, ans1 = 1;
for (long long i = n - a + 1; i <= n; i++) {
ans *= i % MOD;
ans %= MOD;
}
for (long long i = 2; i <= a; i++)
ans1 = (ans1 * i) % MOD;
ans1 = modpow(ans1, MOD - 2, MOD);
return ((ans % MOD) * ans1) % MOD;
}
template <typename T>
bool next_combination(const T first, const T last, int k) {
const T subset = first + k;
// empty container | k = 0 | k == n
if (first == last || first == subset || last == subset) {
return false;
}
T src = subset;
while (first != src) {
src--;
if (*src < *(last - 1)) {
T dest = subset;
while (*src >= *dest) {
dest++;
}
iter_swap(src, dest);
rotate(src + 1, dest + 1, last);
rotate(subset, subset + (last - dest) - 1, last);
return true;
}
}
// restore
rotate(first, subset, last);
return false;
}
void dfs(vector<ll> s, ll mx, ll N, vector<vector<ll>> &arr) {
if (s.size() == (size_t)N) {
// cout << s.c_str() << endl;
arr.push_back(s);
} else {
for (ll c = s.size() > 0 ? 0 : 0; c <= mx; c++) {
s.push_back(c);
dfs(s, mx, N, arr);
s.pop_back();
}
}
return;
}
int bfs(int sx, int sy, int gx, int gy, int h, int w,
vector<vector<char>> map) {
queue<pair<int, int>> s;
vector<vector<ll>> ans;
for (int i = 0; i < h; i++) {
vector<ll> aa(w);
ans.push_back(aa);
}
s.push(make_pair(sx, sy));
while (s.size() > 0) {
pair<int, int> tmp = s.front();
s.pop();
map[tmp.first][tmp.second] = '#';
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
if (tmp.first + i < 0 || tmp.first + i >= h) {
continue;
}
if (tmp.second + j < 0 || tmp.second + j >= w) {
continue;
}
if (i != 0 && j != 0) {
continue;
}
if (i == 0 && j == 0) {
continue;
}
if (map[tmp.first + i][tmp.second + j] == '#') {
continue;
}
map[tmp.first + i][tmp.second + j] = '#';
if (ans[tmp.first + i][tmp.second + j] == 0) {
ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
} else {
ans[tmp.first + i][tmp.second + j] =
min(ans[tmp.first + i][tmp.second + j],
ans[tmp.first][tmp.second] + 1);
}
s.push(make_pair(tmp.first + i, tmp.second + j));
}
}
}
return ans[gy][gx];
}
ll modfactorial(ll a) {
if (a == 1)
return 1;
return (a % MOD) * (modfactorial(a - 1) % MOD);
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
/* dijkstra(G,s,dis)
入力:グラフ G, 開始点 s, 距離を格納する dis
計算量:O(|E|log|V|)
副作用:dis が書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<ll> &dis, vector<ll> &prev) {
int N = G.size();
dis.resize(N, INF);
prev.resize(N, -1); // 初期化
priority_queue<P, vector<P>, greater<P>> pq;
dis[s] = 0;
pq.emplace(dis[s], s);
while (!pq.empty()) {
P p = pq.top();
pq.pop();
int v = p.second;
if (dis[v] < p.first) {
continue;
}
for (auto &e : G[v]) {
if (dis[e.to] > dis[v] + e.cost) {
dis[e.to] = dis[v] + e.cost;
prev[e.to] = v; // 頂点 v を通って e.to にたどり着いた
pq.emplace(dis[e.to], e.to);
}
}
}
}
vector<ll> get_path(const vector<ll> &prev, ll t) {
vector<ll> path;
for (ll cur = t; cur != -1; cur = prev[cur]) {
path.push_back(cur);
}
reverse(path.begin(), path.end()); // 逆順なのでひっくり返す
return path;
}
vector<string> split(string &s, char delim) {
vector<string> elems;
stringstream ss(s);
string item;
while (getline(ss, item, delim)) {
if (!item.empty()) {
elems.push_back(item);
}
}
return elems;
}
vector<ll> divisor(ll n) {
vector<ll> ret;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
int main() {
ll n, m;
cin >> n >> m;
vector<pair<ll, ll>> v;
vector<ll> p(m);
vector<ll> cnt(m + 1, 0);
vector<pair<ll, ll>> ans(m);
for (int i = 0; i < m; i++) {
ll a, b;
cin >> p[i] >> b;
v.push_back(make_pair(b, i));
}
sort(v.begin(), v.end());
for (int i = 0; i < m; i++) {
ll tmp = ++cnt[p[v[i].second]];
ans[v[i].second] = make_pair(p[v[i].second], tmp);
}
for (int i = 0; i < m; i++) {
if (ans[i].first < 100000) {
std::cout << std::setfill('0') << std::right << std::setw(6)
<< ans[i].first;
} else {
cout << ans[i].first;
}
if (ans[i].second < 100000) {
std::cout << std::setfill('0') << std::right << std::setw(6)
<< ans[i].second << endl;
} else {
cout << ans[i].second << endl;
}
}
return 0;
}
// cout << std::fixed << std::setprecision(15) | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
struct Edge {
long long to;
long long cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
const long long INF = 1LL << 60;
long long modpow(long long a, long long n, long long m) {
long long ans = 1;
while (n) {
if (n & 1) {
ans = (ans * a) % m;
}
a = (a * a) % m;
n >>= 1;
}
return ans;
}
long long combi(long long n, long long a) {
long long ans = 1, ans1 = 1;
for (long long i = n - a + 1; i <= n; i++) {
ans *= i % MOD;
ans %= MOD;
}
for (long long i = 2; i <= a; i++)
ans1 = (ans1 * i) % MOD;
ans1 = modpow(ans1, MOD - 2, MOD);
return ((ans % MOD) * ans1) % MOD;
}
template <typename T>
bool next_combination(const T first, const T last, int k) {
const T subset = first + k;
// empty container | k = 0 | k == n
if (first == last || first == subset || last == subset) {
return false;
}
T src = subset;
while (first != src) {
src--;
if (*src < *(last - 1)) {
T dest = subset;
while (*src >= *dest) {
dest++;
}
iter_swap(src, dest);
rotate(src + 1, dest + 1, last);
rotate(subset, subset + (last - dest) - 1, last);
return true;
}
}
// restore
rotate(first, subset, last);
return false;
}
void dfs(vector<ll> s, ll mx, ll N, vector<vector<ll>> &arr) {
if (s.size() == (size_t)N) {
// cout << s.c_str() << endl;
arr.push_back(s);
} else {
for (ll c = s.size() > 0 ? 0 : 0; c <= mx; c++) {
s.push_back(c);
dfs(s, mx, N, arr);
s.pop_back();
}
}
return;
}
int bfs(int sx, int sy, int gx, int gy, int h, int w,
vector<vector<char>> map) {
queue<pair<int, int>> s;
vector<vector<ll>> ans;
for (int i = 0; i < h; i++) {
vector<ll> aa(w);
ans.push_back(aa);
}
s.push(make_pair(sx, sy));
while (s.size() > 0) {
pair<int, int> tmp = s.front();
s.pop();
map[tmp.first][tmp.second] = '#';
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
if (tmp.first + i < 0 || tmp.first + i >= h) {
continue;
}
if (tmp.second + j < 0 || tmp.second + j >= w) {
continue;
}
if (i != 0 && j != 0) {
continue;
}
if (i == 0 && j == 0) {
continue;
}
if (map[tmp.first + i][tmp.second + j] == '#') {
continue;
}
map[tmp.first + i][tmp.second + j] = '#';
if (ans[tmp.first + i][tmp.second + j] == 0) {
ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
} else {
ans[tmp.first + i][tmp.second + j] =
min(ans[tmp.first + i][tmp.second + j],
ans[tmp.first][tmp.second] + 1);
}
s.push(make_pair(tmp.first + i, tmp.second + j));
}
}
}
return ans[gy][gx];
}
ll modfactorial(ll a) {
if (a == 1)
return 1;
return (a % MOD) * (modfactorial(a - 1) % MOD);
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
/* dijkstra(G,s,dis)
入力:グラフ G, 開始点 s, 距離を格納する dis
計算量:O(|E|log|V|)
副作用:dis が書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<ll> &dis, vector<ll> &prev) {
int N = G.size();
dis.resize(N, INF);
prev.resize(N, -1); // 初期化
priority_queue<P, vector<P>, greater<P>> pq;
dis[s] = 0;
pq.emplace(dis[s], s);
while (!pq.empty()) {
P p = pq.top();
pq.pop();
int v = p.second;
if (dis[v] < p.first) {
continue;
}
for (auto &e : G[v]) {
if (dis[e.to] > dis[v] + e.cost) {
dis[e.to] = dis[v] + e.cost;
prev[e.to] = v; // 頂点 v を通って e.to にたどり着いた
pq.emplace(dis[e.to], e.to);
}
}
}
}
vector<ll> get_path(const vector<ll> &prev, ll t) {
vector<ll> path;
for (ll cur = t; cur != -1; cur = prev[cur]) {
path.push_back(cur);
}
reverse(path.begin(), path.end()); // 逆順なのでひっくり返す
return path;
}
vector<string> split(string &s, char delim) {
vector<string> elems;
stringstream ss(s);
string item;
while (getline(ss, item, delim)) {
if (!item.empty()) {
elems.push_back(item);
}
}
return elems;
}
vector<ll> divisor(ll n) {
vector<ll> ret;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
int main() {
ll n, m;
cin >> n >> m;
vector<pair<ll, ll>> v;
vector<ll> p(m);
vector<ll> cnt(n + 1, 0);
vector<pair<ll, ll>> ans(m);
for (int i = 0; i < m; i++) {
ll a, b;
cin >> p[i] >> b;
v.push_back(make_pair(b, i));
}
sort(v.begin(), v.end());
for (int i = 0; i < m; i++) {
ll tmp = ++cnt[p[v[i].second]];
ans[v[i].second] = make_pair(p[v[i].second], tmp);
}
for (int i = 0; i < m; i++) {
if (ans[i].first < 100000) {
std::cout << std::setfill('0') << std::right << std::setw(6)
<< ans[i].first;
} else {
cout << ans[i].first;
}
if (ans[i].second < 100000) {
std::cout << std::setfill('0') << std::right << std::setw(6)
<< ans[i].second << endl;
} else {
cout << ans[i].second << endl;
}
}
return 0;
}
// cout << std::fixed << std::setprecision(15) | replace | 228 | 229 | 228 | 229 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
const int M = 1000;
int n, m, p[M], y[M];
vector<int> num[M];
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
num[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; i++)
sort(num[i].begin(), num[i].end());
for (int i = 0; i < m; i++) {
printf("%06d", p[i]);
auto tmp = lower_bound(num[p[i] - 1].begin(), num[p[i] - 1].end(), y[i]) -
num[p[i] - 1].begin() + 1;
printf("%06d\n", tmp);
}
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
const int M = 100000;
int n, m, p[M], y[M];
vector<int> num[M];
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
num[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; i++)
sort(num[i].begin(), num[i].end());
for (int i = 0; i < m; i++) {
printf("%06d", p[i]);
auto tmp = lower_bound(num[p[i] - 1].begin(), num[p[i] - 1].end(), y[i]) -
num[p[i] - 1].begin() + 1;
printf("%06d\n", tmp);
}
} | replace | 10 | 11 | 10 | 11 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
auto ys = vector<pair<int, pair<int, int>>>(m);
auto ps = vector<int>(n);
for (int i = 0; i < m; ++i) {
int p, y;
cin >> p >> y;
ys[i] = make_pair(y, make_pair(i, p));
ps[i] = p;
}
sort(ys.begin(), ys.end());
auto xs = vector<int>(n, 0);
auto rs = vector<int>(m, 0);
for (int i = 0; i < m; ++i) {
++xs[ys[i].second.second - 1];
rs[ys[i].second.first] = xs[ys[i].second.second - 1];
}
for (int i = 0; i < m; ++i) {
printf("%06d%06d\n", ps[i], rs[i]);
}
return 0;
}
| #include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
auto ys = vector<pair<int, pair<int, int>>>(m);
auto ps = vector<int>(m);
for (int i = 0; i < m; ++i) {
int p, y;
cin >> p >> y;
ys[i] = make_pair(y, make_pair(i, p));
ps[i] = p;
}
sort(ys.begin(), ys.end());
auto xs = vector<int>(n, 0);
auto rs = vector<int>(m, 0);
for (int i = 0; i < m; ++i) {
++xs[ys[i].second.second - 1];
rs[ys[i].second.first] = xs[ys[i].second.second - 1];
}
for (int i = 0; i < m; ++i) {
printf("%06d%06d\n", ps[i], rs[i]);
}
return 0;
}
| replace | 11 | 12 | 11 | 12 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int vector_finder(std::vector<ll> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
int main() {
ll N, M;
cin >> N >> M;
vector<pair<ll, ll>> id(N + 1);
vector<vector<ll>> tmp(N + 1);
REP(i, M) {
ll p, y;
cin >> p >> y;
id[i] = make_pair(p, y);
}
REP(i, M) { tmp[id[i].first].push_back(id[i].second); }
REP(i, N + 1) { sort(all(tmp[i])); }
for (ll i = 0; i < M; ++i) {
int ans = lower_bound(all(tmp[id[i].first]), id[i].second) -
tmp[id[i].first].begin();
cout << setw(6) << setfill('0') << id[i].first << setw(6) << setfill('0')
<< (ans + 1) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int vector_finder(std::vector<ll> vec, int number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
int main() {
ll N, M;
cin >> N >> M;
vector<pair<ll, ll>> id(M);
vector<vector<ll>> tmp(N + 1);
REP(i, M) {
ll p, y;
cin >> p >> y;
id[i] = make_pair(p, y);
}
REP(i, M) { tmp[id[i].first].push_back(id[i].second); }
REP(i, N + 1) { sort(all(tmp[i])); }
for (ll i = 0; i < M; ++i) {
int ans = lower_bound(all(tmp[id[i].first]), id[i].second) -
tmp[id[i].first].begin();
cout << setw(6) << setfill('0') << id[i].first << setw(6) << setfill('0')
<< (ans + 1) << endl;
}
} | replace | 34 | 35 | 34 | 35 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD (long long)1e9 + 7
#define LINF (long long)4e18
void dfs() {}
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
rep(i, M) cin >> P[i] >> Y[i];
vector<vector<int>> PY(N + 100);
rep(i, M) { PY[P[i]].push_back(Y[i]); }
for (auto i : P) {
sort(PY[i].begin(), PY[i].end());
}
rep(i, M) {
printf("%012lld\n",
(long long)(P[i]) * 1000000 +
lower_bound(PY[P[i]].begin(), PY[P[i]].end(), Y[i]) -
PY[P[i]].begin() + 1);
}
}
| #include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD (long long)1e9 + 7
#define LINF (long long)4e18
void dfs() {}
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
rep(i, M) cin >> P[i] >> Y[i];
vector<vector<int>> PY(N + 100);
rep(i, M) { PY[P[i]].push_back(Y[i]); }
repr(i, 1, N + 1) { sort(PY[i].begin(), PY[i].end()); }
rep(i, M) {
printf("%012lld\n",
(long long)(P[i]) * 1000000 +
lower_bound(PY[P[i]].begin(), PY[P[i]].end(), Y[i]) -
PY[P[i]].begin() + 1);
}
}
| replace | 27 | 30 | 27 | 28 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))
const int INF = 2000000000;
int n, m;
int main() {
cin >> n >> m;
vector<vector<int>> v(n);
int ans_1[100000];
int year[100000];
rep(i, m) {
cin >> ans_1[i];
int tmp;
cin >> year[i];
v[ans_1[i] - 1].push_back(year[i]);
}
rep(i, n) sort(all(v[i]));
;
rep(i, m) {
printf("%06d", ans_1[i]);
const int result =
distance(v[ans_1[i] - 1].begin(), find(all(v[ans_1[i] - 1]), year[i]));
printf("%06d\n", result + 1);
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))
const int INF = 2000000000;
int n, m;
int main() {
cin >> n >> m;
vector<vector<int>> v(n);
int ans_1[100000];
int year[100000];
rep(i, m) {
cin >> ans_1[i];
int tmp;
cin >> year[i];
v[ans_1[i] - 1].push_back(year[i]);
}
rep(i, n) sort(all(v[i]));
;
rep(i, m) {
printf("%06d", ans_1[i]);
int itr = distance(v[ans_1[i] - 1].begin(),
lower_bound(all(v[ans_1[i] - 1]), year[i]));
printf("%06d\n", itr + 1);
}
}
| replace | 25 | 28 | 25 | 28 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int length(int n) {
int i = 1;
while (n != 0) {
n = n / 10;
++i;
}
return i;
}
int main() {
int n, m, i, j, k = 1;
cin >> n >> m;
vector<int> p(m), y(m), ans1(n, 1), ans2(n, 0);
map<int, pair<int, int>> mp;
for (i = 0; i < m; ++i) {
cin >> p[i] >> y[i];
mp[y[i]] = make_pair(p[i], i);
}
for (auto q : mp) {
ans2[q.second.second] = ans1[q.second.first - 1];
++ans1[q.second.first - 1];
++i;
}
for (i = 0; i < m; ++i) {
for (j = 0; j <= 6 - length(p[i]); ++j) {
cout << 0;
}
cout << p[i];
for (j = 0; j <= 6 - length(ans2[i]); ++j) {
cout << 0;
}
cout << ans2[i];
cout << "\n";
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int length(int n) {
int i = 1;
while (n != 0) {
n = n / 10;
++i;
}
return i;
}
int main() {
int n, m, i, j, k = 1;
cin >> n >> m;
vector<int> p(m), y(m), ans1(n, 1), ans2(m, 0);
map<int, pair<int, int>> mp;
for (i = 0; i < m; ++i) {
cin >> p[i] >> y[i];
mp[y[i]] = make_pair(p[i], i);
}
for (auto q : mp) {
ans2[q.second.second] = ans1[q.second.first - 1];
++ans1[q.second.first - 1];
++i;
}
for (i = 0; i < m; ++i) {
for (j = 0; j <= 6 - length(p[i]); ++j) {
cout << 0;
}
cout << p[i];
for (j = 0; j <= 6 - length(ans2[i]); ++j) {
cout << 0;
}
cout << ans2[i];
cout << "\n";
}
return 0;
} | replace | 15 | 16 | 15 | 16 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
int p[m], y[m];
vector<int> yd[m];
REP(i, m) {
cin >> p[i] >> y[i];
yd[p[i]].push_back(y[i]);
}
REP(i, n) { SORT(yd[i + 1]); }
REP(i, m) {
cout << setfill('0') << setw(6) << p[i];
cout << setfill('0') << setw(6)
<< lower_bound(ALL(yd[p[i]]), y[i]) - yd[p[i]].begin() + 1 << endl;
}
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
int p[100000], y[100000];
vector<int> yd[100001];
REP(i, m) {
cin >> p[i] >> y[i];
yd[p[i]].push_back(y[i]);
}
REP(i, n) { SORT(yd[i + 1]); }
REP(i, m) {
cout << setfill('0') << setw(6) << p[i];
cout << setfill('0') << setw(6)
<< lower_bound(ALL(yd[p[i]]), y[i]) - yd[p[i]].begin() + 1 << endl;
}
return 0;
} | replace | 19 | 21 | 19 | 21 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const long long INF = 1LL << 60;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
int main() {
int n, m;
cin >> n >> m;
vector<vector<pii>> a(n, vector<pii>());
rep(i, m) {
int p, y;
cin >> p >> y;
a[p].push_back(mp(y, i));
}
vector<pii> b(m);
rep(i, n) {
sort(all(a[i]));
rep(j, a[i].size()) {
int y, num;
tie(y, num) = a[i][j];
b[num] = mp(i, j);
}
}
rep(i, m) {
int p, yy;
tie(p, yy) = b[i];
printf("%06d%06d\n", p + 1, yy + 1);
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const long long INF = 1LL << 60;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
int main() {
int n, m;
cin >> n >> m;
vector<vector<pii>> a(n, vector<pii>());
rep(i, m) {
int p, y;
cin >> p >> y;
p--;
a[p].push_back(mp(y, i));
}
vector<pii> b(m);
rep(i, n) {
sort(all(a[i]));
rep(j, a[i].size()) {
int y, num;
tie(y, num) = a[i][j];
b[num] = mp(i, j);
}
}
rep(i, m) {
int p, yy;
tie(p, yy) = b[i];
printf("%06d%06d\n", p + 1, yy + 1);
}
return 0;
}
| insert | 37 | 37 | 37 | 38 | -11 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int mxsz = 1e5;
int n, m;
map<pii, int> mp;
vi pi[mxsz];
pii req[mxsz];
int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> req[i].fi >> req[i].se;
pi[req[i].fi].pb(req[i].se);
}
for (int i = 1; i <= n; i++) {
if (!pi[i].empty()) {
sort(pi[i].begin(), pi[i].end());
for (int j = 1; j <= pi[i].size(); j++) {
pii tmp = {i, pi[i][j - 1]};
mp[tmp] = j;
}
}
}
for (int i = 1; i <= m; i++) {
pii tmp = {req[i].fi, req[i].se};
printf("%06d%06d\n", req[i].fi, mp[tmp]);
}
return 0;
}
| #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int mxsz = 1e5 + 5;
int n, m;
map<pii, int> mp;
vi pi[mxsz];
pii req[mxsz];
int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> req[i].fi >> req[i].se;
pi[req[i].fi].pb(req[i].se);
}
for (int i = 1; i <= n; i++) {
if (!pi[i].empty()) {
sort(pi[i].begin(), pi[i].end());
for (int j = 1; j <= pi[i].size(); j++) {
pii tmp = {i, pi[i][j - 1]};
mp[tmp] = j;
}
}
}
for (int i = 1; i <= m; i++) {
pii tmp = {req[i].fi, req[i].se};
printf("%06d%06d\n", req[i].fi, mp[tmp]);
}
return 0;
}
| replace | 9 | 10 | 9 | 10 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> A;
#define int long long
int N, M;
pair<int, int> K[100001];
signed main() {
cin >> N >> M;
vector<A> vec[100001];
for (int i = 0; i < M; i++) {
int P, Y;
cin >> P >> Y;
vec[P].push_back(A(Y, i));
}
for (int i = 1; i <= N; i++) {
sort(vec[i].begin(), vec[i].end());
K[vec[i][i].second].first = vec[i][i].first;
K[vec[i][i].second].second = vec[i][i].second;
}
for (int i = 0; i < M; i++) {
printf("%06d"
"%06d\n",
K[i].first, K[i].second);
}
} | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> A;
#define int long long
int N, M;
pair<int, int> K[100001];
signed main() {
cin >> N >> M;
vector<A> vec[100001];
for (int i = 0; i < M; i++) {
int P, Y;
cin >> P >> Y;
vec[P].push_back(A(Y, i));
}
for (int i = 1; i <= N; i++) {
sort(vec[i].begin(), vec[i].end());
for (int j = 0; j < vec[i].size(); j++) {
K[vec[i][j].second].first = i;
K[vec[i][j].second].second = j + 1;
}
}
for (int i = 0; i < M; i++) {
printf("%06d"
"%06d\n",
K[i].first, K[i].second);
}
} | replace | 16 | 18 | 16 | 20 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
ll p[m], y[m];
vector<ll> py[m];
for (int i = 0; i < m; i++)
cin >> p[i] >> y[i];
for (int i = 0; i < m; i++)
py[p[i]].push_back(y[i]);
for (int i = 0; i < n; i++)
sort(py[i + 1].begin(), py[i + 1].end());
for (int i = 0; i < m; i++) {
printf("%012lld\n",
ll(p[i]) * 1000000 +
int(lower_bound(py[p[i]].begin(), py[p[i]].end(), y[i]) -
py[p[i]].begin()) +
1);
}
/* for(int i=0;i<m;i++){
printf("%lld\n",*lower_bound(py[p[i]].begin(),py[p[i]].end(),y[i]));
}*/
// for(int i=0;i<m;i++)num[y[i]]=i;
// sort(y,y+m);
/*for( vector<ll>::iterator i=begin(py);i!=end(py);++i) {
std::cout << i << std::endl;
}*/
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
ll p[m], y[m];
vector<ll> py[100001];
for (int i = 0; i < m; i++)
cin >> p[i] >> y[i];
for (int i = 0; i < m; i++)
py[p[i]].push_back(y[i]);
for (int i = 0; i < n; i++)
sort(py[i + 1].begin(), py[i + 1].end());
for (int i = 0; i < m; i++) {
printf("%012lld\n",
ll(p[i]) * 1000000 +
int(lower_bound(py[p[i]].begin(), py[p[i]].end(), y[i]) -
py[p[i]].begin()) +
1);
}
/* for(int i=0;i<m;i++){
printf("%lld\n",*lower_bound(py[p[i]].begin(),py[p[i]].end(),y[i]));
}*/
// for(int i=0;i<m;i++)num[y[i]]=i;
// sort(y,y+m);
/*for( vector<ll>::iterator i=begin(py);i!=end(py);++i) {
std::cout << i << std::endl;
}*/
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<map<int, int>> py(m + 1);
vector<vector<int>> numm(m + 1, vector<int>(2));
int tmp1, tmp2;
for (int i = 1; i <= m; i++) {
cin >> tmp1 >> tmp2;
py[tmp1][tmp2] = 0;
numm[i][0] = tmp1;
numm[i][1] = tmp2;
}
for (int i = 1; i <= n; i++) {
int counter = 1;
for (auto itr = py[i].begin(); itr != py[i].end(); itr++) {
itr->second = counter;
counter++;
}
}
for (int i = 1; i <= m; i++) {
cout << std::setfill('0') << std::right << std::setw(6) << numm[i][0]
<< std::setfill('0') << std::right << std::setw(6)
<< py[numm[i][0]][numm[i][1]] << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<map<int, int>> py(n + 1);
vector<vector<int>> numm(m + 1, vector<int>(2));
int tmp1, tmp2;
for (int i = 1; i <= m; i++) {
cin >> tmp1 >> tmp2;
py[tmp1][tmp2] = 0;
numm[i][0] = tmp1;
numm[i][1] = tmp2;
}
for (int i = 1; i <= n; i++) {
int counter = 1;
for (auto itr = py[i].begin(); itr != py[i].end(); itr++) {
itr->second = counter;
counter++;
}
}
for (int i = 1; i <= m; i++) {
cout << std::setfill('0') << std::right << std::setw(6) << numm[i][0]
<< std::setfill('0') << std::right << std::setw(6)
<< py[numm[i][0]][numm[i][1]] << endl;
}
return 0;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define range(i, s, n) for (int i = s; i < n; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9 + 7)
#define PI 3.1415926535897932384
template <class T> ostream &operator<<(std::ostream &o, const vector<T> &v) {
rep(i, v.size()) { o << (i > 0 ? " " : "") << v[i]; }
return o;
}
int main() {
int n, m;
cin >> n >> m;
vi place(m), year(m);
vvi perp(n + 1, vi());
rep(i, m) {
cin >> place[i] >> year[i];
perp[place[i]].push_back(year[i]);
}
rep(i, n + 1) {
if (!perp[i].empty()) {
sort(all(perp[i]));
}
}
rep(i, m) {
cout << setfill('0') << setw(6) << right << place[i];
rep(j, perp[place[i]].size()) {
if (perp[place[i]][j] == year[i]) {
cout << setfill('0') << setw(6) << right << j + 1 << endl;
}
}
}
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define range(i, s, n) for (int i = s; i < n; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9 + 7)
#define PI 3.1415926535897932384
template <class T> ostream &operator<<(std::ostream &o, const vector<T> &v) {
rep(i, v.size()) { o << (i > 0 ? " " : "") << v[i]; }
return o;
}
int main() {
int n, m;
cin >> n >> m;
vi place(m), year(m);
vvi perp(n + 1, vi());
rep(i, m) {
cin >> place[i] >> year[i];
perp[place[i]].push_back(year[i]);
}
rep(i, n + 1) {
if (!perp[i].empty()) {
sort(all(perp[i]));
}
}
rep(i, m) {
cout << setfill('0') << setw(6) << right << place[i];
auto itr = lower_bound(all(perp[place[i]]), year[i]);
cout << setfill('0') << setw(6) << right << itr - perp[place[i]].begin() + 1
<< endl;
}
}
| replace | 46 | 51 | 46 | 49 | TLE | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int n, m;
int ph1[11000];
int ph2[11000];
int pm[11000];
struct xxx {
int x;
int y;
int id;
} a[1001001];
bool cmp(xxx a, xxx b) {
if (a.x == b.x)
return a.y < b.y;
else
return a.x < b.x;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++)
cin >> a[i].x >> a[i].y, a[i].id = i;
sort(a + 1, a + 1 + m, cmp);
for (int i = 1; i <= m; i++) {
pm[a[i].x]++;
ph1[a[i].id] = a[i].x;
ph2[a[i].id] = pm[a[i].x];
}
for (int i = 1; i <= m; i++) {
int x, pr = 6;
x = ph1[i];
while (x) {
pr--;
x /= 10;
}
while (pr--)
printf("0");
printf("%d", ph1[i]);
x = ph2[i];
pr = 6;
while (x) {
pr--;
x /= 10;
}
while (pr--)
printf("0");
printf("%d\n", ph2[i]);
}
return 0;
} | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int n, m;
int ph1[110000];
int ph2[110000];
int pm[110000];
struct xxx {
int x;
int y;
int id;
} a[1001001];
bool cmp(xxx a, xxx b) {
if (a.x == b.x)
return a.y < b.y;
else
return a.x < b.x;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++)
cin >> a[i].x >> a[i].y, a[i].id = i;
sort(a + 1, a + 1 + m, cmp);
for (int i = 1; i <= m; i++) {
pm[a[i].x]++;
ph1[a[i].id] = a[i].x;
ph2[a[i].id] = pm[a[i].x];
}
for (int i = 1; i <= m; i++) {
int x, pr = 6;
x = ph1[i];
while (x) {
pr--;
x /= 10;
}
while (pr--)
printf("0");
printf("%d", ph1[i]);
x = ph2[i];
pr = 6;
while (x) {
pr--;
x /= 10;
}
while (pr--)
printf("0");
printf("%d\n", ph2[i]);
}
return 0;
} | replace | 7 | 10 | 7 | 10 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip> // std::setw(int), std::setfill(char)
#include <ios> // std::left, std::right
using namespace std;
typedef long long ll;
struct city {
int num;
int p;
int y;
};
int main() {
int n, m;
cin >> n >> m;
vector<city> c(m);
for (int i = 0; i < m; i++) {
c[i].num = i;
cin >> c[i].p >> c[i].y;
}
sort(c.begin(), c.end(),
[](auto const &lhs, auto const &rhs) { return lhs.y < rhs.y; });
/*
for(auto ci:c){
cout << "#" << ci.num << " " << ci.p << " " << ci.y << endl;
}
*/
vector<int> prefs(m + 1, 0);
for (auto &ci : c) {
prefs[ci.p]++;
ci.y = prefs[ci.p];
}
sort(c.begin(), c.end(),
[](auto const &lhs, auto const &rhs) { return lhs.num < rhs.num; });
for (auto ci : c) {
cout << setfill('0') << right << setw(6) << ci.p;
cout << setfill('0') << right << setw(6) << ci.y;
cout << endl;
}
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip> // std::setw(int), std::setfill(char)
#include <ios> // std::left, std::right
using namespace std;
typedef long long ll;
struct city {
int num;
int p;
int y;
};
int main() {
int n, m;
cin >> n >> m;
vector<city> c(m);
for (int i = 0; i < m; i++) {
c[i].num = i;
cin >> c[i].p >> c[i].y;
}
sort(c.begin(), c.end(),
[](auto const &lhs, auto const &rhs) { return lhs.y < rhs.y; });
/*
for(auto ci:c){
cout << "#" << ci.num << " " << ci.p << " " << ci.y << endl;
}
*/
vector<int> prefs(n + 1, 0);
for (auto &ci : c) {
prefs[ci.p]++;
ci.y = prefs[ci.p];
}
sort(c.begin(), c.end(),
[](auto const &lhs, auto const &rhs) { return lhs.num < rhs.num; });
for (auto ci : c) {
cout << setfill('0') << right << setw(6) << ci.p;
cout << setfill('0') << right << setw(6) << ci.y;
cout << endl;
}
return 0;
}
| replace | 41 | 42 | 41 | 42 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#pragma GCC optimize(3)
namespace ZDY {
#define res register
#define ri res int
#define ll long long
#define db double
#define sht short
#define il inline
#define MB template <class T>
#define Fur(i, x, y) for (ri i = x; i <= y; i++)
#define fur(i, x, y) for (i = x; i <= y; i++)
#define Fdr(i, x, y) for (ri i = x; i >= y; i--)
#define clr(x, y) memset(x, y, sizeof(x))
#define cpy(x, y) memcpy(x, y, sizeof(x))
#define fl(i, x) for (ri i = head[x], to; to = e[i].to, i; i = e[i].nxt)
#define inf 2122219134
#define fin(s) freopen(s ".in", "r", stdin)
#define fout(s) freopen(s ".out", "w", stdin)
#define l2(n) (ceil(log2(n)))
#define fast ios::sync_with_stdio(false)
MB il T ABS(T x) { return x > 0 ? x : -x; }
MB il T MAX(T x, T y) { return x > y ? x : y; }
MB il T MIN(T x, T y) { return x < y ? x : y; }
MB il T GCD(T x, T y) { return y ? GCD(y, x % y) : x; }
} // namespace ZDY
using namespace ZDY;
using namespace std;
#define N 10010
int n, m, a1[N], a2[N];
struct city {
int id, y;
friend bool operator<(const city &a, const city &b) { return a.y < b.y; }
};
vector<city> a[N];
int main() {
cin >> n >> m;
int p, y;
Fur(i, 1, m) {
scanf("%d%d", &p, &y);
a[p].push_back((city){i, y});
}
Fur(i, 1, n) if (!a[i].empty()) {
sort(a[i].begin(), a[i].end());
Fur(j, 0, a[i].size() - 1) a1[a[i][j].id] = i, a2[a[i][j].id] = j + 1;
}
Fur(i, 1, m) printf("%06d%06d\n", a1[i], a2[i]);
}
| #include <bits/stdc++.h>
#pragma GCC optimize(3)
namespace ZDY {
#define res register
#define ri res int
#define ll long long
#define db double
#define sht short
#define il inline
#define MB template <class T>
#define Fur(i, x, y) for (ri i = x; i <= y; i++)
#define fur(i, x, y) for (i = x; i <= y; i++)
#define Fdr(i, x, y) for (ri i = x; i >= y; i--)
#define clr(x, y) memset(x, y, sizeof(x))
#define cpy(x, y) memcpy(x, y, sizeof(x))
#define fl(i, x) for (ri i = head[x], to; to = e[i].to, i; i = e[i].nxt)
#define inf 2122219134
#define fin(s) freopen(s ".in", "r", stdin)
#define fout(s) freopen(s ".out", "w", stdin)
#define l2(n) (ceil(log2(n)))
#define fast ios::sync_with_stdio(false)
MB il T ABS(T x) { return x > 0 ? x : -x; }
MB il T MAX(T x, T y) { return x > y ? x : y; }
MB il T MIN(T x, T y) { return x < y ? x : y; }
MB il T GCD(T x, T y) { return y ? GCD(y, x % y) : x; }
} // namespace ZDY
using namespace ZDY;
using namespace std;
#define N 100010
int n, m, a1[N], a2[N];
struct city {
int id, y;
friend bool operator<(const city &a, const city &b) { return a.y < b.y; }
};
vector<city> a[N];
int main() {
cin >> n >> m;
int p, y;
Fur(i, 1, m) {
scanf("%d%d", &p, &y);
a[p].push_back((city){i, y});
}
Fur(i, 1, n) if (!a[i].empty()) {
sort(a[i].begin(), a[i].end());
Fur(j, 0, a[i].size() - 1) a1[a[i][j].id] = i, a2[a[i][j].id] = j + 1;
}
Fur(i, 1, m) printf("%06d%06d\n", a1[i], a2[i]);
}
| replace | 28 | 29 | 28 | 29 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define REP(i, limit) for (int i = 0; i < limit; ++i)
#define LINT long long
int main() {
int N, M;
cin >> N >> M;
pair<int, int> p[M], pp[M];
int look[1000000001];
REP(i, M) {
cin >> p[i].first >> p[i].second;
pp[i].first = p[i].first;
pp[i].second = p[i].second;
look[p[i].second] = i;
}
int bangou[M];
sort(pp, pp + M);
int work = 1;
bangou[look[pp[0].second]] = 1;
REP(i, M - 1) {
if (pp[i + 1].first == pp[i].first) {
++work;
bangou[look[pp[i + 1].second]] = work;
} else {
work = 1;
bangou[look[pp[i + 1].second]] = work;
}
}
int w;
REP(i, M) {
w = look[p[i].second];
printf("%06d%06d\n", p[w].first, bangou[i]);
}
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define REP(i, limit) for (int i = 0; i < limit; ++i)
#define LINT long long
int main() {
int N, M;
cin >> N >> M;
pair<int, int> p[M], pp[M];
map<int, int> look;
REP(i, M) {
cin >> p[i].first >> p[i].second;
pp[i].first = p[i].first;
pp[i].second = p[i].second;
look[p[i].second] = i;
}
int bangou[M];
sort(pp, pp + M);
int work = 1;
bangou[look[pp[0].second]] = 1;
REP(i, M - 1) {
if (pp[i + 1].first == pp[i].first) {
++work;
bangou[look[pp[i + 1].second]] = work;
} else {
work = 1;
bangou[look[pp[i + 1].second]] = work;
}
}
int w;
REP(i, M) {
w = look[p[i].second];
printf("%06d%06d\n", p[w].first, bangou[i]);
}
return 0;
}
| replace | 14 | 15 | 14 | 15 | -11 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
struct pr {
int p, y;
};
int main() {
cin.tie(0), ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<int>> a(m + 1);
vector<pr> b(m);
for (int i = 0; i < m; ++i) {
int p, y;
cin >> p >> y;
a.at(p).emplace_back(y);
b.at(i).p = p, b.at(i).y = y;
}
for (auto &&i : a)
sort(i.begin(), i.end());
unordered_map<int, int> mp;
for (int i = 1; i < a.size(); ++i) {
for (int j = 0; j < a.at(i).size(); ++j) {
mp[a.at(i).at(j)] = j + 1;
}
}
for (auto &&i : b)
cout << setfill('0') << setw(6) << i.p << setfill('0') << setw(6)
<< mp.at(i.y) << "\n"s;
} | #include <bits/stdc++.h>
using namespace std;
struct pr {
int p, y;
};
int main() {
cin.tie(0), ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<int>> a(n + 1);
vector<pr> b(m);
for (int i = 0; i < m; ++i) {
int p, y;
cin >> p >> y;
a.at(p).emplace_back(y);
b.at(i).p = p, b.at(i).y = y;
}
for (auto &&i : a)
sort(i.begin(), i.end());
unordered_map<int, int> mp;
for (int i = 1; i < a.size(); ++i) {
for (int j = 0; j < a.at(i).size(); ++j) {
mp[a.at(i).at(j)] = j + 1;
}
}
for (auto &&i : b)
cout << setfill('0') << setw(6) << i.p << setfill('0') << setw(6)
<< mp.at(i.y) << "\n"s;
} | replace | 10 | 11 | 10 | 11 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(N), Y(N), ord[100010];
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
ord[P[i]].push_back(Y[i]);
}
for (int i = 1; i <= N; i++)
sort(ord[i].begin(), ord[i].end());
for (int i = 0; i < M; i++) {
printf("%06d", P[i]);
int d = lower_bound(ord[P[i]].begin(), ord[P[i]].end(), Y[i]) -
ord[P[i]].begin() + 1;
printf("%06d\n", d);
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M), ord[100010];
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
ord[P[i]].push_back(Y[i]);
}
for (int i = 1; i <= N; i++)
sort(ord[i].begin(), ord[i].end());
for (int i = 0; i < M; i++) {
printf("%06d", P[i]);
int d = lower_bound(ord[P[i]].begin(), ord[P[i]].end(), Y[i]) -
ord[P[i]].begin() + 1;
printf("%06d\n", d);
}
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef vector<V> VV;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF ((ll)1 << 63 - 1)
#define INF (1 << 29)
#define MINF -2000000007
#define MAX 100050
const int MOD = 1e9 + 7;
// テンプレ終了
//====================================================================//
//
int main() {
int N, M;
cin >> N >> M;
vector<tuple<int, int, int>> city(M);
REP(i, M) {
cin >> get<0>(city[i]) >> get<1>(city[i]);
get<2>(city[i]) = 1;
}
REP(i, N) {
V order(M);
iota(ALL(order), 0);
sort(ALL(order), [&](int x, int y) { return city[x] < city[y]; });
int cnt = 1;
get<2>(city[order[0]]) = cnt++;
REPS(j, 1, M) {
if (get<0>(city[order[j - 1]]) != get<0>(city[order[j]]))
cnt = 1;
get<2>(city[order[j]]) = cnt++;
}
}
REP(i, M) printf("%06d%06d\n", get<0>(city[i]), get<2>(city[i]));
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef vector<V> VV;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF ((ll)1 << 63 - 1)
#define INF (1 << 29)
#define MINF -2000000007
#define MAX 100050
const int MOD = 1e9 + 7;
// テンプレ終了
//====================================================================//
//
int main() {
int N, M;
cin >> N >> M;
vector<tuple<int, int, int>> city(M);
REP(i, M) {
cin >> get<0>(city[i]) >> get<1>(city[i]);
get<2>(city[i]) = 1;
}
V order(M);
iota(ALL(order), 0);
sort(ALL(order), [&](int x, int y) { return city[x] < city[y]; });
int cnt = 1;
get<2>(city[order[0]]) = cnt++;
REPS(j, 1, M) {
if (get<0>(city[order[j - 1]]) != get<0>(city[order[j]]))
cnt = 1;
get<2>(city[order[j]]) = cnt++;
}
REP(i, M) printf("%06d%06d\n", get<0>(city[i]), get<2>(city[i]));
return 0;
}
| replace | 38 | 49 | 38 | 47 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
#define REP(i, a, b) for (int i = int(a); i < int(b); ++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
map<pair<int, int>, int> rank;
vector<vector<int>> city(N + 1);
rep(i, M) {
int p, y;
cin >> p >> y;
P.at(i) = p;
Y.at(i) = y;
city.at(p).push_back(y);
}
rep(i, M) { sort(city.at(i).begin(), city.at(i).end()); }
rep(i, N + 1) {
int r = 1;
for (int j : city.at(i)) {
rank[mp(i, j)] = r;
r++;
}
}
rep(i, M) { printf("%06d%06d\n", P.at(i), rank[mp(P.at(i), Y.at(i))]); }
}
| #include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
#define REP(i, a, b) for (int i = int(a); i < int(b); ++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
map<pair<int, int>, int> rank;
vector<vector<int>> city(N + 1);
rep(i, M) {
int p, y;
cin >> p >> y;
P.at(i) = p;
Y.at(i) = y;
city.at(p).push_back(y);
}
rep(i, N + 1) { sort(city.at(i).begin(), city.at(i).end()); }
rep(i, N + 1) {
int r = 1;
for (int j : city.at(i)) {
rank[mp(i, j)] = r;
r++;
}
}
rep(i, M) { printf("%06d%06d\n", P.at(i), rank[mp(P.at(i), Y.at(i))]); }
}
| replace | 25 | 26 | 25 | 26 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int i = (s); i < (e); i++)
#define FOR64(i, s, e) for (ll i = (s); i < (e); i++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(b, e) sort((b), (e))
#define REV(b, e) reverse((b), (e))
#define VSORT(v) sort((v).begin(), (v).end())
#define VREV(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 999999999
typedef long long ll;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M + 1);
vector<int> Y(M + 1);
map<int, vector<int>> m;
FOR(i, 1, M + 1) {
cin >> P[i] >> Y[i];
m[P[i]].pb(Y[i]);
}
for (auto &e : m) {
VSORT(e.second);
}
FOR(i, 1, M + 1) {
auto it = find(ALL(m[P[i]]), Y[i]);
printf("%06d%06d\n", P[i], it - m[P[i]].begin() + 1);
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int i = (s); i < (e); i++)
#define FOR64(i, s, e) for (ll i = (s); i < (e); i++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(b, e) sort((b), (e))
#define REV(b, e) reverse((b), (e))
#define VSORT(v) sort((v).begin(), (v).end())
#define VREV(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 999999999
typedef long long ll;
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M + 1);
vector<int> Y(M + 1);
map<int, vector<int>> m;
FOR(i, 1, M + 1) {
cin >> P[i] >> Y[i];
m[P[i]].pb(Y[i]);
}
for (auto &e : m) {
VSORT(e.second);
}
FOR(i, 1, M + 1) {
auto &e = m[P[i]];
auto it = lower_bound(ALL(e), Y[i]);
printf("%06d%06d\n", P[i], it - e.begin() + 1);
}
return 0;
}
| replace | 34 | 36 | 34 | 37 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
int main() {
int n, m;
cin >> n >> m;
vector<P> p, y;
rep(i, m) {
int a, b;
cin >> a >> b;
p.push_back(make_pair(i, a));
y.push_back(make_pair(b, i));
}
sort(y.begin(), y.end());
map<int, int> mp;
vector<int> ans(n, 0);
rep(i, m) {
int k = y[i].second;
mp[p[k].second]++;
ans[k] = mp[p[k].second];
}
rep(i, m) {
cout << zero_pad(6) << p[i].second;
cout << zero_pad(6) << ans[i] << endl;
}
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
int main() {
int n, m;
cin >> n >> m;
vector<P> p, y;
rep(i, m) {
int a, b;
cin >> a >> b;
p.push_back(make_pair(i, a));
y.push_back(make_pair(b, i));
}
sort(y.begin(), y.end());
map<int, int> mp;
vector<int> ans(m, 0);
rep(i, m) {
int k = y[i].second;
mp[p[k].second]++;
ans[k] = mp[p[k].second];
}
rep(i, m) {
cout << zero_pad(6) << p[i].second;
cout << zero_pad(6) << ans[i] << endl;
}
} | replace | 20 | 21 | 20 | 21 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <limits.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rip(i, n) (int i = 0; i < (int)(n); i++)
int main() {
int n, m;
scanf("%d%d", &n, &m);
vector<pair<int, pair<int, int>>> da(m);
vector<int> p(m), y(m);
for
rip(i, m) {
scanf("%d%d", da[i].first, da[i].second.first);
da[i].second.second = i;
}
sort(da.begin(), da.end());
vector<pair<int, int>> ans(m);
int co = 1;
ans[da[0].second.second] = make_pair(da[0].first, 1);
for (int i = 1; i < m; i++) {
if (da[i].first == da[i - 1].first) {
co++;
} else {
co = 1;
}
ans[da[i].second.second] = make_pair(da[i].first, co);
}
for
rip(i, m) { printf("%06d%06d\n", ans[i].first, ans[i].second); }
} | #include <algorithm>
#include <iostream>
#include <limits.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rip(i, n) (int i = 0; i < (int)(n); i++)
int main() {
int n, m;
scanf("%d%d", &n, &m);
vector<pair<int, pair<int, int>>> da(m);
vector<int> p(m), y(m);
for
rip(i, m) {
scanf("%d%d", &da[i].first, &da[i].second.first);
da[i].second.second = i;
}
sort(da.begin(), da.end());
vector<pair<int, int>> ans(m);
int co = 1;
ans[da[0].second.second] = make_pair(da[0].first, 1);
for (int i = 1; i < m; i++) {
if (da[i].first == da[i - 1].first) {
co++;
} else {
co = 1;
}
ans[da[i].second.second] = make_pair(da[i].first, co);
}
for
rip(i, m) { printf("%06d%06d\n", ans[i].first, ans[i].second); }
} | replace | 17 | 18 | 17 | 18 | -11 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return
// true; } return false; } template<class T> inline bool chmin(T& a, T b) { if
// (a > b) { a = b; return true; } return false; }
/* attention
long longのシフト演算には気をつけよう
タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/
int main(void) {
int N, M;
cin >> N >> M;
vector<int> p(M), y(M);
vector<int> rank[M + 1];
for (int i = 0; i < M; i++) {
cin >> p[i] >> y[i];
rank[p[i]].push_back(y[i]);
}
for (int i = 1; i <= N; i++)
sort(rank[i].begin(), rank[i].end());
for (int i = 0; i < M; i++) {
auto itr = lower_bound(rank[p[i]].begin(), rank[p[i]].end(), y[i]);
int r = itr - rank[p[i]].begin() + 1;
printf("%06d%06d\n", p[i], r);
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return
// true; } return false; } template<class T> inline bool chmin(T& a, T b) { if
// (a > b) { a = b; return true; } return false; }
/* attention
long longのシフト演算には気をつけよう
タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/
int main(void) {
int N, M;
cin >> N >> M;
vector<int> p(M), y(M);
vector<int> rank[N + 1];
for (int i = 0; i < M; i++) {
cin >> p[i] >> y[i];
rank[p[i]].push_back(y[i]);
}
for (int i = 1; i <= N; i++)
sort(rank[i].begin(), rank[i].end());
for (int i = 0; i < M; i++) {
auto itr = lower_bound(rank[p[i]].begin(), rank[p[i]].end(), y[i]);
int r = itr - rank[p[i]].begin() + 1;
printf("%06d%06d\n", p[i], r);
}
} | replace | 16 | 17 | 16 | 17 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void) {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<int> V[100001];
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
V[P[i]].push_back(Y[i]);
}
for (int i = 1; i <= N; i++)
sort(V[i].begin(), V[i].end());
for (int i = 0; i < M; i++) {
int rank =
distance(V[P[i]].begin(), find(V[P[i]].begin(), V[P[i]].end(), Y[i])) +
1;
printf("%06d%06d\n", P[i], rank);
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void) {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<int> V[100001];
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
V[P[i]].push_back(Y[i]);
}
for (int i = 1; i <= N; i++)
sort(V[i].begin(), V[i].end());
for (int i = 0; i < M; i++) {
auto it1 = lower_bound(V[P[i]].begin(), V[P[i]].end(), Y[i]);
int rank = it1 - V[P[i]].begin() + 1;
printf("%06d%06d\n", P[i], rank);
}
} | replace | 19 | 22 | 19 | 21 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(m);
vector<int> y(m);
map<int, vector<int>> city;
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
city[p[i]].push_back(y[i]);
}
for (auto &e : city) {
sort(e.second.begin(), e.second.end());
}
for (int i = 0; i < m; i++) {
char num[13] = {};
auto val = find(city[p[i]].begin(), city[p[i]].end(), y[i]);
sprintf(num, "%06d%06d", p[i], distance(city[p[i]].begin(), val) + 1);
cout << num << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(m);
vector<int> y(m);
map<int, vector<int>> city;
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
city[p[i]].push_back(y[i]);
}
for (auto &e : city) {
sort(e.second.begin(), e.second.end());
}
for (int i = 0; i < m; i++) {
char num[13] = {};
// auto val = find(city[p[i]].begin(), city[p[i]].end(), y[i]);
auto val = lower_bound(city[p[i]].begin(), city[p[i]].end(), y[i]);
sprintf(num, "%06d%06d", p[i], distance(city[p[i]].begin(), val) + 1);
cout << num << endl;
}
return 0;
}
| replace | 22 | 23 | 22 | 24 | TLE | |
p03221 | C++ | Time Limit Exceeded | #pragma region header
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define vvvs vector<vector<vector<string>>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define vvvd vector<vector<vector<ld>>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vvvb vector<vector<vector<bool>>>
#define pii pair<int, int>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define vvvp vector<vector<vector<pair<int, int>>>>
#define mii map<int, int>
#define vm vector<map<int, int>>
#define vvm vector<map<pair<int, int>>>
#define vvvm vector<vector<vector<map<int, int>>>>
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1)(__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
#define split_pair(f, s, p) \
auto f = p.first; \
auto s = p.second
using namespace std;
const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod(int a) { return (a % MOD + MOD) % MOD; }
int m_add(int a, int b) { return (a + b) % MOD; }
int m_add(int a, int b, int c) { return (a + b + c) % MOD; }
int m_sub(int a, int b) { return (a + MOD - b) % MOD; }
int m_mul(int a, int b) { return a * b % MOD; }
int m_mul(int a, int b, int c) { return a * b % MOD * c % MOD; }
int m_bipow(int x, int y) {
if (y == 0)
return 1;
else if (y == 1)
return x % MOD;
else if (y % 2 == 0) {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z);
} else {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z, x);
}
}
int m_inv(int x) { return m_bipow(x, MOD - 2); }
int m_div(int a, int b) { return m_mul(a, m_inv(b)); }
template <class T> void SORT(T &a) { stable_sort(all(a)); }
template <class T> void RSORT(T &a) { stable_sort(rall(a)); }
template <class T> void rev(T &a) { reverse(rall(a)); }
template <class T> void uniq(T &a) { a.erase(unique(all(a)), end(a)); }
template <class T> auto min_of(T a) { return *min_element(all(a)); }
template <class T> auto max_of(T a) { return *max_element(all(a)); }
template <class T> int sum_of(T a) { return accumulate(all(a), 0ll); }
template <class T, class U> auto sum_of(T a, U init) {
return accumulate(all(a), init);
}
template <class T, class U> int count_of(T a, U i) { return count(all(a), i); }
template <class T> T cum(T v) {
T u(sz(v));
partial_sum(all(v), begin(u));
return u;
}
template <class T, class U> int lower_index(T a, U i) {
return lower_bound(all(a), i) - begin(a);
} // use member func for set
template <class T, class U> int upper_index(T a, U i) {
return upper_bound(all(a), i) - begin(a);
}
template <class T, class U> bool binary(T a, U i) {
return binary_search(all(a), i);
}
template <class T, class U> bool exists(T a, U i) {
return find(all(a), i) != end(a);
}
template <class T> int sz(T a) { return a.size(); };
template <class T> void COUT(T x) { cout << x << endl; }
template <class T> bool amin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool amax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> vector<pair<T, int>> indexed_vector(vector<T> v) {
int n = sz(v);
vector<pair<T, int>> w(n);
for (int i = 0; i < n; i++)
w[i] = make_pair(v[i], i);
return w;
}
template <class T, class S> vector<pair<T, S>> zip(vector<T> v, vector<S> w) {
int n = min(sz(v), sz(w));
vector<pair<T, S>> x(n);
for (int i = 0; i < n; i++)
x[i] = make_pair(v[i], w[i]);
return x;
}
template <class T, class S>
pair<vector<T>, vector<S>> unzip(vector<pair<T, S>> v) {
int n = sz(v);
auto w = make_pair(vector<T>(n), vector<S>(n));
for (int i = 0; i < n; i++) {
w.first[i] = v[i].first;
w.second[i] = v[i].second;
}
return w;
}
vs split(const string &s, string d) {
vs elms;
size_t offset = 0, d_size = d.size();
while (true) {
size_t next = s.find_first_of(d, offset);
if (next == string::npos) {
elms.push_back(s.substr(offset));
return elms;
}
elms.push_back(s.substr(offset, next - offset));
offset = next + d_size;
}
}
vs split(const string &s, char d) { return split(s, string(1, d)); }
string join(const vs &v, const string d = "") {
string s;
if (!v.empty()) {
s += v[0];
for (size_t i = 1, c = v.size(); i < c; ++i) {
if (!d.empty())
s += d;
s += v[i];
}
}
return s;
}
string join(const vs &v, const char d) { return join(v, string(1, d)); }
vi divisors(int n) {
vi ret;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
SORT(ret);
return ret;
}
mii prime_factors(int n) {
mii ret;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n]++;
return ret;
}
int ceil_div(int x, int y) { return (x - 1) / y + 1; }
struct union_find {
vi data;
union_find(int size) : data(size, -1) {}
bool union_set(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find_set(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
// struct combination {
// vi fact, ifact;
// combination(int n): fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
// fact[0] = 1;
// for (int i = 1; i <= n; ++i) fact[i] = m_mul(fact[i - 1], i);
// ifact[n] = m_inv(fact[n]);
// for (int i = n; i >= 1; --i) ifact[i-1] = m_mul(ifact[i], i);
// }
// int operator()(int n, int k) {
// if (k < 0 || k > n) return 0;
// return m_mul(fact[n], ifact[k], ifact[n - k]);
// }
// } comb(200001);
#pragma endregion header
// MOD = 1e9 + 7;
string pad_left(string s, int width, char filler = '0') {
int n = sz(s);
if (n > width)
return s.substr(n - width);
return string(width - n, filler) + s;
}
void solve(int n, int m, vi p, vi y) {
unordered_map<int, vp> pc;
rep(i, m) { pc[p[i]].push_back(mp(y[i], i)); }
vs ans(m);
each(x, pc) {
vp v = x.second;
SORT(v);
rep(i, sz(v)) {
ans[v[i].second] =
pad_left(to_string(x.first), 6) + pad_left(to_string(i + 1), 6);
}
}
each(i, ans) COUT(i);
}
#pragma region main
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << fixed << setprecision(15);
int n;
cin >> n;
int m;
cin >> m;
vi p(m);
vi y(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
cin >> y[i];
}
solve(n, m, move(p), move(y));
}
#pragma endregion main
| #pragma region header
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define vvvs vector<vector<vector<string>>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define vvvd vector<vector<vector<ld>>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vvvb vector<vector<vector<bool>>>
#define pii pair<int, int>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define vvvp vector<vector<vector<pair<int, int>>>>
#define mii map<int, int>
#define vm vector<map<int, int>>
#define vvm vector<map<pair<int, int>>>
#define vvvm vector<vector<vector<map<int, int>>>>
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1)(__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
#define split_pair(f, s, p) \
auto f = p.first; \
auto s = p.second
using namespace std;
const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod(int a) { return (a % MOD + MOD) % MOD; }
int m_add(int a, int b) { return (a + b) % MOD; }
int m_add(int a, int b, int c) { return (a + b + c) % MOD; }
int m_sub(int a, int b) { return (a + MOD - b) % MOD; }
int m_mul(int a, int b) { return a * b % MOD; }
int m_mul(int a, int b, int c) { return a * b % MOD * c % MOD; }
int m_bipow(int x, int y) {
if (y == 0)
return 1;
else if (y == 1)
return x % MOD;
else if (y % 2 == 0) {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z);
} else {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z, x);
}
}
int m_inv(int x) { return m_bipow(x, MOD - 2); }
int m_div(int a, int b) { return m_mul(a, m_inv(b)); }
template <class T> void SORT(T &a) { stable_sort(all(a)); }
template <class T> void RSORT(T &a) { stable_sort(rall(a)); }
template <class T> void rev(T &a) { reverse(rall(a)); }
template <class T> void uniq(T &a) { a.erase(unique(all(a)), end(a)); }
template <class T> auto min_of(T a) { return *min_element(all(a)); }
template <class T> auto max_of(T a) { return *max_element(all(a)); }
template <class T> int sum_of(T a) { return accumulate(all(a), 0ll); }
template <class T, class U> auto sum_of(T a, U init) {
return accumulate(all(a), init);
}
template <class T, class U> int count_of(T a, U i) { return count(all(a), i); }
template <class T> T cum(T v) {
T u(sz(v));
partial_sum(all(v), begin(u));
return u;
}
template <class T, class U> int lower_index(T a, U i) {
return lower_bound(all(a), i) - begin(a);
} // use member func for set
template <class T, class U> int upper_index(T a, U i) {
return upper_bound(all(a), i) - begin(a);
}
template <class T, class U> bool binary(T a, U i) {
return binary_search(all(a), i);
}
template <class T, class U> bool exists(T a, U i) {
return find(all(a), i) != end(a);
}
template <class T> int sz(T a) { return a.size(); };
template <class T> void COUT(T x) { cout << x << endl; }
template <class T> bool amin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool amax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> vector<pair<T, int>> indexed_vector(vector<T> v) {
int n = sz(v);
vector<pair<T, int>> w(n);
for (int i = 0; i < n; i++)
w[i] = make_pair(v[i], i);
return w;
}
template <class T, class S> vector<pair<T, S>> zip(vector<T> v, vector<S> w) {
int n = min(sz(v), sz(w));
vector<pair<T, S>> x(n);
for (int i = 0; i < n; i++)
x[i] = make_pair(v[i], w[i]);
return x;
}
template <class T, class S>
pair<vector<T>, vector<S>> unzip(vector<pair<T, S>> v) {
int n = sz(v);
auto w = make_pair(vector<T>(n), vector<S>(n));
for (int i = 0; i < n; i++) {
w.first[i] = v[i].first;
w.second[i] = v[i].second;
}
return w;
}
vs split(const string &s, string d) {
vs elms;
size_t offset = 0, d_size = d.size();
while (true) {
size_t next = s.find_first_of(d, offset);
if (next == string::npos) {
elms.push_back(s.substr(offset));
return elms;
}
elms.push_back(s.substr(offset, next - offset));
offset = next + d_size;
}
}
vs split(const string &s, char d) { return split(s, string(1, d)); }
string join(const vs &v, const string d = "") {
string s;
if (!v.empty()) {
s += v[0];
for (size_t i = 1, c = v.size(); i < c; ++i) {
if (!d.empty())
s += d;
s += v[i];
}
}
return s;
}
string join(const vs &v, const char d) { return join(v, string(1, d)); }
vi divisors(int n) {
vi ret;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
SORT(ret);
return ret;
}
mii prime_factors(int n) {
mii ret;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n]++;
return ret;
}
int ceil_div(int x, int y) { return (x - 1) / y + 1; }
struct union_find {
vi data;
union_find(int size) : data(size, -1) {}
bool union_set(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find_set(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
// struct combination {
// vi fact, ifact;
// combination(int n): fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
// fact[0] = 1;
// for (int i = 1; i <= n; ++i) fact[i] = m_mul(fact[i - 1], i);
// ifact[n] = m_inv(fact[n]);
// for (int i = n; i >= 1; --i) ifact[i-1] = m_mul(ifact[i], i);
// }
// int operator()(int n, int k) {
// if (k < 0 || k > n) return 0;
// return m_mul(fact[n], ifact[k], ifact[n - k]);
// }
// } comb(200001);
#pragma endregion header
// MOD = 1e9 + 7;
string pad_left(string s, int width, char filler = '0') {
int n = sz(s);
if (n > width)
return s.substr(n - width);
return string(width - n, filler) + s;
}
void solve(int n, int m, vi p, vi y) {
mii pm;
vp yi = indexed_vector(y);
SORT(yi);
vi id(m);
each(x, yi) {
int index = x.second;
pm[p[index]]++;
id[index] = pm[p[index]];
}
rep(i, m) {
COUT(pad_left(to_string(p[i]), 6) + pad_left(to_string(id[i]), 6));
}
}
#pragma region main
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << fixed << setprecision(15);
int n;
cin >> n;
int m;
cin >> m;
vi p(m);
vi y(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
cin >> y[i];
}
solve(n, m, move(p), move(y));
}
#pragma endregion main
| replace | 241 | 253 | 241 | 253 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
int main() {
int N, M;
std::cin >> N >> M;
int P[M], Y[M];
std::vector<std::vector<int>> PY(N);
for (int i = 0; i < M; ++i) {
std::cin >> P[i] >> Y[i];
PY[P[i] - 1].push_back(Y[i]);
}
for (int i = 0; i < N; ++i)
std::sort(PY[i].begin(), PY[i].end());
for (int i = 0; i < M; ++i) {
for (int j = 0; j < PY[P[i] - 1].size(); ++j) {
if (Y[i] == PY[P[i] - 1][j]) {
std::cout << std::setfill('0') << std::right << std::setw(6) << P[i];
std::cout << std::setfill('0') << std::right << std::setw(6) << j + 1;
std::cout << std::endl;
break;
}
}
}
return 0;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
int main() {
int N, M;
std::cin >> N >> M;
int P[M], Y[M];
std::vector<std::vector<int>> PY(N);
for (int i = 0; i < M; ++i) {
std::cin >> P[i] >> Y[i];
PY[P[i] - 1].push_back(Y[i]);
}
for (int i = 0; i < N; ++i)
std::sort(PY[i].begin(), PY[i].end());
for (int i = 0; i < M; ++i) {
int index =
std::lower_bound(PY[P[i] - 1].begin(), PY[P[i] - 1].end(), Y[i]) -
PY[P[i] - 1].begin();
std::cout << std::setfill('0') << std::right << std::setw(6) << P[i];
std::cout << std::setfill('0') << std::right << std::setw(6) << index + 1;
std::cout << std::endl;
}
return 0;
}
| replace | 18 | 26 | 18 | 24 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <unordered_map>
#include <vector>
int main() {
std::array<std::vector<uint64_t>, 100001> prefYears;
std::array<int, 100000> p;
std::array<uint64_t, 100000> y;
int n, m;
std::scanf("%d %d", &n, &m);
for (std::size_t i = 0; i < m; ++i) {
std::scanf("%d %lu", &(p[i]), &(y[i]));
prefYears[p[i]].push_back(y[i]);
}
for (std::size_t i = 0; i < m; ++i) {
std::sort(prefYears[p[i]].begin(), prefYears[p[i]].end());
}
for (std::size_t i = 0; i < m; ++i) {
const std::vector<uint64_t> &years = prefYears[p[i]];
std::vector<uint64_t>::const_iterator it =
std::lower_bound(years.begin(), years.end(), y[i]);
std::fprintf(stdout, "%06d%06lu\n", p[i],
(std::size_t)((it - years.begin())) + 1);
}
return 0;
} | #include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <unordered_map>
#include <vector>
int main() {
std::array<std::vector<uint64_t>, 100001> prefYears;
std::array<int, 100000> p;
std::array<uint64_t, 100000> y;
int n, m;
std::scanf("%d %d", &n, &m);
for (std::size_t i = 0; i < m; ++i) {
std::scanf("%d %lu", &(p[i]), &(y[i]));
prefYears[p[i]].push_back(y[i]);
}
for (std::size_t i = 1; i <= n; ++i) {
std::sort(prefYears[i].begin(), prefYears[i].end());
}
for (std::size_t i = 0; i < m; ++i) {
const std::vector<uint64_t> &years = prefYears[p[i]];
std::vector<uint64_t>::const_iterator it =
std::lower_bound(years.begin(), years.end(), y[i]);
std::fprintf(stdout, "%06d%06lu\n", p[i],
(std::size_t)((it - years.begin())) + 1);
}
return 0;
} | replace | 22 | 24 | 22 | 24 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <array>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// 変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
// for簡易表記(引数ミス防止)
#define FOR(LoopVariable, numberOFbegin, numberOFend) \
for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); \
(LoopVariable)++)
#define DEFOR(LoopVariable, numberOFbegin, numberOFend) \
for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); \
(LoopVariable)--)
#define REP(LoopVariable, numberOFend) \
for (int LoopVariable = 0; (LoopVariable) < (numberOFend); LoopVariable++)
int main() {
int n, m;
scanf("%d %d\n", &n, &m);
array<int, 100001> ids, idt;
vector<int> grid[100001];
REP(i, m) {
scanf("%d %d\n", &ids[i], &idt[i]);
grid[ids[i]].push_back(idt[i]);
}
REP(i, n) { sort(grid[i + 1].begin(), grid[i + 1].end()); }
REP(i, m) {
printf("%06d%06ld\n", ids[i],
distance(grid[ids[i]].begin(),
find(grid[ids[i]].begin(), grid[ids[i]].end(), idt[i])) +
1);
}
return 0;
} | #include <algorithm>
#include <array>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// 変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
// for簡易表記(引数ミス防止)
#define FOR(LoopVariable, numberOFbegin, numberOFend) \
for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); \
(LoopVariable)++)
#define DEFOR(LoopVariable, numberOFbegin, numberOFend) \
for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); \
(LoopVariable)--)
#define REP(LoopVariable, numberOFend) \
for (int LoopVariable = 0; (LoopVariable) < (numberOFend); LoopVariable++)
int main() {
int n, m;
scanf("%d %d\n", &n, &m);
array<int, 100001> ids, idt;
vector<int> grid[100001];
REP(i, m) {
scanf("%d %d\n", &ids[i], &idt[i]);
grid[ids[i]].push_back(idt[i]);
}
REP(i, n) { sort(grid[i + 1].begin(), grid[i + 1].end()); }
REP(i, m) {
printf("%06d%06d\n", ids[i],
(int)(lower_bound(grid[ids[i]].begin(), grid[ids[i]].end(), idt[i]) -
grid[ids[i]].begin()) +
1);
}
return 0;
} | replace | 42 | 45 | 42 | 45 | TLE | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> P(n + 1);
vector<int> Y(n + 1);
vector<vector<int>> YS(n + 1);
for (int i = 0; i < m; i++) {
cin >> P[i] >> Y[i];
YS[P[i]].push_back(Y[i]);
}
for (int i = 0; i <= n; i++) {
if (!YS[i].empty()) {
sort(YS[i].begin(), YS[i].end());
}
}
for (int i = 0; i < m; i++) {
int ord = lower_bound(YS[P[i]].begin(), YS[P[i]].end(), Y[i]) -
YS[P[i]].begin() + 1;
cout << setfill('0') << right << setw(6) << P[i];
cout << setfill('0') << right << setw(6) << ord << endl;
}
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> P(m);
vector<int> Y(m);
vector<vector<int>> YS(n + 1);
for (int i = 0; i < m; i++) {
cin >> P[i] >> Y[i];
YS[P[i]].push_back(Y[i]);
}
for (int i = 0; i <= n; i++) {
if (!YS[i].empty()) {
sort(YS[i].begin(), YS[i].end());
}
}
for (int i = 0; i < m; i++) {
int ord = lower_bound(YS[P[i]].begin(), YS[P[i]].end(), Y[i]) -
YS[P[i]].begin() + 1;
cout << setfill('0') << right << setw(6) << P[i];
cout << setfill('0') << right << setw(6) << ord << endl;
}
return 0;
}
| replace | 9 | 11 | 9 | 11 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
int P[100000], Y[100000];
vector<int> v[100001];
rep(i, m) {
cin >> P[i] >> Y[i];
v[P[i]].push_back(Y[i]);
}
rep(i, n) sort(v[i + 1].begin(), v[i + 1].end());
rep(i, m) {
printf("%06d", P[i]);
int r = 0;
for (int j = 0; j < v[P[i]].size(); j++) {
r++;
if (v[P[i]][j] >= Y[i]) {
break;
}
}
printf("%06d", r);
cout << endl;
}
return 0;
} | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
int P[100000], Y[100000];
vector<int> v[100001];
rep(i, m) {
cin >> P[i] >> Y[i];
v[P[i]].push_back(Y[i]);
}
rep(i, n) sort(v[i + 1].begin(), v[i + 1].end());
rep(i, m) {
printf("%06d", P[i]);
// int r=0;
/*for(int j=0;j<v[P[i]].size();j++){
r++;
if(v[P[i]][j]>=Y[i]){
break;
}
}*/
int r =
lower_bound(v[P[i]].begin(), v[P[i]].end(), Y[i]) - v[P[i]].begin() + 1;
printf("%06d", r);
cout << endl;
}
return 0;
} | replace | 28 | 35 | 28 | 37 | TLE | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
#define put(n) cout << (n) << endl
#define rep(i, N) for (int(i) = 0; (i) < (N); ++(i))
#define rrep(i, N) for (int(i) = (N - 1); (i) >= (0); --(i))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
int main() {
int N, M;
cin >> N >> M;
vector<vector<P>> city(N + 1);
vector<int> ans1(N), ans2(N);
rep(i, M) {
int a, b;
cin >> a >> b;
city[a].push_back({b, i});
}
rep(i, N + 1) {
if (city[i].size() < 1)
continue;
sort(all(city[i]));
}
rep(i, N + 1) {
rep(j, city[i].size()) {
P c = city[i][j];
ans1[c.second] = i;
ans2[c.second] = j + 1;
}
}
rep(i, M) {
cout << setfill('0') << right << setw(6) << ans1[i];
cout << setfill('0') << right << setw(6) << ans2[i] << endl;
}
} | #include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
#define put(n) cout << (n) << endl
#define rep(i, N) for (int(i) = 0; (i) < (N); ++(i))
#define rrep(i, N) for (int(i) = (N - 1); (i) >= (0); --(i))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
int main() {
int N, M;
cin >> N >> M;
vector<vector<P>> city(N + 1);
vector<int> ans1(M), ans2(M);
rep(i, M) {
int a, b;
cin >> a >> b;
city[a].push_back({b, i});
}
rep(i, N + 1) {
if (city[i].size() < 1)
continue;
sort(all(city[i]));
}
rep(i, N + 1) {
rep(j, city[i].size()) {
P c = city[i][j];
ans1[c.second] = i;
ans2[c.second] = j + 1;
}
}
rep(i, M) {
cout << setfill('0') << right << setw(6) << ans1[i];
cout << setfill('0') << right << setw(6) << ans2[i] << endl;
}
} | replace | 21 | 22 | 21 | 22 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep(i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
#include "../../Lib/cout_container.hpp"
#define debug(x) cout << #x " => " << (x) << endl
#else
#define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace {
struct INIT {
INIT() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
} INIT;
} // namespace
int main(void) {
int n, m;
cin >> n >> m;
vector<pair<int, int>> py(m);
rep(i, m) cin >> py[i].first >> py[i].second;
vector<vector<int>> ken(n + 1);
rep(i, m) ken[py[i].first].push_back(py[i].second);
rep(i, m) sort(all(ken[i]));
vector<string> ans(m);
rep(i, m) {
int rank = lower_bound(all(ken[py[i].first]), py[i].second) -
ken[py[i].first].begin() + 1;
stringstream ss;
ss << setfill('0') << right << setw(6) << py[i].first;
ss << setfill('0') << right << setw(6) << rank;
ss >> ans[i];
}
rep(i, m) cout << ans[i] << "\n";
return 0;
} | #include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep(i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
#include "../../Lib/cout_container.hpp"
#define debug(x) cout << #x " => " << (x) << endl
#else
#define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace {
struct INIT {
INIT() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
} INIT;
} // namespace
int main(void) {
int n, m;
cin >> n >> m;
vector<pair<int, int>> py(m);
rep(i, m) cin >> py[i].first >> py[i].second;
vector<vector<int>> ken(n + 1);
rep(i, m) ken[py[i].first].push_back(py[i].second);
rep1(i, n) sort(all(ken[i]));
vector<string> ans(m);
rep(i, m) {
int rank = lower_bound(all(ken[py[i].first]), py[i].second) -
ken[py[i].first].begin() + 1;
stringstream ss;
ss << setfill('0') << right << setw(6) << py[i].first;
ss << setfill('0') << right << setw(6) << rank;
ss >> ans[i];
}
rep(i, m) cout << ans[i] << "\n";
return 0;
} | replace | 39 | 40 | 39 | 40 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const ll INF = 1LL << 60;
int main() {
ll n, m;
cin >> n >> m;
vector<tuple<ll, ll, ll>> data(m);
rep(i, n) {
ll p;
ll y;
cin >> p;
cin >> y;
data[i] = make_tuple(y, p, i);
}
sort(data.begin(), data.end());
vector<ll> cnt(n + 1);
vector<pair<ll, ll>> id(m);
for (ll i = 0; i < m; ++i) {
ll y, p, idx;
tie(y, p, idx) = data[i];
++cnt[p];
id[idx] = make_pair(p, cnt[p]);
}
for (ll i = 0; i < m; ++i) {
cout << setw(6) << setfill('0') << id[i].first;
cout << setw(6) << setfill('0') << id[i].second << endl;
}
} | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const ll INF = 1LL << 60;
int main() {
ll n, m;
cin >> n >> m;
vector<tuple<ll, ll, ll>> data(m);
rep(i, m) {
ll p;
ll y;
cin >> p;
cin >> y;
data[i] = make_tuple(y, p, i);
}
sort(data.begin(), data.end());
vector<ll> cnt(n + 1);
vector<pair<ll, ll>> id(m);
for (ll i = 0; i < m; ++i) {
ll y, p, idx;
tie(y, p, idx) = data[i];
++cnt[p];
id[idx] = make_pair(p, cnt[p]);
}
for (ll i = 0; i < m; ++i) {
cout << setw(6) << setfill('0') << id[i].first;
cout << setw(6) << setfill('0') << id[i].second << endl;
}
} | replace | 36 | 37 | 36 | 37 | 0 | |
p03221 | C++ | Runtime Error | /* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
でないと厳しい
*/
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;
typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
} // Greatest Common Divisor ユークリッドの互除法(aが長辺)
vector<pair<ll, int>> factorize(ll n) { // a,bの公約数 = GCD(a, b)の約数
vector<pair<ll, int>> res;
for (ll i = 2; i * i <= n; i++) { // √nまで探せばよい
if (n % i)
continue;
res.emplace_back(i, 0); // 割り切れたら
while (n % i == 0) {
n /= i;
res.back().second++;
}
}
if (n != 1)
res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
return res;
}
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
} // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) { return (a + b - 1) / b; }
const ll INF = LONG_MAX;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
// https://qiita.com/drken/items/4a7869c5e304883f539b#3-3-dfs-%E3%81%AE%E5%86%8D%E5%B8%B0%E9%96%A2%E6%95%B0%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E5%AE%9F%E8%A3%85
/*
using Graph = vector<vector<int>>;
vector<bool> seen;
// 初期化方法 seen.assign(N, false); // 全頂点を「未訪問」に初期化
void dfs(const Graph &g, int v) {
seen[v] = true;
for(auto next_v : g[v]) {
if(seen[next_v])
continue;
dfs(g, next_v);
}
}
*/
// ***
// 01 - BSF
// ***
// ex.
// Edge edge[9];
// vector<int> dist(9);
// addEdge(true, edge, 0, 1, 0);
// addEdge(true, edge, 0, 7, 1);
// ...
// int src = 0; // source node
// zeroOneBFS(edge, dist ,src);
// const int dx[] = {-1, 1, 0, 0};
// const int dy[] = {0, 0, -1, 1};
const int dx[] = {1, 0};
const int dy[] = {0, 1};
template <typename T> struct BIT {
private:
vector<T> array;
const int n;
public:
BIT(int _n) : array(_n + 1, 0), n(_n) {}
// 1番目からi番目までの累積和
T sum(int i) {
T s = 0;
while (i > 0) {
s += array[i];
i -= i & -i;
}
}
// [i, j]の要素の総和
T sum(int i, int j) {
T ret_i = sum(i - 1);
T ret_j = sum(j);
return ret_j - ret_i;
}
// i番目に要素xを追加
void add(int i, T x) {
while (i <= n) {
array[i] += x;
i += i & -i;
}
}
};
int main() {
#ifdef LOCAL
// 以降 cin の入力元が 'xxx.txt' になる
std::ifstream in("code.txt");
std::cin.rdbuf(in.rdbuf());
#endif
struct py_t {
int city;
int p;
int y;
py_t(int c, int p, int y) : city(c), p(p), y(y){};
bool operator<(const py_t &another) const { return y < another.y; }
};
int n, m;
cin >> n >> m;
vector<py_t> py;
rep(i, m) {
int p, y;
cin >> p >> y;
py.push_back(py_t(i, p, y));
}
sort(py.begin(), py.end());
vector<queue<int>> vq(n);
vector<int> name_upper(m), name_lower(m);
rep(i, m) {
vq[py[i].p].push(py[i].p);
name_upper[py[i].city] = py[i].p;
name_lower[py[i].city] = vq[py[i].p].size();
}
rep(i, m) {
cout << setfill('0') << setw(6) << name_upper[i];
cout << setfill('0') << setw(6) << name_lower[i] << endl;
}
return 0;
}
/*
- 最大値
long long 9,223,372,036,854,775,807 < 9.223.. * 10^18
- 1e9 : 10^9
- container一般
- 合計
accumulate(a.begin(), a.end(), 0LL) 0LLはオーバーフロー用.
数値は合計に履かせる下駄.
- vector
vector<int> A(N, 0); // 0で初期化(省略可)
vector<vector<int>> vec(n_rows, vector<int>(n_cols, value)); //
2次元配列初期化
- loop
for (int i = 0; i < A.size(); i++) {}
for (int elem : A) {}
- sort
std::sort(v.begin(), v.end()); // 昇順
std::sort(v.begin(), v.end(), std::greater<int>()); //降順
- vector<vector<int>> cnt(h, vector<int>(w))
- sort(struct)
struct st_t {
string name;
int p;
bool operator<(const st_t& another) const {
if (name == another.name)
{
return p > another.p;
}
return name < another.name;
}
};
vector<st_t> st(n);
sort(st.begin(), st.end());
- pair
- pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
- pair<pair<string,int>,int> p[110];
std::sort(p,p+a);
こうすると、first.first -> first.second ->
secondの順にソートされる
- sort
- sort(a.begin(), cb.end(), greater<pair<int, int>>());
- map
- for (auto x : map) {} // x.first:key x.second:value.
- priority_queue<int> q;
- q.top()に最大値が入っている
- string
- loop
for (char& c : s) {}
*/
/*
// エラトステネスのふるい
int MAX = 101010;
vector<int> is_prime(MAX, 1);
is_prime[0] = 0, is_prime[1] = 0;
for (int i = 2; i < MAX; ++i) {
if (!is_prime[i]) continue;
for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
}
*/
#if 0
struct node {
int to, weight;
};
using Edge = vector<node>;
void addEdge(bool directed, Edge *edges, int u, int v, int wt) {
edges[u].push_back({v, wt});
if(!directed) {
edges[v].push_back({u, wt});
}
}
int pre_node[100000];
void zeroOneBFS(Edge *edges, vector<int> &dist, int src) {
// Initialize distances from given source
for(int i = 0; i < dist.size(); i++)
dist[i] = INT_MAX;
// double ende queue to do BFS.
deque<int> Q;
dist[src] = 0;
Q.push_back(src);
while(!Q.empty()) {
int v = Q.front();
Q.pop_front();
for(int i = 0; i < edges[v].size(); i++) {
// checking for the optimal distance
if(dist[edges[v][i].to] > dist[v] + edges[v][i].weight) {
dist[edges[v][i].to] = dist[v] + edges[v][i].weight;
pre_node[edges[v][i].to] = v;
// Put 0 weight edges to front and 1 weight
// edges to back so that vertices are processed
// in increasing order of weights.
if(edges[v][i].weight == 0)
Q.push_front(edges[v][i].to);
else
Q.push_back(edges[v][i].to);
}
}
}
// printing the shortest distances
for(int i = 0; i < dist.size(); i++)
cout << dist[i] << " ";
}
#endif | /* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
でないと厳しい
*/
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;
typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
} // Greatest Common Divisor ユークリッドの互除法(aが長辺)
vector<pair<ll, int>> factorize(ll n) { // a,bの公約数 = GCD(a, b)の約数
vector<pair<ll, int>> res;
for (ll i = 2; i * i <= n; i++) { // √nまで探せばよい
if (n % i)
continue;
res.emplace_back(i, 0); // 割り切れたら
while (n % i == 0) {
n /= i;
res.back().second++;
}
}
if (n != 1)
res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
return res;
}
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
} // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) { return (a + b - 1) / b; }
const ll INF = LONG_MAX;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
// https://qiita.com/drken/items/4a7869c5e304883f539b#3-3-dfs-%E3%81%AE%E5%86%8D%E5%B8%B0%E9%96%A2%E6%95%B0%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E5%AE%9F%E8%A3%85
/*
using Graph = vector<vector<int>>;
vector<bool> seen;
// 初期化方法 seen.assign(N, false); // 全頂点を「未訪問」に初期化
void dfs(const Graph &g, int v) {
seen[v] = true;
for(auto next_v : g[v]) {
if(seen[next_v])
continue;
dfs(g, next_v);
}
}
*/
// ***
// 01 - BSF
// ***
// ex.
// Edge edge[9];
// vector<int> dist(9);
// addEdge(true, edge, 0, 1, 0);
// addEdge(true, edge, 0, 7, 1);
// ...
// int src = 0; // source node
// zeroOneBFS(edge, dist ,src);
// const int dx[] = {-1, 1, 0, 0};
// const int dy[] = {0, 0, -1, 1};
const int dx[] = {1, 0};
const int dy[] = {0, 1};
template <typename T> struct BIT {
private:
vector<T> array;
const int n;
public:
BIT(int _n) : array(_n + 1, 0), n(_n) {}
// 1番目からi番目までの累積和
T sum(int i) {
T s = 0;
while (i > 0) {
s += array[i];
i -= i & -i;
}
}
// [i, j]の要素の総和
T sum(int i, int j) {
T ret_i = sum(i - 1);
T ret_j = sum(j);
return ret_j - ret_i;
}
// i番目に要素xを追加
void add(int i, T x) {
while (i <= n) {
array[i] += x;
i += i & -i;
}
}
};
int main() {
#ifdef LOCAL
// 以降 cin の入力元が 'xxx.txt' になる
std::ifstream in("code.txt");
std::cin.rdbuf(in.rdbuf());
#endif
struct py_t {
int city;
int p;
int y;
py_t(int c, int p, int y) : city(c), p(p), y(y){};
bool operator<(const py_t &another) const { return y < another.y; }
};
int n, m;
cin >> n >> m;
vector<py_t> py;
rep(i, m) {
int p, y;
cin >> p >> y;
py.push_back(py_t(i, p, y));
}
sort(py.begin(), py.end());
vector<queue<int>> vq(100003);
vector<int> name_upper(m), name_lower(m);
rep(i, m) {
vq[py[i].p].push(py[i].p);
name_upper[py[i].city] = py[i].p;
name_lower[py[i].city] = vq[py[i].p].size();
}
rep(i, m) {
cout << setfill('0') << setw(6) << name_upper[i];
cout << setfill('0') << setw(6) << name_lower[i] << endl;
}
return 0;
}
/*
- 最大値
long long 9,223,372,036,854,775,807 < 9.223.. * 10^18
- 1e9 : 10^9
- container一般
- 合計
accumulate(a.begin(), a.end(), 0LL) 0LLはオーバーフロー用.
数値は合計に履かせる下駄.
- vector
vector<int> A(N, 0); // 0で初期化(省略可)
vector<vector<int>> vec(n_rows, vector<int>(n_cols, value)); //
2次元配列初期化
- loop
for (int i = 0; i < A.size(); i++) {}
for (int elem : A) {}
- sort
std::sort(v.begin(), v.end()); // 昇順
std::sort(v.begin(), v.end(), std::greater<int>()); //降順
- vector<vector<int>> cnt(h, vector<int>(w))
- sort(struct)
struct st_t {
string name;
int p;
bool operator<(const st_t& another) const {
if (name == another.name)
{
return p > another.p;
}
return name < another.name;
}
};
vector<st_t> st(n);
sort(st.begin(), st.end());
- pair
- pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
- pair<pair<string,int>,int> p[110];
std::sort(p,p+a);
こうすると、first.first -> first.second ->
secondの順にソートされる
- sort
- sort(a.begin(), cb.end(), greater<pair<int, int>>());
- map
- for (auto x : map) {} // x.first:key x.second:value.
- priority_queue<int> q;
- q.top()に最大値が入っている
- string
- loop
for (char& c : s) {}
*/
/*
// エラトステネスのふるい
int MAX = 101010;
vector<int> is_prime(MAX, 1);
is_prime[0] = 0, is_prime[1] = 0;
for (int i = 2; i < MAX; ++i) {
if (!is_prime[i]) continue;
for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
}
*/
#if 0
struct node {
int to, weight;
};
using Edge = vector<node>;
void addEdge(bool directed, Edge *edges, int u, int v, int wt) {
edges[u].push_back({v, wt});
if(!directed) {
edges[v].push_back({u, wt});
}
}
int pre_node[100000];
void zeroOneBFS(Edge *edges, vector<int> &dist, int src) {
// Initialize distances from given source
for(int i = 0; i < dist.size(); i++)
dist[i] = INT_MAX;
// double ende queue to do BFS.
deque<int> Q;
dist[src] = 0;
Q.push_back(src);
while(!Q.empty()) {
int v = Q.front();
Q.pop_front();
for(int i = 0; i < edges[v].size(); i++) {
// checking for the optimal distance
if(dist[edges[v][i].to] > dist[v] + edges[v][i].weight) {
dist[edges[v][i].to] = dist[v] + edges[v][i].weight;
pre_node[edges[v][i].to] = v;
// Put 0 weight edges to front and 1 weight
// edges to back so that vertices are processed
// in increasing order of weights.
if(edges[v][i].weight == 0)
Q.push_front(edges[v][i].to);
else
Q.push_back(edges[v][i].to);
}
}
}
// printing the shortest distances
for(int i = 0; i < dist.size(); i++)
cout << dist[i] << " ";
}
#endif | replace | 137 | 138 | 137 | 138 | -11 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
// typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for (int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for (auto i : mp)
#define FOR(i, m, n) for (int i = m; i < n; i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll N, M;
const int MAX_M = int(1e5);
ll P[MAX_M + 1], Y[MAX_M + 1];
vector<ll> nums[MAX_M + 1];
void solve() {
REP(i, M) {
auto at = find(nums[P[i]].begin(), nums[P[i]].end(), Y[i]);
string sp = to_string(P[i]), sdiff = to_string(at - nums[P[i]].begin() + 1);
if (sp.length() < 6)
sp = string(6 - sp.length(), '0') + sp;
if (sdiff.length() < 6)
sdiff = string(6 - sdiff.length(), '0') + sdiff;
string ans = sp + sdiff;
printf("%s\n", ans.c_str());
}
}
int main() {
cin >> N >> M;
REP(i, M) {
scanf("%lli %lli", &P[i], &Y[i]);
nums[P[i]].emplace_back(Y[i]);
}
REPONE(i, N) { sort(nums[i].begin(), nums[i].end()); }
solve();
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
// typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for (int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for (auto i : mp)
#define FOR(i, m, n) for (int i = m; i < n; i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll N, M;
const int MAX_M = int(1e5);
ll P[MAX_M + 1], Y[MAX_M + 1];
vector<ll> nums[MAX_M + 1];
void solve() {
REP(i, M) {
auto at = lower_bound(nums[P[i]].begin(), nums[P[i]].end(), Y[i]);
string sp = to_string(P[i]), sdiff = to_string(at - nums[P[i]].begin() + 1);
if (sp.length() < 6)
sp = string(6 - sp.length(), '0') + sp;
if (sdiff.length() < 6)
sdiff = string(6 - sdiff.length(), '0') + sdiff;
string ans = sp + sdiff;
printf("%s\n", ans.c_str());
}
}
int main() {
cin >> N >> M;
REP(i, M) {
scanf("%lli %lli", &P[i], &Y[i]);
nums[P[i]].emplace_back(Y[i]);
}
REPONE(i, N) { sort(nums[i].begin(), nums[i].end()); }
solve();
return 0;
} | replace | 28 | 29 | 28 | 29 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
long long MOD = 1e9 + 7;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(m), y(m);
vector<vector<int>> y_sort(n + 1);
rep(i, m) {
cin >> p[i] >> y[i];
y_sort[p[i]].push_back(y[i]);
}
rep(i, n) { sort(y_sort[p[i + 1]].begin(), y_sort[p[i + 1]].end()); }
for (int i = 0; i < m; i++) {
printf("%012lld\n", ll(p[i]) * 1000000 +
int(lower_bound(all(y_sort[p[i]]), y[i]) -
y_sort[p[i]].begin()) +
1);
}
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
long long MOD = 1e9 + 7;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(m), y(m);
vector<vector<int>> y_sort(n + 1);
rep(i, m) {
cin >> p[i] >> y[i];
y_sort[p[i]].push_back(y[i]);
}
rep(i, n) { sort(y_sort[i + 1].begin(), y_sort[i + 1].end()); }
for (int i = 0; i < m; i++) {
printf("%012lld\n", ll(p[i]) * 1000000 +
int(lower_bound(all(y_sort[p[i]]), y[i]) -
y_sort[p[i]].begin()) +
1);
}
return 0;
} | replace | 18 | 19 | 18 | 19 | 0 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> pa;
vector<vector<int>> c(n);
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--;
pa.push_back({a, b});
c[a].push_back(b);
}
for (int i = 0; i < c.size(); i++) {
sort(c[i].begin(), c[i].end());
}
for (int i = 0; i < m; i++) {
int x = pa[i].second;
int index = distance(c[i].begin(), find(c[i].begin(), c[i].end(), x));
cout << setw(6) << setfill('0') << pa[i].first + 1 << setw(6)
<< setfill('0') << index + 1 << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> pa;
vector<vector<int>> c(n);
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--;
pa.push_back({a, b});
c[a].push_back(b);
}
for (int i = 0; i < c.size(); i++) {
sort(c[i].begin(), c[i].end());
}
for (int i = 0; i < m; i++) {
int x = pa[i].second;
int index = distance(c[pa[i].first].begin(),
find(c[pa[i].first].begin(), c[pa[i].first].end(), x));
cout << setw(6) << setfill('0') << pa[i].first + 1 << setw(6)
<< setfill('0') << index + 1 << endl;
}
return 0;
} | replace | 22 | 23 | 22 | 24 | -11 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> pa;
vector<vector<pair<int, int>>> c(n);
for (int i = 0; i < m; i++) {
int p, y;
cin >> p >> y;
p--;
y--;
pa.emplace_back(p, y);
c[p].emplace_back(y, i);
}
for (int i = 0; i < m; i++) {
sort(c[i].begin(), c[i].end());
for (int j = 0; j < c[i].size(); j++) {
pa[c[i][j].second].second = j;
}
}
for (int i = 0; i < m; i++) {
cout << setw(6) << setfill('0') << pa[i].first + 1 << setw(6)
<< setfill('0') << pa[i].second + 1 << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> pa;
vector<vector<pair<int, int>>> c(n);
for (int i = 0; i < m; i++) {
int p, y;
cin >> p >> y;
p--;
y--;
pa.emplace_back(p, y);
c[p].emplace_back(y, i);
}
for (int i = 0; i < n; i++) {
sort(c[i].begin(), c[i].end());
for (int j = 0; j < c[i].size(); j++) {
pa[c[i][j].second].second = j;
}
}
for (int i = 0; i < m; i++) {
cout << setw(6) << setfill('0') << pa[i].first + 1 << setw(6)
<< setfill('0') << pa[i].second + 1 << endl;
}
return 0;
} | replace | 18 | 19 | 18 | 19 | -11 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, s, n) for (int i = (s); i < (n); i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define REPR(i, s, n) for (int i = (s); i >= (n); (i)--)
#define all(a) (a).begin(), (a).end()
#define reall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define pf push_front
#define MIN(a, b) a = min((a), (b))
#define MAX(a, b) a = max((a), (b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y) {
ll r;
while ((r = x % y) != 0) {
x = y;
y = r;
}
return y;
}
ll lcm(ll x, ll y) {
x /= gcd(x, y);
y /= gcd(x, y);
return (x * y);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, m;
cin >> n >> m;
vector<P> vec[10005];
vi p(m), y(m), a(m), b(m);
rep(i, m) {
cin >> p[i] >> y[i];
a[i] = p[i];
vec[p[i] - 1].pb(P(y[i], i));
}
rep(i, n) {
sort(all(vec[i]));
rep(j, vec[i].size()) { b[vec[i][j].second] = j; }
}
rep(i, m) { printf("%06d%06d\n", a[i], b[i] + 1); }
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, s, n) for (int i = (s); i < (n); i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define REPR(i, s, n) for (int i = (s); i >= (n); (i)--)
#define all(a) (a).begin(), (a).end()
#define reall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define pf push_front
#define MIN(a, b) a = min((a), (b))
#define MAX(a, b) a = max((a), (b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y) {
ll r;
while ((r = x % y) != 0) {
x = y;
y = r;
}
return y;
}
ll lcm(ll x, ll y) {
x /= gcd(x, y);
y /= gcd(x, y);
return (x * y);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, m;
cin >> n >> m;
vector<P> vec[100005];
vi p(m), y(m), a(m), b(m);
rep(i, m) {
cin >> p[i] >> y[i];
a[i] = p[i];
vec[p[i] - 1].pb(P(y[i], i));
}
rep(i, n) {
sort(all(vec[i]));
rep(j, vec[i].size()) { b[vec[i][j].second] = j; }
}
rep(i, m) { printf("%06d%06d\n", a[i], b[i] + 1); }
return 0;
}
| replace | 59 | 60 | 59 | 60 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
// freopen("input.txt", "r", stdin);
int n, m;
scanf("%d %d", &n, &m);
vector<int> p(m), y(m);
for (int i = 0; i < m; ++i) {
scanf("%d %d", &p[i], &y[i]);
}
vector<vector<int>> a(n, vector<int>(0));
for (int i = 0; i < m; ++i) {
a[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; ++i) {
sort(a[i].begin(), a[i].end());
}
for (int i = 0; i < m; ++i) {
printf("%06d", p[i]);
auto itr = find(a[p[i] - 1].begin(), a[p[i] - 1].end(), y[i]);
printf("%06d\n", distance(a[p[i] - 1].begin(), itr) + 1);
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
// freopen("input.txt", "r", stdin);
int n, m;
scanf("%d %d", &n, &m);
vector<int> p(m), y(m);
for (int i = 0; i < m; ++i) {
scanf("%d %d", &p[i], &y[i]);
}
vector<vector<int>> a(n, vector<int>(0));
for (int i = 0; i < m; ++i) {
a[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; ++i) {
sort(a[i].begin(), a[i].end());
}
for (int i = 0; i < m; ++i) {
auto itr = lower_bound(a[p[i] - 1].begin(), a[p[i] - 1].end(), y[i]);
printf("%06d%06d\n", p[i], distance(a[p[i] - 1].begin(), itr) + 1);
}
return 0;
}
| replace | 23 | 26 | 23 | 25 | TLE | |
p03221 | C++ | Runtime Error | #include <iomanip>
#include <ios>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct city {
long long year;
long long num;
long long pref;
long long order;
};
bool operator<(const struct city &a, const struct city &b) {
return a.year > b.year;
}
priority_queue<struct city> que[10002];
vector<struct city> ps;
int main(void) {
long long n, m;
cin >> n >> m;
for (long long i = 0; i < m; i++) {
long long p, y;
cin >> p >> y;
struct city t;
t.pref = p;
t.num = i;
t.year = y;
que[p].push(t);
ps.push_back(t);
}
for (long long i = 1; i <= n; i++) {
long long cur = 1;
while (!que[i].empty()) {
struct city t = que[i].top();
ps[t.num].order = cur;
que[i].pop();
cur++;
}
}
for (long long i = 0; i < m; i++) {
cout << std::setfill('0') << std::right << std::setw(6) << ps[i].pref;
cout << std::setfill('0') << std::right << std::setw(6) << ps[i].order
<< endl;
}
return 0;
} | #include <iomanip>
#include <ios>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct city {
long long year;
long long num;
long long pref;
long long order;
};
bool operator<(const struct city &a, const struct city &b) {
return a.year > b.year;
}
priority_queue<struct city> que[100002];
vector<struct city> ps;
int main(void) {
long long n, m;
cin >> n >> m;
for (long long i = 0; i < m; i++) {
long long p, y;
cin >> p >> y;
struct city t;
t.pref = p;
t.num = i;
t.year = y;
que[p].push(t);
ps.push_back(t);
}
for (long long i = 1; i <= n; i++) {
long long cur = 1;
while (!que[i].empty()) {
struct city t = que[i].top();
ps[t.num].order = cur;
que[i].pop();
cur++;
}
}
for (long long i = 0; i < m; i++) {
cout << std::setfill('0') << std::right << std::setw(6) << ps[i].pref;
cout << std::setfill('0') << std::right << std::setw(6) << ps[i].order
<< endl;
}
return 0;
} | replace | 18 | 19 | 18 | 19 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
int p[100005];
int y[100005];
vector<int> order[100005];
int main() {
int n, m;
cin >> n >> m;
REP(i, m) {
cin >> p[i];
cin >> y[i];
order[p[i] - 1].push_back(y[i]);
}
REP(i, n) sort(ALL(order[i]));
REP(i, m) {
printf("%06d", p[i]);
printf("%06d",
find(ALL(order[p[i] - 1]), y[i]) - order[p[i] - 1].begin() + 1);
printf("\n");
}
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
int p[100005];
int y[100005];
vector<int> order[100005];
int main() {
int n, m;
cin >> n >> m;
REP(i, m) {
cin >> p[i];
cin >> y[i];
order[p[i] - 1].push_back(y[i]);
}
REP(i, n) sort(ALL(order[i]));
REP(i, m) {
printf("%06d", p[i]);
printf("%06d", lower_bound(ALL(order[p[i] - 1]), y[i]) -
order[p[i] - 1].begin() + 1);
printf("\n");
}
return 0;
} | replace | 31 | 33 | 31 | 33 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) \
int x; \
scanf("%d", &x);
#define scll(x) \
LL x; \
scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
LL mod = 1e9 + 7;
/* Fast I/O */
inline int scanInt() {
int n = 0;
char ch = getchar();
int sign = 1;
while (ch < '0' || ch > '9') {
if (ch == '-')
sign = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
n = (n << 1) + (n << 3) + (int)(ch - '0');
ch = getchar();
}
return n * sign;
}
inline LL scanLong() {
LL n = 0;
char ch = getchar();
LL sign = 1;
while (ch < '0' || ch > '9') {
if (ch == '-')
sign = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
n = (n << 1) + (n << 3) + (LL)(ch - '0');
ch = getchar();
}
return n * sign;
}
const LL MAXN = 1e5;
string getSixDigit(LL n) {
string ret = "";
while (ret.length() != 6) {
ret = char('0' + n % 10) + ret;
n /= 10;
}
return ret;
}
struct City {
LL idx, prefect, year;
string id;
void setId(LL x) { id = getSixDigit(prefect) + getSixDigit(x); }
} cities[MAXN];
bool sortByYear(City a, City b) { return a.year < b.year; }
int main() {
sll(n);
sll(m);
vector<City> pre_city[n + 1];
rep(i, 1, m + 1) {
cities[i].idx = i;
cities[i].prefect = scanLong();
cities[i].year = scanLong();
pre_city[cities[i].prefect].push_back(cities[i]);
}
rep(i, 1, n + 1) {
sort(pre_city[i].begin(), pre_city[i].end(), sortByYear);
rep(x, 0, pre_city[i].size()) cities[pre_city[i][x].idx].setId(x + 1);
}
rep(i, 1, m + 1) cout << cities[i].id << endl;
} | #include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) \
int x; \
scanf("%d", &x);
#define scll(x) \
LL x; \
scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
LL mod = 1e9 + 7;
/* Fast I/O */
inline int scanInt() {
int n = 0;
char ch = getchar();
int sign = 1;
while (ch < '0' || ch > '9') {
if (ch == '-')
sign = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
n = (n << 1) + (n << 3) + (int)(ch - '0');
ch = getchar();
}
return n * sign;
}
inline LL scanLong() {
LL n = 0;
char ch = getchar();
LL sign = 1;
while (ch < '0' || ch > '9') {
if (ch == '-')
sign = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
n = (n << 1) + (n << 3) + (LL)(ch - '0');
ch = getchar();
}
return n * sign;
}
const LL MAXN = 1e5 + 10;
string getSixDigit(LL n) {
string ret = "";
while (ret.length() != 6) {
ret = char('0' + n % 10) + ret;
n /= 10;
}
return ret;
}
struct City {
LL idx, prefect, year;
string id;
void setId(LL x) { id = getSixDigit(prefect) + getSixDigit(x); }
} cities[MAXN];
bool sortByYear(City a, City b) { return a.year < b.year; }
int main() {
sll(n);
sll(m);
vector<City> pre_city[n + 1];
rep(i, 1, m + 1) {
cities[i].idx = i;
cities[i].prefect = scanLong();
cities[i].year = scanLong();
pre_city[cities[i].prefect].push_back(cities[i]);
}
rep(i, 1, n + 1) {
sort(pre_city[i].begin(), pre_city[i].end(), sortByYear);
rep(x, 0, pre_city[i].size()) cities[pre_city[i][x].idx].setId(x + 1);
}
rep(i, 1, m + 1) cout << cities[i].id << endl;
} | replace | 66 | 67 | 66 | 67 | 0 | |
p03221 | C++ | Runtime Error | #include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <sstream>
#include <string>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
map<int, list<pair<int, int>>> town;
town.clear();
int ken = 0, val = 0;
string ans[10000] = {""};
for (int i = 0; i < m; ++i) {
cin >> ken >> val;
town[ken].push_back(pair<int, int>(val, i));
}
for (int i = 1; i <= n; ++i) {
town[i].sort();
list<pair<int, int>>::iterator it = town[i].begin();
int cnt = 1;
while (it != town[i].end()) {
stringstream strStream;
strStream << setfill('0') << right << setw(6) << i;
strStream << setfill('0') << right << setw(6) << cnt;
ans[(*it).second] = strStream.str();
++it;
++cnt;
}
}
for (int i = 0; i < m; ++i) {
cout << ans[i] << endl;
}
return 0;
}
| #include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <sstream>
#include <string>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
map<int, list<pair<int, int>>> town;
town.clear();
int ken = 0, val = 0;
string ans[100000] = {""};
for (int i = 0; i < m; ++i) {
cin >> ken >> val;
town[ken].push_back(pair<int, int>(val, i));
}
for (int i = 1; i <= n; ++i) {
town[i].sort();
list<pair<int, int>>::iterator it = town[i].begin();
int cnt = 1;
while (it != town[i].end()) {
stringstream strStream;
strStream << setfill('0') << right << setw(6) << i;
strStream << setfill('0') << right << setw(6) << cnt;
ans[(*it).second] = strStream.str();
++it;
++cnt;
}
}
for (int i = 0; i < m; ++i) {
cout << ans[i] << endl;
}
return 0;
} | replace | 15 | 16 | 15 | 16 | 0 | |
p03221 | Python | Runtime Error | import sys
from collections import defaultdict
from copy import deepcopy
input = sys.stdin.readline
N, M = list(map(int, input().split()))
PY = []
for _ in range(M):
PY.append(list(map(int, input().split())))
sorted_PY = deepcopy(PY)
sorted_PY.sort(key=lambda x: x[1])
p_count_dict = defaultdict(lambda: 0)
y_dict = {}
for py in sorted_PY:
p_count_dict[py[0]] += 1
y_dict[py[1]] = p_count_dict[py[0]]
for py in PY:
print(f"{py[0]:0>6}{y_dict[py[1]]:0>6}")
| import sys
from collections import defaultdict
from copy import deepcopy
input = sys.stdin.readline
N, M = list(map(int, input().split()))
PY = []
for _ in range(M):
PY.append(list(map(int, input().split())))
sorted_PY = deepcopy(PY)
sorted_PY.sort(key=lambda x: x[1])
p_count_dict = defaultdict(lambda: 0)
y_dict = {}
for py in sorted_PY:
p_count_dict[py[0]] += 1
y_dict[py[1]] = p_count_dict[py[0]]
for py in PY:
# print(f'{py[0]:0>6}{y_dict[py[1]]:0>6}')
print("{}{}".format(str(py[0]).zfill(6), str(y_dict[py[1]]).zfill(6)))
| replace | 22 | 23 | 22 | 24 | 0 | |
p03221 | Python | Runtime Error | N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
res = [""] * M
ctr = [0] * (M + 1)
for i, (p, y) in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ctr[p] += 1
res[i] = "{:0>6}{:0>6}".format(p, ctr[p])
print(*res, sep="\n")
| N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
res = [""] * M
ctr = [0] * (N + 1)
for i, (p, y) in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])):
ctr[p] += 1
res[i] = "{:0>6}{:0>6}".format(p, ctr[p])
print(*res, sep="\n")
| replace | 4 | 5 | 4 | 5 | 0 | |
p03221 | Python | Runtime Error | N, M = map(int, input().split())
timeline = []
for i in range(M):
P, Y = map(int, input().split())
timeline.append((Y, P, i))
timeline.sort()
count = [0] * (N + 1)
number = [(0, 0)] * M
for y, p, i in timeline:
count[p] += 1
number[i] = (p, count[p])
for i in range(M):
print(f"{number[i][0]:06}{number[i][1]:06}")
| N, M = map(int, input().split())
timeline = []
for i in range(M):
P, Y = map(int, input().split())
timeline.append((Y, P, i))
timeline.sort()
count = [0] * (N + 1)
number = [(0, 0)] * M
for y, p, i in timeline:
count[p] += 1
number[i] = (p, count[p])
for i in range(M):
print("{:06}{:06}".format(number[i][0], number[i][1]))
| replace | 12 | 13 | 12 | 13 | 0 | |
p03221 | C++ | Runtime Error | #include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
struct City {
int prefecture;
int year;
int x;
};
int main() {
int N, M;
cin >> N >> M;
vector<City> city(M);
map<int, map<int, int>> years;
for (int i = 1; i <= M; i++) {
int Pi, Yi;
cin >> Pi >> Yi;
city[i].prefecture = Pi, city[i].year = Yi;
years[Pi][Yi] = i;
}
for (int Pi = 1; Pi <= N; Pi++) {
int x = 1;
for (auto year_i : years[Pi])
city[year_i.second].x = x++;
}
for (int i = 1; i <= M; i++) {
cout << setfill('0');
cout << setw(6) << city[i].prefecture;
cout << setw(6) << city[i].x << endl;
}
} | #include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
struct City {
int prefecture;
int year;
int x;
};
int main() {
int N, M;
cin >> N >> M;
vector<City> city(M + 1);
map<int, map<int, int>> years;
for (int i = 1; i <= M; i++) {
int Pi, Yi;
cin >> Pi >> Yi;
city[i].prefecture = Pi, city[i].year = Yi;
years[Pi][Yi] = i;
}
for (int Pi = 1; Pi <= N; Pi++) {
int x = 1;
for (auto year_i : years[Pi])
city[year_i.second].x = x++;
}
for (int i = 1; i <= M; i++) {
cout << setfill('0');
cout << setw(6) << city[i].prefecture;
cout << setw(6) << city[i].x << endl;
}
} | replace | 16 | 17 | 16 | 17 | -11 | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int>> vvi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
#define mt make_tuple
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
int main() {
int n, m;
cin >> n >> m;
vector<tuple<int, int, int>> a;
vector<int> cnt(m, 0);
for (int i = 0; i < m; i++) {
int p, y;
cin >> p >> y;
a.pb(mt(p, y, i));
cnt[p - 1]++;
}
sort(a.begin(), a.end());
vector<pair<string, string>> ans(m);
int k = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < cnt[i]; j++) {
string str = "000000";
ans[get<2>(a[k])].first =
str.substr(0, 6 - to_string(i + 1).length()) + to_string(i + 1);
ans[get<2>(a[k])].second =
str.substr(0, 6 - to_string(j + 1).length()) + to_string(j + 1);
k++;
}
}
for (int i = 0; i < m; i++) {
cout << ans[i].first << ans[i].second << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int>> vvi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
#define mt make_tuple
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
int main() {
int n, m;
cin >> n >> m;
vector<tuple<int, int, int>> a;
vector<int> cnt(n, 0);
for (int i = 0; i < m; i++) {
int p, y;
cin >> p >> y;
a.pb(mt(p, y, i));
cnt[p - 1]++;
}
sort(a.begin(), a.end());
vector<pair<string, string>> ans(m);
int k = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < cnt[i]; j++) {
string str = "000000";
ans[get<2>(a[k])].first =
str.substr(0, 6 - to_string(i + 1).length()) + to_string(i + 1);
ans[get<2>(a[k])].second =
str.substr(0, 6 - to_string(j + 1).length()) + to_string(j + 1);
k++;
}
}
for (int i = 0; i < m; i++) {
cout << ans[i].first << ans[i].second << endl;
}
} | replace | 31 | 32 | 31 | 32 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
int main() {
int N, M;
cin >> N >> M;
vector<PP> C(M);
for (int i = 0; i < M; i++) {
int p, y;
cin >> p >> y;
C[i] = PP(P(p, y), i);
}
sort(C.begin(), C.end());
vector<P> res(N);
int pre = 0, cnt = 0;
for (int i = 0; i < M; i++) {
int p = C[i].first.first;
if (p == pre) {
cnt++;
} else {
cnt = 1;
}
pre = p;
res[C[i].second] = P(p, cnt);
}
for (int i = 0; i < M; i++) {
printf("%.6d%.6d\n", res[i].first, res[i].second);
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
int main() {
int N, M;
cin >> N >> M;
vector<PP> C(M);
for (int i = 0; i < M; i++) {
int p, y;
cin >> p >> y;
C[i] = PP(P(p, y), i);
}
sort(C.begin(), C.end());
vector<P> res(M);
int pre = 0, cnt = 0;
for (int i = 0; i < M; i++) {
int p = C[i].first.first;
if (p == pre) {
cnt++;
} else {
cnt = 1;
}
pre = p;
res[C[i].second] = P(p, cnt);
}
for (int i = 0; i < M; i++) {
printf("%.6d%.6d\n", res[i].first, res[i].second);
}
return 0;
} | replace | 19 | 20 | 19 | 20 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> v(n);
vector<pair<int, int>> o(m);
repi(i, m, 0) {
int p, y;
cin >> p >> y;
v[p - 1].push_back(y);
o[i].first = p;
o[i].second = y;
}
repi(i, n, 0) { sort(v[i].begin(), v[i].end()); }
repi(i, m, 0) {
int p = o[i].first, y = o[i].second;
int cnt = 0;
repi(j, v[p - 1].size(), 0) {
cnt++;
if (v[p - 1][j] == y) {
string pid = "000000", yid = "000000";
pid += to_string(p);
yid += to_string(cnt);
cout << pid.substr(pid.size() - 6) + yid.substr(yid.size() - 6) << endl;
break;
}
}
}
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> v(n);
vector<pair<int, int>> o(m);
repi(i, m, 0) {
int p, y;
cin >> p >> y;
v[p - 1].push_back(y);
o[i].first = p;
o[i].second = y;
}
repi(i, n, 0) { sort(v[i].begin(), v[i].end()); }
repi(i, m, 0) {
int p = o[i].first, y = o[i].second;
int cnt = 0;
auto itr = lower_bound(v[p - 1].begin(), v[p - 1].end(), y);
string pid = "000000", yid = "000000";
pid += to_string(p);
yid += to_string(distance(v[p - 1].begin(), itr) + 1);
cout << pid.substr(pid.size() - 6) + yid.substr(yid.size() - 6) << endl;
}
return 0;
} | replace | 28 | 38 | 28 | 33 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define put(i) cout << fixed << i << endl
using namespace std;
using ll = long long;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> p(m), y(m);
rep(i, m) cin >> p[i] >> y[i];
map<pair<ll, ll>, ll> mp;
for (int i = 0; i < m; i++) {
mp[make_pair(p[i], y[i])];
}
vector<ll> cnt(m, 0);
for (auto x : mp) {
cnt[x.first.first - 1]++;
mp[x.first] = cnt[x.first.first - 1];
// cout << x.first.first << " " << x.first.second << " " << x.second <<
// endl;
}
for (int i = 0; i < m; i++) {
cout << setfill('0') << right << setw(6) << p[i];
cout << setfill('0') << right << setw(6) << mp[make_pair(p[i], y[i])]
<< endl;
}
// for(auto x:mp) cout << x.first.first << " " << x.first.second << " " <<
// x.second << endl; for(auto x:cnt) cout << x << " "; cout << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define put(i) cout << fixed << i << endl
using namespace std;
using ll = long long;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> p(m), y(m);
rep(i, m) cin >> p[i] >> y[i];
map<pair<ll, ll>, ll> mp;
for (int i = 0; i < m; i++) {
mp[make_pair(p[i], y[i])];
}
vector<ll> cnt(n, 0);
for (auto x : mp) {
cnt[x.first.first - 1]++;
mp[x.first] = cnt[x.first.first - 1];
// cout << x.first.first << " " << x.first.second << " " << x.second <<
// endl;
}
for (int i = 0; i < m; i++) {
cout << setfill('0') << right << setw(6) << p[i];
cout << setfill('0') << right << setw(6) << mp[make_pair(p[i], y[i])]
<< endl;
}
// for(auto x:mp) cout << x.first.first << " " << x.first.second << " " <<
// x.second << endl; for(auto x:cnt) cout << x << " "; cout << endl;
} | replace | 18 | 19 | 18 | 19 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(long long N, long long M, std::vector<long long> P,
std::vector<long long> Y) {
map<ll, vector<ll>> PYmap;
for (ll i = 0; i < M; ++i) {
PYmap[P[i]].push_back(Y[i]);
}
for (auto &&m : PYmap) {
sort(begin(m.second), end(m.second));
}
for (ll i = 0; i < M; ++i) {
auto &Pcities = PYmap[P[i]];
auto it = find(begin(Pcities), end(Pcities), Y[i]);
auto x = distance(begin(Pcities), it) + 1;
printf("%06lld%06ld\n", P[i], x);
}
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You
// use the default template now. You can remove this line by using your custom
// template)
// clang-format off
int main(){
long long N;
scanf("%lld",&N);
long long M;
scanf("%lld",&M);
std::vector<long long> P(M);
std::vector<long long> Y(M);
for(int i = 0 ; i < M ; i++){
scanf("%lld",&P[i]);
scanf("%lld",&Y[i]);
}
cin.tie(nullptr);
cout.tie(nullptr);
ios_base::sync_with_stdio(false);
solve(N, M, std::move(P), std::move(Y));
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(long long N, long long M, std::vector<long long> P,
std::vector<long long> Y) {
map<ll, vector<ll>> PYmap;
for (ll i = 0; i < M; ++i) {
PYmap[P[i]].push_back(Y[i]);
}
for (auto &&m : PYmap) {
sort(begin(m.second), end(m.second));
}
for (ll i = 0; i < M; ++i) {
auto &Pcities = PYmap[P[i]];
auto it = lower_bound(begin(Pcities), end(Pcities), Y[i]);
auto x = distance(begin(Pcities), it) + 1;
printf("%06lld%06ld\n", P[i], x);
}
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You
// use the default template now. You can remove this line by using your custom
// template)
// clang-format off
int main(){
long long N;
scanf("%lld",&N);
long long M;
scanf("%lld",&M);
std::vector<long long> P(M);
std::vector<long long> Y(M);
for(int i = 0 ; i < M ; i++){
scanf("%lld",&P[i]);
scanf("%lld",&Y[i]);
}
cin.tie(nullptr);
cout.tie(nullptr);
ios_base::sync_with_stdio(false);
solve(N, M, std::move(P), std::move(Y));
return 0;
}
| replace | 15 | 16 | 15 | 16 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(n), y(n);
vector<vector<int>> data(
n); // (prefecture, year), be careful with the initialization...
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
data[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; i++) {
sort(data[i].begin(), data[i].end());
}
for (int i = 0; i < m; i++) {
cout << setw(6) << setfill('0') << p[i] << setw(6) << setfill('0')
<< lower_bound(data[p[i] - 1].begin(), data[p[i] - 1].end(), y[i]) -
data[p[i] - 1].begin() + 1
<< endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<long long int> p(m), y(m);
vector<vector<long long int>> data(
n); // (prefecture, year), be careful with the initialization...
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
data[p[i] - 1].push_back(y[i]);
}
for (int i = 0; i < n; i++) {
sort(data[i].begin(), data[i].end());
}
for (int i = 0; i < m; i++) {
cout << setw(6) << setfill('0') << p[i] << setw(6) << setfill('0')
<< lower_bound(data[p[i] - 1].begin(), data[p[i] - 1].end(), y[i]) -
data[p[i] - 1].begin() + 1
<< endl;
}
return 0;
} | replace | 7 | 9 | 7 | 9 | 0 | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(n + 1);
vector<int> y(m + 1);
vector<int> id[n + 1];
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
id[p[i]].push_back(y[i]);
}
for (int i = 0; i < n; i++) {
sort(id[i + 1].begin(), id[i + 1].end());
}
for (int i = 0; i < m; i++) {
printf("%012lld\n",
(long long)(p[i]) * 1000000 +
(long long)(lower_bound(id[p[i]].begin(), id[p[i]].end(), y[i]) -
id[p[i]].begin() + 1));
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> p(m + 1);
vector<int> y(m + 1);
vector<int> id[n + 1];
for (int i = 0; i < m; i++) {
cin >> p[i] >> y[i];
id[p[i]].push_back(y[i]);
}
for (int i = 0; i < n; i++) {
sort(id[i + 1].begin(), id[i + 1].end());
}
for (int i = 0; i < m; i++) {
printf("%012lld\n",
(long long)(p[i]) * 1000000 +
(long long)(lower_bound(id[p[i]].begin(), id[p[i]].end(), y[i]) -
id[p[i]].begin() + 1));
}
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template <typename TYPE> void print_vec(const vector<TYPE> &v) {
for (int i = 0; i < v.size(); i++) {
cout << v[i] << " ";
}
cout << endl;
}
template <typename TYPE> void print_vec2(const vector<vector<TYPE>> &v) {
cout << endl;
cout << " ";
for (int i = 0; i < v[0].size(); i++)
cout << i << " ";
cout << endl;
for (int i = 0; i < v.size(); i++) {
cout << "i=" << i << ": ";
for (int j = 0; j < v[i].size(); j++) {
if (v[i][j] == 0)
cout << "\x1B[0m" << v[i][j] << " ";
else
cout << "\x1B[31m" << v[i][j]
<< " "; // https://stackoverrun.com/ja/q/12618775
}
cout << "\x1B[0m" << endl;
}
}
using LP = pair<ll, int>;
string zeronumber(int x) {
string num = to_string(x);
string zero = "";
for (int i = 6; i > (int)num.size(); i--)
zero.push_back('0');
return zero + num;
}
int main() {
int N, M;
cin >> N >> M;
vector<LP> YP;
for (int i = 0; i < M; i++) {
int p;
ll y;
cin >> p >> y;
p--;
YP.emplace_back(y, p);
}
// sort(YP.begin(), YP.end());
vector<vector<ll>> id(N, vector<ll>()); // id[i][j]: 県iのj番目にできた年
for (int i = 0; i < M; i++) {
id[YP[i].second].push_back(YP[i].first);
}
// cout << " id: "; print_vec2(id);
for (int i = 0; i < N; i++) {
for (int j = 0; j < id[i].size(); j++) {
sort(id[i].begin(), id[i].end());
}
}
// cout << " id: "; print_vec2(id);
for (int i = 0; i < M; i++) {
int y = YP[i].first;
int p = YP[i].second;
string ue6 = zeronumber(p + 1);
auto iter = lower_bound(id[p].begin(), id[p].end(), y);
auto index = iter - id[p].begin();
string sita6 = zeronumber((int)index + 1);
cout << ue6 + sita6 << endl;
}
return 0;
}
| #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template <typename TYPE> void print_vec(const vector<TYPE> &v) {
for (int i = 0; i < v.size(); i++) {
cout << v[i] << " ";
}
cout << endl;
}
template <typename TYPE> void print_vec2(const vector<vector<TYPE>> &v) {
cout << endl;
cout << " ";
for (int i = 0; i < v[0].size(); i++)
cout << i << " ";
cout << endl;
for (int i = 0; i < v.size(); i++) {
cout << "i=" << i << ": ";
for (int j = 0; j < v[i].size(); j++) {
if (v[i][j] == 0)
cout << "\x1B[0m" << v[i][j] << " ";
else
cout << "\x1B[31m" << v[i][j]
<< " "; // https://stackoverrun.com/ja/q/12618775
}
cout << "\x1B[0m" << endl;
}
}
using LP = pair<ll, int>;
string zeronumber(int x) {
string num = to_string(x);
string zero = "";
for (int i = 6; i > (int)num.size(); i--)
zero.push_back('0');
return zero + num;
}
int main() {
int N, M;
cin >> N >> M;
vector<LP> YP;
for (int i = 0; i < M; i++) {
int p;
ll y;
cin >> p >> y;
p--;
YP.emplace_back(y, p);
}
// sort(YP.begin(), YP.end());
vector<vector<ll>> id(N, vector<ll>()); // id[i][j]: 県iのj番目にできた年
for (int i = 0; i < M; i++) {
id[YP[i].second].push_back(YP[i].first);
}
// cout << " id: "; print_vec2(id);
for (int i = 0; i < N; i++) {
sort(id[i].begin(), id[i].end());
}
// cout << " id: "; print_vec2(id);
for (int i = 0; i < M; i++) {
int y = YP[i].first;
int p = YP[i].second;
string ue6 = zeronumber(p + 1);
auto iter = lower_bound(id[p].begin(), id[p].end(), y);
auto index = iter - id[p].begin();
string sita6 = zeronumber((int)index + 1);
cout << ue6 + sita6 << endl;
}
return 0;
}
| replace | 56 | 59 | 56 | 57 | TLE | |
p03221 | C++ | Runtime Error | #include <iostream>
// #include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <utility>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
const int MAXN = 1e2 + 5, INF = 1e9;
int n, m;
pair<int, int> inp[MAXN];
vector<int> a[MAXN];
string makeID(int x) {
string s = "";
while (x) {
s.push_back((x % 10) + '0');
x /= 10;
}
while (s.length() < 6) {
s.push_back('0');
}
reverse(s.begin(), s.end());
return s;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < m; ++i) {
cin >> inp[i].first >> inp[i].second;
a[inp[i].first - 1].emplace_back(inp[i].second);
}
for (int i = 0; i < n; ++i) {
sort(a[i].begin(), a[i].end());
}
for (int i = 0; i < m; ++i) {
int x = lower_bound(a[inp[i].first - 1].begin(), a[inp[i].first - 1].end(),
inp[i].second) -
a[inp[i].first - 1].begin();
cout << makeID(inp[i].first) << makeID(x + 1) << endl;
}
return 0;
} | #include <iostream>
// #include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string.h>
#include <utility>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
const int MAXN = 1e5 + 5, INF = 1e9;
int n, m;
pair<int, int> inp[MAXN];
vector<int> a[MAXN];
string makeID(int x) {
string s = "";
while (x) {
s.push_back((x % 10) + '0');
x /= 10;
}
while (s.length() < 6) {
s.push_back('0');
}
reverse(s.begin(), s.end());
return s;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < m; ++i) {
cin >> inp[i].first >> inp[i].second;
a[inp[i].first - 1].emplace_back(inp[i].second);
}
for (int i = 0; i < n; ++i) {
sort(a[i].begin(), a[i].end());
}
for (int i = 0; i < m; ++i) {
int x = lower_bound(a[inp[i].first - 1].begin(), a[inp[i].first - 1].end(),
inp[i].second) -
a[inp[i].first - 1].begin();
cout << makeID(inp[i].first) << makeID(x + 1) << endl;
}
return 0;
} | replace | 19 | 20 | 19 | 20 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
vector<int> p(M, 0);
vector<int> yp(M, 0);
vector<vector<int>> y(N, vector<int>(0, 0));
for (int i = 0; i < M; ++i) {
int tmp_p, tmp_y;
cin >> tmp_p >> tmp_y;
--tmp_p;
p[i] = tmp_p;
yp[i] = tmp_y;
y[tmp_p].push_back(tmp_y);
}
for (int i = 0; i < N; ++i) {
sort(y[i].begin(), y[i].end());
}
for (int i = 0; i < M; ++i) {
std::vector<int>::iterator it = find(y[p[i]].begin(), y[p[i]].end(), yp[i]);
int index = distance(y[p[i]].begin(), it);
cout << setw(6) << setfill('0') << p[i] + 1;
cout << setw(6) << setfill('0') << index + 1 << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
vector<int> p(M, 0);
vector<int> yp(M, 0);
vector<vector<int>> y(N, vector<int>(0, 0));
for (int i = 0; i < M; ++i) {
int tmp_p, tmp_y;
cin >> tmp_p >> tmp_y;
--tmp_p;
p[i] = tmp_p;
yp[i] = tmp_y;
y[tmp_p].push_back(tmp_y);
}
for (int i = 0; i < N; ++i) {
sort(y[i].begin(), y[i].end());
}
for (int i = 0; i < M; ++i) {
int index =
lower_bound(y[p[i]].begin(), y[p[i]].end(), yp[i]) - y[p[i]].begin();
cout << setw(6) << std::setfill('0') << p[i] + 1;
cout << setw(6) << std::setfill('0') << index + 1 << endl;
}
return 0;
}
| replace | 25 | 29 | 25 | 29 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;
typedef pair<int, int> P;
int main() {
int n, m;
cin >> n >> m;
int p[m + 10], y[m + 10];
P num[m + 10];
rep(i, 0, m) {
cin >> p[i] >> y[i];
num[i].second = p[i];
num[i].first = y[i];
}
sort(num, num + m);
vector<int> v[100010];
rep(i, 0, m) { v[num[i].second - 1].push_back(num[i].first); }
string digit[] = {"00000", "0000", "000", "00", "0", ""};
rep(i, 0, m) {
string s = to_string(p[i]);
vector<int>::iterator pn =
find(v[p[i] - 1].begin(), v[p[i] - 1].end(), y[i]);
size_t index = distance(v[p[i] - 1].begin(), pn);
string t = to_string(index + 1);
cout << digit[s.size() - 1] << s << digit[t.size() - 1] << t << endl;
}
return 0;
}
| #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;
typedef pair<int, int> P;
int main() {
int n, m;
cin >> n >> m;
int p[m + 10], y[m + 10];
P num[m + 10];
rep(i, 0, m) {
cin >> p[i] >> y[i];
num[i].second = p[i];
num[i].first = y[i];
}
sort(num, num + m);
vector<int> v[100010];
rep(i, 0, m) { v[num[i].second - 1].push_back(num[i].first); }
string digit[] = {"00000", "0000", "000", "00", "0", ""};
rep(i, 0, m) {
string s = to_string(p[i]);
int index = upper_bound(v[p[i] - 1].begin(), v[p[i] - 1].end(), y[i]) -
v[p[i] - 1].begin();
string t = to_string(index);
cout << digit[s.size() - 1] << s << digit[t.size() - 1] << t << endl;
}
return 0;
}
| replace | 32 | 37 | 32 | 35 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define rrep(i, n) RREP(i, n - 1, 0)
#define all(v) v.begin(), v.end()
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<ll> P(m), Y(m);
vector<set<pair<ll, int>>> C(n);
rep(i, m) {
cin >> P[i] >> Y[i];
P[i]--;
C[P[i]].emplace(Y[i], i);
}
vector<int> ans(n);
rep(i, n) {
int j = 1;
for (auto ele : C[i])
ans[ele.second] = j++;
}
rep(i, m) {
cout << setfill('0') << right << setw(6) << P[i] + 1;
cout << setfill('0') << right << setw(6) << ans[i];
cout << "\n";
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define rrep(i, n) RREP(i, n - 1, 0)
#define all(v) v.begin(), v.end()
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<ll> P(m), Y(m);
vector<set<pair<ll, int>>> C(n);
rep(i, m) {
cin >> P[i] >> Y[i];
P[i]--;
C[P[i]].emplace(Y[i], i);
}
vector<int> ans(m);
rep(i, n) {
int j = 1;
for (auto ele : C[i])
ans[ele.second] = j++;
}
rep(i, m) {
cout << setfill('0') << right << setw(6) << P[i] + 1;
cout << setfill('0') << right << setw(6) << ans[i];
cout << "\n";
}
return 0;
}
| replace | 24 | 25 | 24 | 25 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
Int GCD(Int a, Int b) {
if (b == 0)
return a;
if (a < b)
return GCD(b, a);
unsigned r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
int binary_search_index(Int Y, vi q) {
int left = 0, right = q.size() - 1;
while (right >= left) {
int mid = left + (right - left) / 2;
if (q[mid] == Y)
return mid;
else if (q[mid] > Y)
right = mid - 1;
else if (q[mid] < Y)
left = mid + 1;
}
return -1;
}
int main() {
Int N, M;
cin >> N >> M;
vi P = vi(M);
vi Y = vi(M);
rep(i, M) {
cin >> P[i];
cin >> Y[i];
}
map<Int, vi> mp;
rep(i, M) { mp[P[i]].push_back(Y[i]); }
rep(i, N + 1) { sort(mp[i].begin(), mp[i].end()); }
rep(i, M) {
stringstream ans;
Int yi = binary_search_index(Y[i], mp[P[i]]) + 1;
ans << std::setw(6) << std::setfill('0') << P[i];
ans << std::setw(6) << std::setfill('0') << yi;
cout << ans.str() << endl;
}
return 0;
} | #include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
Int GCD(Int a, Int b) {
if (b == 0)
return a;
if (a < b)
return GCD(b, a);
unsigned r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
int binary_search_index(Int Y, vi &q) {
int left = 0, right = q.size() - 1;
while (right >= left) {
int mid = left + (right - left) / 2;
if (q[mid] == Y)
return mid;
else if (q[mid] > Y)
right = mid - 1;
else if (q[mid] < Y)
left = mid + 1;
}
return -1;
}
int main() {
Int N, M;
cin >> N >> M;
vi P = vi(M);
vi Y = vi(M);
rep(i, M) {
cin >> P[i];
cin >> Y[i];
}
map<Int, vi> mp;
rep(i, M) { mp[P[i]].push_back(Y[i]); }
rep(i, N + 1) { sort(mp[i].begin(), mp[i].end()); }
rep(i, M) {
stringstream ans;
Int yi = binary_search_index(Y[i], mp[P[i]]) + 1;
ans << std::setw(6) << std::setfill('0') << P[i];
ans << std::setw(6) << std::setfill('0') << yi;
cout << ans.str() << endl;
}
return 0;
} | replace | 36 | 37 | 36 | 37 | TLE | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>
bool city(pair<P, int> a, pair<P, int> b) { return a.second < b.second; }
int main() {
int n, m;
cin >> n >> m;
pair<P, int> c[n];
rep(i, m) {
cin >> c[i].first.first >> c[i].first.second;
c[i].second = i;
}
sort(c, c + m);
c[0].first.second = 1;
rep(i, m - 1) {
if (c[i + 1].first.first == c[i].first.first) {
c[i + 1].first.second = c[i].first.second + 1;
} else {
c[i + 1].first.second = 1;
}
}
sort(c, c + m, city);
for (int i = 0; i < m; i++) {
cout << setfill('0') << right << setw(6) << c[i].first.first;
cout << setfill('0') << right << setw(6) << c[i].first.second << endl;
}
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>
bool city(pair<P, int> a, pair<P, int> b) { return a.second < b.second; }
int main() {
int n, m;
cin >> n >> m;
pair<P, int> c[m];
rep(i, m) {
cin >> c[i].first.first >> c[i].first.second;
c[i].second = i;
}
sort(c, c + m);
c[0].first.second = 1;
rep(i, m - 1) {
if (c[i + 1].first.first == c[i].first.first) {
c[i + 1].first.second = c[i].first.second + 1;
} else {
c[i + 1].first.second = 1;
}
}
sort(c, c + m, city);
for (int i = 0; i < m; i++) {
cout << setfill('0') << right << setw(6) << c[i].first.first;
cout << setfill('0') << right << setw(6) << c[i].first.second << endl;
}
}
| replace | 18 | 19 | 18 | 19 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<vector<int>> data(N + 1);
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
data[P[i]].push_back(Y[i]);
}
for (int i = 0; i < N + 1; i++) {
sort(data[i].begin(), data[i].end());
}
for (int i = 0; i < M; i++) {
vector<int> d = data[P[i]];
int k = lower_bound(d.begin(), d.end(), Y[i]) - d.begin();
printf("%06d%06d\n", P[i], k + 1);
}
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<vector<int>> data(N + 1);
for (int i = 0; i < M; i++) {
cin >> P[i] >> Y[i];
data[P[i]].push_back(Y[i]);
}
for (int i = 0; i < N + 1; i++) {
sort(data[i].begin(), data[i].end());
}
for (int i = 0; i < M; i++) {
vector<int> &d = data[P[i]];
int k = lower_bound(d.begin(), d.end(), Y[i]) - d.begin();
printf("%06d%06d\n", P[i], k + 1);
}
}
| replace | 31 | 32 | 31 | 32 | TLE | |
p03221 | C++ | Runtime Error | #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
map<int, int> mp[n + 1];
int p[n + 1], y[n + 1];
REP(i, m) {
cin >> p[i] >> y[i];
mp[p[i]][y[i]]++;
}
FOR(i, 1, n + 1) {
int cnt = 1;
for (auto &x : mp[i]) {
x.second = cnt++;
}
}
REP(i, m) { printf("%06d%06d\n", p[i], mp[p[i]][y[i]]); }
return 0;
}
| #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
map<int, int> mp[n + 1];
int p[m + 1], y[m + 1];
REP(i, m) {
cin >> p[i] >> y[i];
mp[p[i]][y[i]]++;
}
FOR(i, 1, n + 1) {
int cnt = 1;
for (auto &x : mp[i]) {
x.second = cnt++;
}
}
REP(i, m) { printf("%06d%06d\n", p[i], mp[p[i]][y[i]]); }
return 0;
}
| replace | 11 | 12 | 11 | 12 | 0 | |
p03221 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, x, n) for (int i = x; i < n; i++)
#define all(L) L.begin(), L.end()
using ll = long long;
#define RO 1
#define SI 2
#define PA 3
int N, M;
int P[100000], Y[100000];
vector<int> idy[100001];
void dfs(int m, int bits, int &count) {
if (m > N)
return;
if (bits == 0b111)
count++;
dfs(10 * m + 7, bits | 0b100, count);
dfs(10 * m + 5, bits | 0b010, count);
dfs(10 * m + 3, bits | 0b001, count);
}
int main() {
cin >> N >> M;
rep(i, 0, M) {
cin >> P[i] >> Y[i];
idy[P[i]].push_back(Y[i]);
}
rep(i, 0, M) { sort(idy[P[i]].begin(), idy[P[i]].end()); }
rep(i, 0, M) {
printf("%06d", P[i]);
int x;
x = (int)(lower_bound(idy[P[i]].begin(), idy[P[i]].end(), Y[i]) -
idy[P[i]].begin()) +
1;
printf("%06d\n", x);
}
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, x, n) for (int i = x; i < n; i++)
#define all(L) L.begin(), L.end()
using ll = long long;
#define RO 1
#define SI 2
#define PA 3
int N, M;
int P[100000], Y[100000];
vector<int> idy[100001];
void dfs(int m, int bits, int &count) {
if (m > N)
return;
if (bits == 0b111)
count++;
dfs(10 * m + 7, bits | 0b100, count);
dfs(10 * m + 5, bits | 0b010, count);
dfs(10 * m + 3, bits | 0b001, count);
}
int main() {
cin >> N >> M;
rep(i, 0, M) {
cin >> P[i] >> Y[i];
idy[P[i]].push_back(Y[i]);
}
rep(i, 1, N + 1) { sort(idy[i].begin(), idy[i].end()); }
rep(i, 0, M) {
printf("%06d", P[i]);
int x;
x = (int)(lower_bound(idy[P[i]].begin(), idy[P[i]].end(), Y[i]) -
idy[P[i]].begin()) +
1;
printf("%06d\n", x);
}
}
| replace | 35 | 36 | 35 | 36 | TLE | |
p03221 | C++ | Time Limit Exceeded | /*
_ooOoo_
o8888888o
88" . "88 AC!AC!
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ul(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ul(var) = (max)-1; (var) + 1 > (min); --(var))
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
// vector<ld> vec;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
VV vec(n + 1);
VP reg(k);
rep(i, k) {
int x, y;
cin >> x >> y;
vec[x].push_back(y);
reg[i] = make_pair(x, y);
}
rep(i, n + 1) { sort(all(vec[i])); }
rep(i, k) {
int x =
find(all(vec[reg[i].first]), reg[i].second) - vec[reg[i].first].begin();
x++;
string s1 = to_string(reg[i].first);
string s2 = to_string(x);
rep(i, 6 - s1.size()) { cout << '0'; }
cout << s1;
rep(i, 6 - s2.size()) { cout << '0'; }
cout << s2 << endl;
}
}
| /*
_ooOoo_
o8888888o
88" . "88 AC!AC!
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ul(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ul(var) = (max)-1; (var) + 1 > (min); --(var))
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
// vector<ld> vec;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
VV vec(n + 1);
VP reg(k);
rep(i, k) {
int x, y;
cin >> x >> y;
vec[x].push_back(y);
reg[i] = make_pair(x, y);
}
rep(i, n + 1) { sort(all(vec[i])); }
rep(i, k) {
int x = lower_bound(all(vec[reg[i].first]), reg[i].second) -
vec[reg[i].first].begin();
x++;
string s1 = to_string(reg[i].first);
string s2 = to_string(x);
rep(i, 6 - s1.size()) { cout << '0'; }
cout << s1;
rep(i, 6 - s2.size()) { cout << '0'; }
cout << s2 << endl;
}
}
| replace | 78 | 80 | 78 | 80 | TLE | |
p03221 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<vector<int>> A(N + 1, vector<int>());
rep(i, 0, M) {
cin >> P[i] >> Y[i];
A[P[i]].push_back(Y[i]);
}
rep(i, 0, M) sort(A[P[i]].begin(), A[P[i]].end());
rep(i, 0, M) {
int n = lower_bound(A[P[i]].begin(), A[P[i]].end(), Y[i]) - A[P[i]].begin();
printf("%06d%06d\n", P[i], n + 1);
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
int main() {
int N, M;
cin >> N >> M;
vector<int> P(M), Y(M);
vector<vector<int>> A(N + 1, vector<int>());
rep(i, 0, M) {
cin >> P[i] >> Y[i];
A[P[i]].push_back(Y[i]);
}
rep(i, 1, N + 1) sort(A[i].begin(), A[i].end());
rep(i, 0, M) {
int n = lower_bound(A[P[i]].begin(), A[P[i]].end(), Y[i]) - A[P[i]].begin();
printf("%06d%06d\n", P[i], n + 1);
}
return 0;
}
| replace | 13 | 14 | 13 | 14 | TLE | |
p03221 | C++ | Runtime Error | #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define UNTIL(p) while (!(p))
// constant
const double EPS = 1e-5;
const double PI = acos(-1.0);
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
#define PUTS(x) cout << (x) << endl;
class Data {
public:
int n, p, y, id;
};
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<Data> data(M);
REP(i, M) {
data[i].n = i;
cin >> data[i].p >> data[i].y;
}
sort(ALL(data), [](const Data &a, const Data &b) {
return a.p < b.p ? (1) : (a.y < b.y);
});
int x = 1;
int pre_p = -1;
REP(i, M) {
if (data[i].p == pre_p) {
x++;
} else {
x = 1;
}
data[i].id = x;
pre_p = data[i].p;
}
sort(ALL(data), [](const Data &a, const Data &b) { return a.n < b.n; });
REP(i, M) { printf("%06d%06d\n", data[i].p, data[i].id); }
} | #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// conversion
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }
// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define UNTIL(p) while (!(p))
// constant
const double EPS = 1e-5;
const double PI = acos(-1.0);
// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
#define PUTS(x) cout << (x) << endl;
class Data {
public:
int n, p, y, id;
};
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<Data> data(M);
REP(i, M) {
data[i].n = i;
cin >> data[i].p >> data[i].y;
}
sort(ALL(data), [](const Data &a, const Data &b) {
if (a.p == b.p) {
return a.y < b.y;
} else {
return a.p < b.p;
}
});
int x = 1;
int pre_p = -1;
REP(i, M) {
if (data[i].p == pre_p) {
x++;
} else {
x = 1;
}
data[i].id = x;
pre_p = data[i].p;
}
sort(ALL(data), [](const Data &a, const Data &b) { return a.n < b.n; });
REP(i, M) { printf("%06d%06d\n", data[i].p, data[i].id); }
} | replace | 91 | 92 | 91 | 96 | 0 |
Subsets and Splits