QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#119289#6669. Mapahos_lyric#0 1ms4036kbC++142.9kb2023-07-05 09:53:082024-05-31 19:05:08

Judging History

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

  • [2024-05-31 19:05:08]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4036kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-05 09:53:08]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


constexpr int E = 30;
constexpr int F = 15;
constexpr int MO = 32749;
int myhash(int x) {
  return x % MO;
}

string toBinary(int len, int x) {
  string s(len, '?');
  for (int e = 0; e < len; ++e) s[e] = "01"[x >> e & 1];
  return s;
}
int fromBinary(const string &s) {
  const int len = s.size();
  int x = 0;
  for (int e = 0; e < len; ++e) x |= (s[e] - '0') << e;
  return x;
}

string encode(int N, const vector<int> &X, const vector<int> &Y) {
  string S = "";
  for (int i = 0; i < N; ++i) {
    S += toBinary(F, myhash(X[i]));
    S += toBinary(E, Y[i]);
  }
  return S;
}

vector<int> decode(int N, int Q, int K, const string &S, const vector<int> &Z) {
  map<int, int> mapa;
  {
    int pos = 0;
    for (int i = 0; i < N; ++i) {
      const int h = fromBinary(S.substr(pos, F)); pos += F;
      const int y = fromBinary(S.substr(pos, E)); pos += E;
      mapa[h] = y;
    }
  }
  vector<int> ans(Q);
  for (int q = 0; q < Q; ++q) {
    ans[q] = mapa[myhash(Z[q])];
  }
  return ans;
}

int main() {
  int T;
  scanf("%d", &T);
  if (T == 1) {
    int N;
    scanf("%d", &N);
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d%d", &X[i], &Y[i]);
    }
    const string S = encode(N, X, Y);
    const int K = S.size();
    printf("%d\n", K);
    puts(S.c_str());
  } else {
    int N, Q, K;
    scanf("%d%d%d", &N, &Q, &K);
    char buf[6010];
    scanf("%s", buf);
    const string S = buf;
    vector<int> Z(Q);
    for (int q = 0; q < Q; ++q) {
      scanf("%d", &Z[q]);
    }
    const auto ans = decode(N, Q, K, S, Z);
    for (int q = 0; q < Q; ++q) {
      printf("%d\n", ans[q]);
    }
  }
  return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 50
Acceptable Answer
time: 1ms = 1ms + 0ms
memory: 3836kb,4036kb

input:

1
100
495528311 963488152
269613430 443544124
700489871 792354118
151890319 506569919
180452297 13229948
684464994 543841485
978085128 903812192
238355172 441140842
28061035 783291471
530823766 718942732
936853023 439421263
201361623 226633955
304644844 778868118
864860135 461524170
88300500 6959354...

output:

4500
0001111000110000001100110010101101101101001110111011000111010011110001001111111101100101100110000000101010110001010111010010111001111011001001110000001111110100100101100011000111101101110100101000011111011111011100100110000000111000101010101011001100111010010101100000010110010110110000000011000...

input:

2
100 79 4500
0001111000110000001100110010101101101101001110111011000111010011110001001111111101100101100110000000101010110001010111010010111001111011001001110000001111110100100101100011000111101101110100101000011111011111011100100110000000111000101010101011001100111010010101100000010110010110110000...

output:

310305144
821194635
174780370
903812192
805026231
996046536
439421263
645287342
90686849
20101025
440972097
543841485
176553522
249563964
461524170
348624865
848301562
506569919
306718453
206848250
382805509
278712030
964702808
868944393
493895143
39665197
574757075
441140842
785665865
229376884
551...

result:

points 0.50 ok K = 4500

Test #2:

score: 50
Acceptable Answer
time: 0ms = 0ms + 0ms
memory: 3756kb,3764kb

input:

1
100
743248071 842720888
367650901 130970775
297946283 705168964
771526942 537186020
245003150 707948455
643491261 668001146
311535032 293708068
183828318 18515526
593973840 915870006
102456762 64193833
729806890 839221652
47145974 35682954
668676377 228428310
370700393 569441954
250911162 48980047...

output:

4500
0011010010100100001111001100111010111000100111100000110010101110100100101110011100111110000110101111110110010001001100000000100000101010000100110100110010011101110011001000000000011001001101111001110010111110110010011000101010000100000011000101111011000111000010111110010000110111100110010010010...

input:

2
100 79 4500
0011010010100100001111001100111010111000100111100000110010101110100100101110011100111110000110101111110110010001001100000000100000101010000100110100110010011101110011001000000000011001001101111001110010111110110010011000101010000100000011000101111011000111000010111110010000110111100110...

output:

442563406
97578442
469403815
293708068
138158276
720700065
839221652
674386240
810209830
563527225
259979005
668001146
813899310
943777483
569441954
226088806
825435650
537186020
131383422
83733737
830289758
425793016
858146541
609883097
414389335
407054915
47572024
18515526
276587480
810627636
4972...

result:

points 0.50 ok K = 4500

Test #3:

score: 0
Wrong Answer
time: 0ms = 0ms + 0ms
memory: 3784kb,3764kb

input:

1
100
770174568 168127255
893508708 185778664
976425263 477317099
287595878 512153851
621600374 418802856
818787535 612197605
796811122 566496677
789841517 873731343
43178468 619503942
597852289 471053284
66112404 635260765
158101403 199253397
680158192 123081916
626776438 29107026
721141470 5177084...

output:

4500
1111001111111101110100011010110101000000101001011001010100010001011110000011010010001101000010000001101101101011111100010110011100011101011100010010111101111100011011011000010111100100010011111010001010100110110011011110001100101101000101111010011100100110101111100010010000110010110111010010110...

input:

2
100 79 4500
1111001111111101110100011010110101000000101001011001010100010001011110000011010010001101000010000001101101101011111100010110011100011101011100010010111101111100011011011000010111100100010011111010001010100110110011011110001100101101000101111010011100100110101111100010010000110010110111...

output:

676203467
418593456
222540092
566496677
487711174
155177230
278435153
19655934
405420089
197948311
16997620
612197605
623431791
654167214
29107026
103769907
951695033
512153851
401411177
839097490
141196222
886472586
767476542
270436089
885084406
492744649
861074271
873731343
744691837
300804222
364...

result:

wrong answer wrong answer on query #7: read 278435153 but expected 635260765