結果
| 問題 | No.2759 Take Pictures, Elements? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-08 18:44:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,059 bytes |
| 記録 | |
| コンパイル時間 | 987 ms |
| コンパイル使用メモリ | 102,484 KB |
| 実行使用メモリ | 64,832 KB |
| 最終ジャッジ日時 | 2025-06-20 13:16:08 |
| 合計ジャッジ時間 | 4,114 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 6 WA * 15 |
コンパイルメッセージ
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];
}