結果
問題 | No.2759 Take Pictures, Elements? |
ユーザー | matcharate12 |
提出日時 | 2024-05-08 18:44:13 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,059 bytes |
コンパイル時間 | 948 ms |
コンパイル使用メモリ | 105,248 KB |
実行使用メモリ | 65,024 KB |
最終ジャッジ日時 | 2024-05-09 19:54:56 |
合計ジャッジ時間 | 3,554 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 172 ms
65,024 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | WA | - |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:65:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 65 | for(auto [nv,c] : G[v]){ | ^
ソースコード
//#include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <iomanip> #include <numeric> #include <cmath> #include <bit> #include <cstdint> #define rep(i,n) for(ll i = 0; i < n; i++) //[0,n) #define srep(i,a,b) for(ll i = a; i < b; i++) //[a,b) #define arep(i,a,b,d) for(ll i = a; i < b; i += d) #define all(A) (A).begin(),(A).end() #define rall(A) (A).rbegin(),(A).rend() #define pmt(A) next_permutation(all(A)) using namespace std; using ll = long long; using ull = unsigned long long; using pq = priority_queue<ll,vector<ll>,greater<ll>>; const ll inf = 1LL<<60; const int iinf = (int)1e9+1; const int mod9 = 998244353; const int mod1 = (int)1e9+7; struct Edge { int to; long long cost; int from; }; bool compe(const Edge &e,const Edge &e2){ return e.cost < e2.cost; } using Graph = vector<vector<int>>; using SGraph = vector<set<ll>>; template <class T> int siz(T& a){return (int)a.size();} ll squa(ll a){ return a*a; } double torad(double x){ return x*(acos(-1)/180.0); } ll cross(ll ax,ll ay,ll bx,ll by){ return ax*by-ay*bx; } ll mceil(ll a,ll b){ return (a+b-1)/b; } int main(){ int N,Q; cin >> N >> Q; vector<int> A(N),B(Q); rep(i,N) cin >> A[i]; rep(i,Q) cin >> B[i]; vector<vector<pair<int,int>>> G(N*Q+N+1); rep(j,Q){ rep(i,N){ G[j*N+i].emplace_back(j*N+i+1,1); G[j*N+i+1].emplace_back(j*N+i,1); } rep(i,N){ if(A[i] != B[j]) continue; if(j != Q-1) G[j*N+i].emplace_back((j+1)*N+i,0); else G[j*N+i].emplace_back(N*Q,0); } } vector<int> dist(N*Q+1,iinf); deque<int> D; D.push_back(0); dist[0] = 0; while(siz(D)){ int v = D.front(); D.pop_front(); for(auto [nv,c] : G[v]){ int d = dist[v]+c; if(d < dist[nv]){ dist[nv] = d; if(c) D.push_back(nv); else D.push_front(nv); } } } cout << dist[N*Q]; }