QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#283604#1173. Knowledge Is...8BQubeWA 1ms7780kbC++201.2kb2023-12-14 21:40:452023-12-14 21:40:46

Judging History

你现在查看的是最新测评结果

  • [2023-12-14 21:40:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7780kb
  • [2023-12-14 21:40:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define pb push_back
#define ALL(v) v.begin(), v.end()

pii arr[300005];
int ans[300005], idx[300005];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    int tp = 0;
    for (int i = 1; i <= n; ++i)
        cin >> arr[i].X >> arr[i].Y;
    iota(idx + 1, idx + n + 1, 1);
    sort(idx + 1, idx + n + 1, [&](int a, int b) {
        if (arr[a].Y != arr[b].Y) return arr[a].Y < arr[b].Y;
        return arr[a].X < arr[b].X;
    });
    set<pii> st;
    for (int i = 1; i <= n; ++i) {
        int u = idx[i];
        auto p = st.lower_bound(pii(arr[u].X, 0));
        if (p != st.begin()) {
            --p;
            if (tp < m) {
                ++tp;
                ans[p->Y] = tp;
                ans[u] = tp;
            }
            st.erase(p);
        }
        else
            st.insert(pii(arr[u].Y, u));
    }
    for (int i = 1; i <= n; ++i) {
        if (!ans[i] && tp < m) ans[i] = ++tp;
        cout << ans[i] << " \n"[i == n];
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5600kb

input:

7 5
9 10
7 9
3 4
9 10
2 6
8 9
5 8

output:

3 2 1 4 2 5 1

result:

ok answer = 7

Test #2:

score: 0
Accepted
time: 1ms
memory: 7780kb

input:

2 2
1 2
3 4

output:

1 1

result:

ok answer = 2

Test #3:

score: 0
Accepted
time: 1ms
memory: 5624kb

input:

2 1
1 2
2 3

output:

1 0

result:

ok answer = 1

Test #4:

score: 0
Accepted
time: 1ms
memory: 5568kb

input:

1 1
4 26

output:

1

result:

ok answer = 1

Test #5:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

500 258
1 3
3 5
2 4
3 5
4 5
4 5
1 4
1 2
3 5
2 5
2 5
4 5
4 5
4 5
2 3
1 4
1 4
1 4
4 5
4 5
2 3
4 5
3 5
3 5
1 5
1 4
2 5
1 5
3 5
3 4
4 5
2 3
3 5
3 5
4 5
2 3
1 5
1 5
2 3
2 3
3 4
3 5
3 4
1 3
1 2
1 5
4 5
2 3
2 4
1 3
4 5
4 5
4 5
1 3
3 5
4 5
3 5
1 5
1 2
1 2
3 5
3 5
4 5
3 4
3 5
2 3
2 5
2 4
2 5
3 5
2 3
1 5
4 5
...

output:

118 119 120 121 63 64 122 38 123 124 125 69 70 71 117 126 127 128 73 74 116 75 129 130 131 132 133 134 135 22 83 115 136 137 86 114 138 139 113 112 28 140 31 111 37 141 91 110 142 109 45 44 43 108 143 39 144 145 36 35 146 147 47 37 148 107 149 150 151 152 106 153 52 154 155 105 53 7 156 54 56 157 34...

result:

ok answer = 376

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 5592kb

input:

500 242
8 9
9 10
2 9
8 10
9 10
6 10
4 8
4 5
2 6
7 10
3 8
1 8
1 6
5 9
7 8
8 10
8 9
8 10
2 9
2 3
6 8
3 10
5 9
1 3
6 8
4 10
9 10
8 9
8 10
1 9
3 9
3 7
2 3
6 10
3 6
6 10
3 4
3 6
9 10
5 7
8 10
6 10
5 6
5 7
7 8
1 3
4 7
9 10
4 9
2 4
8 9
1 3
8 10
3 4
9 10
4 9
5 10
8 9
1 3
1 5
8 10
3 4
8 9
3 9
3 6
3 10
6 7
7 ...

output:

104 126 153 154 135 155 152 5 93 156 151 150 92 157 82 158 159 160 161 49 61 162 163 27 55 164 165 103 166 167 168 118 26 169 91 170 53 90 171 33 172 173 15 32 71 25 25 129 174 52 98 24 175 51 119 176 177 108 23 61 178 3 97 179 89 180 47 67 181 124 88 182 183 184 117 125 149 148 116 185 74 80 127 14...

result:

wrong answer participant answer = 394, judge answer = 471