Submission #74651549


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define se second
#define fi first
#define pb push_back
#define pf push_front
#define ld long double
#define INF 1e18
#define lcm(x, y) x / __gcd(x, y) * y
#define Pair pair<ll, ll>
#define pii pair<int, int>
#define Pq priority_queue<ll>
#define Pqr priority_queue<ll, vector<ll>, greater<ll >>
#define clockst clock_t tStart = clock()
#define clockfin printf("Time taken: %.2fs\n",(double)(clock() - tStart)/CLOCKS_PER_SEC)
#define all(x) x.begin(), x.end()
#define sz(x)((ll)(x).size())
#define eb emplace_back
#define mp make_pair
#define mems(a, x) memset((a),(x), sizeof(a))
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,bmi,bmi2,fma")
typedef unsigned long long ull;
void init() { freopen("cf.INP", "r", stdin); freopen("cf.OUT", "w", stdout); }
ll xc[5] = { -1, 1, 0, 0 }, yc[5] = { 0, 0, 1, -1 };
ll xc8[8] = { -1, 1, 0, 0, -1, 1, -1, 1 };
ll yc8[8] = { 0, 0, 1, -1, -1, 1, 1, -1 };
const long double pi = acosl(-1.0L);
template<class T1, class T2> bool cmax(T1 &x, const T2 &y) { if(x < y) { x = y; return 1; } return 0; }

inline ll read()
{
    ll x = 0;
    char ch = getchar();;
    bool str = 1;
    while(ch < '0' || ch > '9')
    {
        if(ch == '-') str = 0; ch = getchar();;
    }
    while(ch >= '0' && ch <= '9')
    {
        x =((x << 3) +(x << 1)) + ch - '0';
        ch = getchar();;
    }
    return str ? x : x;
}

void solve()
{
    ll n, m;
    cin >> n;
    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
    cin >> m;
    vector<string> q(m);
    for (ll i = 0; i < m; i++) cin >> q[i];
    bool allow[11][26] = {0};
    for (const string& s : q)
    {
        ll len = s.size();
        for (ll i = 0; i < n; i++)
        {
            if (a[i] == len)
            {
                ll pos = b[i] - 1;
                char c = s[pos];
                allow[i + 1][c - 'a'] = 1;
            }
        }
    }

    for (const string& s : q)
    {
        if ((ll)s.size() != n)
        {
            cout << "No\n";
            continue;
        }
        bool ok = 1;
        for (ll i = 0; i < n; i++)
        {
            char c = s[i];
            if (!allow[i + 1][c - 'a'])
            {
                ok = 0;
                break;
            }
        }
        cout << (ok ? "Yes" : "No") << '\n';
    }
}

bool multest = 0;

int main()
{
    fast;
    ll t = 1;
    if(multest) cin >> t;
    while(t--) solve();
    return 0;
}

Submission Info

Submission Time
Task C - Fishbones
User khanhdang2109
Language C++23 (Clang 21.1.0)
Score 300
Code Size 2677 Byte
Status AC
Exec Time 65 ms
Memory 7760 KiB

Compile Error

./Main.cpp:59:27: warning: suggest braces around initialization of subobject [-Wmissing-braces]
   59 |     bool allow[11][26] = {0};
      |                           ^
      |                           {}
1 warning generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 25
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt
All 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 2 ms 2888 KiB
00-sample-02.txt AC 1 ms 2840 KiB
01-01.txt AC 7 ms 3348 KiB
01-02.txt AC 27 ms 5280 KiB
01-03.txt AC 47 ms 7272 KiB
01-04.txt AC 27 ms 5564 KiB
01-05.txt AC 37 ms 6424 KiB
01-06.txt AC 32 ms 5820 KiB
01-07.txt AC 61 ms 7540 KiB
01-08.txt AC 64 ms 7584 KiB
01-09.txt AC 7 ms 3644 KiB
01-10.txt AC 28 ms 5584 KiB
01-11.txt AC 7 ms 3664 KiB
01-12.txt AC 44 ms 7100 KiB
01-13.txt AC 32 ms 5820 KiB
01-14.txt AC 27 ms 5400 KiB
01-15.txt AC 62 ms 7624 KiB
01-16.txt AC 65 ms 7580 KiB
01-17.txt AC 64 ms 7740 KiB
01-18.txt AC 64 ms 7524 KiB
01-19.txt AC 64 ms 7740 KiB
01-20.txt AC 64 ms 7760 KiB
01-21.txt AC 64 ms 7704 KiB
01-22.txt AC 64 ms 7456 KiB
01-23.txt AC 64 ms 7612 KiB