QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528971#1350. Mango36champWA 0ms3624kbC++203.1kb2024-08-24 05:12:022024-08-24 05:12:03

Judging History

你现在查看的是最新测评结果

  • [2024-08-24 05:12:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-08-24 05:12:02]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

void query1(ll l, ll r, ll n, string &a, vector<string> &str)
{
    if(str[0].size() != 0 && l <= n * (ll) str[0].size())
    {
        for(ll i = l; i <= min(n * (ll) str[0].size(), r); i++) cout << str[0][(i - 1) % str[0].size()];
    }

    l = max(1LL, l - n * (ll) str[0].size());
    r -= n * (ll) str[0].size();

    if(r <= 0) return;

    for(ll i = l; i <= min((ll) a.size(), r); i++) cout << a[i - 1];
    l = max(1LL, l - (ll) a.size());
    r -= a.size();

    if(r <= 0) return;

    for(ll i = l; i <= min(n * (ll) str[1].size(), r); i++) cout << str[1][(i - 1) % str[1].size()];
}

void query(ll l, ll r, ll n, string &a, vector<string> &str, vector<ll> &len)
{
    //cout << "Q " << l << " " << r << " " << n << "\n";
    if(l > r || l < 1 || r < 1) return;

    if(n == 0)
    {
        for(ll i = l; i <= r; i++) cout << a[i - 1];
        return;
    }

    if(n > (ll) len.size())
    {
        for(ll i = l; i <= min((ll) (n - len.size()) * (ll) str[0].size(), r); i++)
        {
            cout << str[0][(i - 1) % str[0].size()];
        }

        return query(max(1LL, l - (ll) (n - len.size()) * (ll) str[0].size()), r - (ll) (n - len.size()) * (ll) str[0].size(), len.size(), a, str, len);
    }

    for(int j = 0; j < (ll) str.size(); j++)
    {
        if(l <= (ll) str[j].size())
        {
            //cout << "! " << j << " " << l << " " << str[j].size() << " " << min(l + (ll) str[j].size() - 1, r) << "\n";
            for(ll i = l; i <= min((ll) str[j].size(), r); i++) cout << str[j][i - 1];
        }
        l = max(1LL, l - (ll) str[j].size());
        r -= (ll) str[j].size();

        if(r <= 0) return;

        if(l <= len[n - 1]) query(l, min(len[n - 1], r), n - 1, a, str, len);

        l = max(1LL, l - len[n - 1]);
        r -= len[n - 1];

        if(r <= 0) return;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	string a, s;
	cin >> a >> s;

    ll n, q;
    cin >> n >> q;

    ll cnt = 0;
    for(char c: s) if(c == '$') cnt++;

    vector<string> str;
    string now;
    for(char c: s)
    {
        if(c == '$')
        {
            str.pb(now);
            now = "";
            continue;
        }

        now += c;
    }
    str.pb(now);

    /*for(string x: str) cout << x << " ";
    cout << "\n";

    for(string x: str) cout << x.size() << " ";
    cout << "\n";*/

    //cout << cnt << "\n";

    ll l = a.size();
    vector<ll> len;
    for(int i=0; i<n; i++)
    {
        len.pb(l);

        if(l - 1 > (1LL<<60) / cnt) break;
        l = (l - 1) * cnt;

        if(l < 1LL<<60 - (ll) s.size()) break;
        l += s.size();
    }

    /*for(ll l: len) cout << l << " ";
    cout << "\n";*/

    while(q-->0)
    {
        ll l, r;
        cin >> l >> r;

        if(cnt == 1) query1(l, r, n, a, str);
        else query(l, r, n, a, str, len);
        cout << "\n";
    }
}
/*
It's_a_cat,_not_a_mango
It's_"$",_not_"$"
1 6
1 20
18 35
49 61
29 40
41 50
5 5
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

It's_a_cat,_not_a_mango
It's_"$",_not_"$"
1 6
1 20
18 35
49 61
29 40
41 50
5 5

output:

It's_"It's_a_cat,_no
_not_a_mango",_not
_not_a_mango"
o",_not_"It'
s_a_cat,_n
_

result:

ok 6 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

Ad_finitum
$
100000 4
1 10
1 2
4 10
5 8

output:

Ad_finitum
Ad
finitum
init

result:

ok 4 tokens

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3624kb

input:

THE_END
$_IS_NEVER_$_IS_NEVER_$
88 5
1 7
3256 3257
67706 67710
111011 111017
999999999999999968 999999999999999993

output:

THE_END





result:

wrong answer Unexpected EOF in the participants output