이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std;
#define int long long
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define UseOFF ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0);
#define sz size
#define ins insert
#define new junkedseduneon
#define prev usfdjik
const ll N = 2e6 + 111;
pair <ll, ll> a[N];
map <pair <ll, ll>, ll> ans;
map <pair <ll, ll>, ll> mp;
void solve() {
ll n, q;
cin >> n >> q;
vector < pair <ll, ll> > v;
for(int i = 1; i <= n; i++) {
cin >> a[i].ff >> a[i].ss;
v.pb({a[i].ss, a[i].ff});
mp[{a[i].ff, a[i].ss}] = i;
}
sort(v.begin(), v.end());
for(int i = 0; i < v.sz(); i++) {
a[i + 1].ff = v[i].ss;
a[i + 1].ss = v[i].ff;
//cout << a[i].ff << " " << a[i].ss << " || " << v[i].ss << " " << v[i].ff << '\n';
}
for(int i = 1; i <= n; i++) {
//cout << a[i].ff << " " << a[i].ss << '\n';
ans[{a[i].ff, a[i].ss}] = i;
}
for(int i = 1; i <= q; i++) {
ll s, f;
cin >> s >> f;
//cout << i << " - " << q << endl;
//cout << s << " " << f << " || " << a[f].ff << " " << a[f].ss << " || " << a[s].ff << " " << a[s].ss << '\n';
if(ans[{a[f].ff, a[f].ss}] - ans[{a[s].ff, a[s].ss}] < 0) {
cout << "impossible\n";
}
else {
//cout << s << " " << f << " || " << a[f].ff << " " << a[f].ss << " || " << a[s].ff << " " << a[s].ss << '\n';
cout << ans[{a[f].ff, a[f].ss}] - ans[{a[s].ff, a[s].ss}] << '\n';
}
}
}
signed main()
{
UseOFF
ll ttt = 1;
//cin >> ttt;
while(ttt--)
{
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
events.cpp: In function 'void solve()':
events.cpp:53:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i = 0; i < v.sz(); i++) {
| ~~^~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |