Submission #64451342


Source Code Expand

// Author: Mkswll
// Date: 2025-04-02 23:50:43
// Problem: A - Twice Subsequence
// Contest: AtCoder - AtCoder Regular Contest 195 (Div. 2)
// URL: https://atcoder.jp/contests/arc195/tasks/arc195_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

// I will become better someday.

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;
#define debug(x) cout << '[' << #x << ": " << x << "] "
#define cio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define cases int _; cin >> _; while(_--)
#define pb push_back
#define eb emplace_back
#define space << " " <<
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Unique(v) v.erase(unique(all(v)), v.end())
#define mset(x) memset(x, 0, sizeof(x))
#define sflush fflush(stdout)
#define cflush cout.flush()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define lyes cout << "Yes\n"
#define lno cout << "No\n"
#define nl cout << "\n";
#define vt vector
#define ar array
#define uid uniform_int_distribution 

template <typename T> 
istream& operator >> (istream& in, vector<T>& a){
	for(auto &x : a) in >> x; 
	return in;
}

template <typename T> 
ostream& operator << (ostream& out, vector<T>& a){
	for(auto &x : a) out << x << ' '; 
	return out;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

ll read(){
    int w = 1, c;
    ll ret;
    while((c = getchar()) > '9' || c < '0'){
        w = (c == '-' ? -1 : 1);
    }
    ret = c - '0';
    while((c = getchar()) >= '0' && c <= '9'){
        ret = ret * 10 + c - '0';
    }
    return ret * w;
}

ll rd(){
	ll in;
	cin >> in;
	return in;
}
 
void write(ll x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9){
        write(x / 10);
    }
    putchar(x % 10 + '0');
}

const int MAXN = 3e5 + 5, MAXM = 2e5 + 5, INF = 1e9 + 5, MOD = 1e9 + 7;
const ll LMOD = (ll) 1e18 + 9;
const ll LINF = 1e18 + 5;
const ld ep = 1e-8, Pi = acos(-1.0);

int n, m, k, x; 
int a[MAXN], b[MAXN];
string s;

int l[MAXN], r[MAXN];


void clear(){
    
}

int main(){
    cio;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
    	cin >> a[i];
    }
    for(int i = 1; i <= m; ++i){
    	cin >> b[i];
    }
    {
    	int ptr = 1;
    	for(int i = 1; i <= n; ++i){
    		if(a[i] == b[ptr]){
    			l[ptr] = i;
    			++ptr;
    		}
    		if(ptr > m) break;
    	}
    }
    {
    	int ptr = m;
    	for(int i = n; i >= 1; --i){
    		if(a[i] == b[ptr]){
    			r[ptr] = i;
    			--ptr;
    		}
    		if(!ptr) break;
    	}
    }
    if(!l[m]){
    	lno;
    	return 0;
    }
    for(int i = 1; i <= m; ++i){
    	if(l[i] != r[i]){
    		lyes;
    		return 0;
    	}
    }
    lno;
    return 0;
}   

Submission Info

Submission Time
Task A - Twice Subsequence
User Mkswll
Language C++ 20 (gcc 12.2)
Score 400
Code Size 3261 Byte
Status AC
Exec Time 23 ms
Memory 6652 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 48
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 03_medium_01.txt, 03_medium_02.txt, 03_medium_03.txt, 03_medium_04.txt, 03_medium_05.txt, 04_large_01.txt, 04_large_02.txt, 04_large_03.txt, 04_large_04.txt, 04_large_05.txt, 05_max_01.txt, 05_max_02.txt, 05_max_03.txt, 05_max_04.txt, 05_max_05.txt, 06_not_emerge_01.txt, 06_not_emerge_02.txt, 06_not_emerge_03.txt, 07_emerge_once_01.txt, 07_emerge_once_02.txt, 07_emerge_once_03.txt, 07_emerge_once_04.txt, 07_emerge_once_05.txt, 08_emerge_twice_01.txt, 08_emerge_twice_02.txt, 08_emerge_twice_03.txt, 08_emerge_twice_04.txt, 08_emerge_twice_05.txt, 09_one_two_only_01.txt, 09_one_two_only_02.txt, 09_one_two_only_03.txt, 09_one_two_only_04.txt, 09_one_two_only_05.txt, 09_one_two_only_06.txt, 09_one_two_only_07.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3628 KiB
00_sample_02.txt AC 1 ms 3568 KiB
00_sample_03.txt AC 1 ms 3480 KiB
01_handmade_01.txt AC 1 ms 3500 KiB
01_handmade_02.txt AC 23 ms 6620 KiB
01_handmade_03.txt AC 13 ms 6616 KiB
01_handmade_04.txt AC 12 ms 5836 KiB
01_handmade_05.txt AC 12 ms 5828 KiB
02_small_01.txt AC 1 ms 3492 KiB
02_small_02.txt AC 1 ms 3492 KiB
02_small_03.txt AC 1 ms 3496 KiB
02_small_04.txt AC 1 ms 3488 KiB
02_small_05.txt AC 1 ms 3624 KiB
03_medium_01.txt AC 1 ms 3484 KiB
03_medium_02.txt AC 1 ms 3476 KiB
03_medium_03.txt AC 1 ms 3496 KiB
03_medium_04.txt AC 1 ms 3500 KiB
03_medium_05.txt AC 1 ms 3504 KiB
04_large_01.txt AC 4 ms 3788 KiB
04_large_02.txt AC 17 ms 5732 KiB
04_large_03.txt AC 21 ms 6504 KiB
04_large_04.txt AC 9 ms 4572 KiB
04_large_05.txt AC 16 ms 5488 KiB
05_max_01.txt AC 22 ms 6628 KiB
05_max_02.txt AC 22 ms 6624 KiB
05_max_03.txt AC 22 ms 6604 KiB
05_max_04.txt AC 22 ms 6612 KiB
05_max_05.txt AC 22 ms 6652 KiB
06_not_emerge_01.txt AC 12 ms 4376 KiB
06_not_emerge_02.txt AC 12 ms 4188 KiB
06_not_emerge_03.txt AC 12 ms 4352 KiB
07_emerge_once_01.txt AC 16 ms 4980 KiB
07_emerge_once_02.txt AC 22 ms 6580 KiB
07_emerge_once_03.txt AC 20 ms 5756 KiB
07_emerge_once_04.txt AC 22 ms 6532 KiB
07_emerge_once_05.txt AC 12 ms 4280 KiB
08_emerge_twice_01.txt AC 15 ms 4872 KiB
08_emerge_twice_02.txt AC 21 ms 6128 KiB
08_emerge_twice_03.txt AC 21 ms 5728 KiB
08_emerge_twice_04.txt AC 19 ms 5628 KiB
08_emerge_twice_05.txt AC 20 ms 5728 KiB
09_one_two_only_01.txt AC 11 ms 5448 KiB
09_one_two_only_02.txt AC 11 ms 5436 KiB
09_one_two_only_03.txt AC 11 ms 5364 KiB
09_one_two_only_04.txt AC 10 ms 5204 KiB
09_one_two_only_05.txt AC 13 ms 5592 KiB
09_one_two_only_06.txt AC 8 ms 4448 KiB
09_one_two_only_07.txt AC 11 ms 5560 KiB