QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#283620#1173. Knowledge Is...ckisekiWA 1ms3556kbC++231.5kb2023-12-14 22:23:422023-12-14 22:23:42

Judging History

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

  • [2023-12-14 22:23:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3556kb
  • [2023-12-14 22:23:42]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define all(x) begin(x), end(x)
#ifdef local
#include <experimental/iterator>
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(const char *s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
void orange_(const char *s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int,int>> s(N);
  for (int i = 0; i < N; i++) {
    auto &[l, r, id] = s[i];
    cin >> l >> r;
    id = i;
  }
  ranges::sort(s);

  multimap<int, int, greater<>> st;

  vector<int> ans(N, -1);
  // vector<int> match(N, -1);
  int mat = 0;

  for (auto [l, r, i] : s) {
    auto it = st.upper_bound(l);
    if (it != st.end()) {
      // match[i] = it->second;
      // match[it->second] = i;
      ans[i] = ans[it->second] = mat++;
      if (mat == M)
        break;
      st.erase(it);
    } else {
      st.insert({r, i});
    }
  }

  for (int i = 0; i < N && mat < M; i++)
    if (ans[i] == -1)
      ans[i] = mat++;

  for (int i = 0; i < N; i++)
    cout << ans[i] + 1 << (i+1==N ? '\n' : ' ');
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3496kb

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: 0ms
memory: 3512kb

input:

2 2
1 2
3 4

output:

1 1

result:

ok answer = 2

Test #3:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

2 1
1 2
2 3

output:

1 0

result:

ok answer = 1

Test #4:

score: 0
Accepted
time: 0ms
memory: 3424kb

input:

1 1
4 26

output:

1

result:

ok answer = 1

Test #5:

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

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:

39 119 120 121 39 40 122 1 123 124 125 41 42 43 71 126 127 128 44 45 72 46 129 130 131 132 133 134 135 1 47 73 136 137 48 74 138 139 75 76 2 140 3 40 2 141 49 77 142 41 50 51 52 42 143 53 144 145 3 4 146 147 54 4 148 78 149 150 151 152 79 153 55 154 155 43 56 5 156 57 58 157 5 6 7 59 158 6 7 60 159 ...

result:

ok answer = 376

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3552kb

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:

94 119 153 154 120 155 20 5 72 156 129 119 62 157 62 158 95 159 160 13 54 161 162 5 55 163 121 96 164 165 166 110 14 167 85 168 1 86 122 29 169 170 21 30 63 6 14 123 171 27 97 7 172 2 124 173 174 98 8 41 175 3 99 176 87 177 41 64 178 125 73 179 180 181 111 126 56 130 103 182 65 66 127 136 128 183 94...

result:

wrong answer participant answer = 394, judge answer = 471