답안 #771780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771780 2023-07-03T09:15:58 Z CyberCow 새 집 (APIO18_new_home) C++17
5 / 100
5000 ms 11988 KB
//#include <bits/stdc++.h>
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define fr first
#define sc second
#define ad push_back
using namespace std;
using ll = long long;
mt19937 rnd(348502);
const int N = 200005;
vector<pair<pair<int, int>, pair<int, int>>> v;
vector<pair<int, int>> aa;

void solve()
{
    int n, i, j, k, q, x, y, t, a, b;
    cin >> n >> k >> q;
    for (i = 0; i < n; i++)
    {
        cin >> x >> t >> a >> b;
        v.push_back({ {a, b}, {x, t} });
    }
    for ( i = 0; i < q; i++)
    {
        cin >> x >> y;
        map<int, int> ma;
        map<int, int> ma1;
        for ( j = 0; j < n; j++)
        {
            if (v[j].first.first <= y && v[j].first.second >= y)
            {
                if (ma[v[j].second.second] == 0)
                {
                    ma[v[j].second.second] = 1;
                    ma1[v[j].second.second] = abs(x - v[j].second.first);
                }
                else
                {
                    ma1[v[j].second.second] = min(ma1[v[j].second.second], abs(x - v[j].second.first));
                }
            }
        }
        if (ma.size() == k)
        {
            int ans = 0;
            for (auto to : ma1)
            {
                ans = max(ans, to.second);
            }
            cout << ans << '\n';
        }
        else
        {
            cout << -1 << '\n';
        }
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

Compilation message

new_home.cpp: In function 'void solve()':
new_home.cpp:60:23: warning: comparison of integer expressions of different signedness: 'std::map<int, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |         if (ma.size() == k)
      |             ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 10 ms 368 KB Output is correct
8 Correct 13 ms 340 KB Output is correct
9 Correct 17 ms 336 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 356 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 9 ms 332 KB Output is correct
17 Correct 5 ms 360 KB Output is correct
18 Correct 9 ms 332 KB Output is correct
19 Correct 9 ms 376 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 21 ms 396 KB Output is correct
22 Correct 12 ms 392 KB Output is correct
23 Correct 8 ms 340 KB Output is correct
24 Correct 6 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 10 ms 368 KB Output is correct
8 Correct 13 ms 340 KB Output is correct
9 Correct 17 ms 336 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 356 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 9 ms 332 KB Output is correct
17 Correct 5 ms 360 KB Output is correct
18 Correct 9 ms 332 KB Output is correct
19 Correct 9 ms 376 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 21 ms 396 KB Output is correct
22 Correct 12 ms 392 KB Output is correct
23 Correct 8 ms 340 KB Output is correct
24 Correct 6 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Execution timed out 5088 ms 2968 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5005 ms 11988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5044 ms 9908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 10 ms 368 KB Output is correct
8 Correct 13 ms 340 KB Output is correct
9 Correct 17 ms 336 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 356 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 9 ms 332 KB Output is correct
17 Correct 5 ms 360 KB Output is correct
18 Correct 9 ms 332 KB Output is correct
19 Correct 9 ms 376 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 21 ms 396 KB Output is correct
22 Correct 12 ms 392 KB Output is correct
23 Correct 8 ms 340 KB Output is correct
24 Correct 6 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Execution timed out 5088 ms 2968 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 10 ms 368 KB Output is correct
8 Correct 13 ms 340 KB Output is correct
9 Correct 17 ms 336 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 356 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 7 ms 376 KB Output is correct
16 Correct 9 ms 332 KB Output is correct
17 Correct 5 ms 360 KB Output is correct
18 Correct 9 ms 332 KB Output is correct
19 Correct 9 ms 376 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 21 ms 396 KB Output is correct
22 Correct 12 ms 392 KB Output is correct
23 Correct 8 ms 340 KB Output is correct
24 Correct 6 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Execution timed out 5088 ms 2968 KB Time limit exceeded
32 Halted 0 ms 0 KB -