답안 #1012787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012787 2024-07-02T15:30:50 Z huutuan Spy 3 (JOI24_spy3) C++17
23 / 100
58 ms 6560 KB
#include "Aoi.h"

#include <bits/stdc++.h>

using namespace std;

#define int long long

namespace Aoi{
   const int N=1e4+10, M=2e4+10;
   int n, m;
   pair<pair<int, int>, int> edge[M];
   vector<int> g[N];
   int tr[N], f[N];
   void dijkstra(){
      memset(f, 0x3f, sizeof f);
      priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
      pq.emplace(f[0]=0, 0);
      while (pq.size()){
         int u=pq.top().second, d=pq.top().first;
         pq.pop();
         if (f[u]!=d) continue;
         for (int i:g[u]){
            int v=edge[i].first.first^edge[i].first.second^u;
            int w=edge[i].second;
            if (f[v]>d+w) pq.emplace(f[v]=d+w, v), tr[v]=i;
         }
      }
   }
   bool used[M];
   void trace(int u, vector<int> &ans){
      if (u==0) return;
      ans.push_back(tr[u]);
      return trace(edge[tr[u]].first.first^edge[tr[u]].first.second^u, ans);
   }
   string solve(int32_t _N, int32_t _M, int32_t Q, int32_t K, vector<int32_t> A,
                vector<int32_t> B, vector<long long> C,
                vector<int32_t> T, vector<int32_t> X){
      n=_N, m=_M;
      for (int i=0; i<m; ++i){
         edge[i]={{A[i], B[i]}, C[i]};
         g[A[i]].push_back(i);
         g[B[i]].push_back(i);
      }
      dijkstra();
      string ans;
      for (int i:T){
         string cur(K, '0');
         vector<int> path;
         trace(i, path);
         for (int j:path) used[j]=1;
         for (int j=0; j<K; ++j) cur[j]=used[X[j]]+'0';
         for (int j:path) used[j]=0;
         ans+=cur;
      }
      return ans;
   }
}

string aoi(int32_t N, int32_t M, int32_t Q, int32_t K, vector<int32_t> A,
           vector<int32_t> B, vector<long long> C,
           vector<int32_t> T, vector<int32_t> X) {
   return Aoi::solve(N, M, Q, K, A, B, C, T, X);
}
#include "Bitaro.h"

#include <bits/stdc++.h>

using namespace std;

#define int long long

namespace Bitaro{
   const int N=1e4+10, M=2e4+10, inf=1e18;
   int n, m, q, k;
   pair<pair<int, int>, int> edge[M];
   vector<int> g[N];
   int tr[N], f[N];
   void trace(int u, vector<int32_t> &ans){
      if (u==0) return;
      ans.push_back(tr[u]);
      return trace(edge[tr[u]].first.first^edge[tr[u]].first.second^u, ans);
   }
   void dijkstra(){
      memset(f, 0x3f, sizeof f);
      priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
      pq.emplace(f[0]=0, 0);
      while (pq.size()){
         int u=pq.top().second, d=pq.top().first;
         pq.pop();
         if (f[u]!=d) continue;
         for (int i:g[u]){
            int v=edge[i].first.first^edge[i].first.second^u;
            int w=edge[i].second;
            if (f[v]>d+w) pq.emplace(f[v]=d+w, v), tr[v]=i;
         }
      }
   }
   void solve(int32_t _N, int32_t _M, int32_t Q, int32_t K, vector<int32_t> A, vector<int32_t> B,
              vector<long long> C, vector<int32_t> T, vector<int32_t> X,
              string s){
      n=_N, m=_M, q=Q, k=K;
      for (int i=0; i<m; ++i){
         edge[i]={{A[i], B[i]}, C[i]};
         g[A[i]].push_back(i);
         g[B[i]].push_back(i);
      }
      for (int i=0; i<Q; ++i){
         string t=s.substr(i*K, K);
         vector<int> id;
         for (int j=0; j<K; ++j) if (t[j]=='1') edge[X[j]].second=0; else edge[X[j]].second=inf;
         dijkstra();
         vector<int32_t> ans;
         trace(T[i], ans);
         reverse(ans.begin(), ans.end());
         answer(ans);
      }
   }
}

void bitaro(int32_t N, int32_t M, int32_t Q, int32_t K, vector<int32_t> A, vector<int32_t> B,
            vector<long long> C, vector<int32_t> T, vector<int32_t> X,
            string s) {
   Bitaro::solve(N, M, Q, K, A, B, C, T, X, s);
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 14 ms 5264 KB Partially correct
2 Correct 1 ms 1292 KB Output is correct
3 Partially correct 35 ms 5308 KB Partially correct
4 Partially correct 33 ms 5020 KB Partially correct
5 Partially correct 36 ms 5308 KB Partially correct
6 Partially correct 38 ms 5308 KB Partially correct
7 Partially correct 28 ms 5512 KB Partially correct
8 Partially correct 27 ms 5528 KB Partially correct
9 Partially correct 31 ms 5164 KB Partially correct
10 Correct 15 ms 5392 KB Output is correct
11 Partially correct 31 ms 5580 KB Partially correct
12 Correct 36 ms 5308 KB Output is correct
13 Partially correct 36 ms 5304 KB Partially correct
14 Partially correct 33 ms 5496 KB Partially correct
15 Correct 34 ms 5372 KB Output is correct
16 Correct 14 ms 5300 KB Output is correct
17 Partially correct 58 ms 5480 KB Partially correct
18 Partially correct 54 ms 5352 KB Partially correct
19 Partially correct 36 ms 6304 KB Partially correct
20 Partially correct 30 ms 6380 KB Partially correct
21 Partially correct 37 ms 6392 KB Partially correct
22 Partially correct 48 ms 6364 KB Partially correct
23 Partially correct 36 ms 6352 KB Partially correct
24 Partially correct 48 ms 6432 KB Partially correct
25 Partially correct 38 ms 5172 KB Partially correct
26 Partially correct 37 ms 5204 KB Partially correct
27 Correct 0 ms 1296 KB Output is correct
28 Partially correct 30 ms 5552 KB Partially correct
29 Partially correct 15 ms 4112 KB Partially correct
30 Correct 32 ms 5900 KB Output is correct
31 Correct 22 ms 5824 KB Output is correct
32 Partially correct 36 ms 5892 KB Partially correct
33 Correct 37 ms 5464 KB Output is correct
34 Partially correct 45 ms 5812 KB Partially correct
35 Correct 30 ms 5816 KB Output is correct
36 Partially correct 32 ms 5900 KB Partially correct
37 Partially correct 10 ms 3592 KB Partially correct
38 Partially correct 22 ms 4260 KB Partially correct
39 Partially correct 18 ms 4312 KB Partially correct
40 Correct 8 ms 3856 KB Output is correct
41 Partially correct 47 ms 6096 KB Partially correct
42 Partially correct 31 ms 5984 KB Partially correct
43 Correct 50 ms 6240 KB Output is correct
44 Correct 18 ms 5956 KB Output is correct
45 Partially correct 10 ms 3340 KB Partially correct
46 Partially correct 12 ms 3856 KB Partially correct
47 Correct 17 ms 3856 KB Output is correct
48 Correct 0 ms 1292 KB Output is correct
49 Correct 1 ms 1300 KB Output is correct
50 Partially correct 10 ms 5348 KB Partially correct
51 Partially correct 2 ms 1808 KB Partially correct
52 Partially correct 2 ms 1292 KB Partially correct
53 Partially correct 13 ms 5400 KB Partially correct
54 Partially correct 9 ms 3852 KB Partially correct
55 Partially correct 25 ms 4356 KB Partially correct
56 Partially correct 21 ms 5812 KB Partially correct
57 Partially correct 35 ms 6160 KB Partially correct
58 Partially correct 27 ms 4828 KB Partially correct
59 Partially correct 41 ms 6552 KB Partially correct
60 Partially correct 33 ms 6128 KB Partially correct
61 Partially correct 44 ms 6028 KB Partially correct
62 Partially correct 40 ms 5860 KB Partially correct
63 Partially correct 49 ms 5980 KB Partially correct
64 Correct 15 ms 5392 KB Output is correct
65 Partially correct 24 ms 4596 KB Partially correct
66 Partially correct 20 ms 6560 KB Partially correct
67 Partially correct 24 ms 4564 KB Partially correct
68 Partially correct 21 ms 6500 KB Partially correct
69 Correct 1 ms 1292 KB Output is correct
70 Correct 0 ms 1292 KB Output is correct
71 Correct 2 ms 1292 KB Output is correct
72 Partially correct 12 ms 3332 KB Partially correct
73 Partially correct 28 ms 3828 KB Partially correct
74 Partially correct 23 ms 3856 KB Partially correct
75 Correct 8 ms 3864 KB Output is correct
76 Correct 1 ms 1292 KB Output is correct
77 Correct 27 ms 5300 KB Output is correct
78 Partially correct 24 ms 5488 KB Partially correct
79 Correct 28 ms 5484 KB Output is correct
80 Correct 0 ms 1292 KB Output is correct
81 Partially correct 32 ms 5300 KB Partially correct
82 Partially correct 31 ms 5544 KB Partially correct
83 Partially correct 35 ms 5508 KB Partially correct