Submission #1267659

#TimeUsernameProblemLanguageResultExecution timeMemory
1267659alexandrosModern Machine (JOI23_ho_t5)C++20
3 / 100
3095 ms1352 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector<char> tiles;
vector<char> tilest;
vector<ll> buttons;

int main() {
    ll amount, amountB, amountQ;
    char temp;
    ll temp2, start, end, ball, button, p, reds, redso = 0;
    scanf("%lld %lld", &amount, &amountB);
    tiles.reserve(amount);
    for(int i = 0; i < amount; i++)
    {
        scanf(" %c", &temp);
        tiles.push_back(temp);
        if(temp == 'R') redso++;
    }
    buttons.reserve(amountB);
    for(int i = 0; i < amountB; i++)
    {
        scanf("%lld", &temp2);
        buttons.push_back(temp2);
    }
    scanf("%lld", &amountQ);
    for(int q = 0; q < amountQ; q++)
    {
        scanf("%lld %lld", &start, &end);
        tilest = tiles;
        reds = redso;
        for(int i = start; i <= end; i++)
        {
            button = buttons[i-1] - 1;
            ball = button;
            if(tilest[button] == 'B') reds++;
            tilest[button] = 'R';
            while(true)
            {
                p = ball;
                if(tilest[p] == 'B')
                {
                    reds++;
                    tilest[p] = 'R';
                    if(p == 0) 
                    {
                        break;
                    }
                    else ball--;
                }
                else
                {
                    reds--;
                    tilest[p] = 'B';
                    if(p == amount-1) 
                    {
                        break;
                    }
                    else ball++;
                }
            }
        }
        printf("%lld\n", reds);
    }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%lld %lld", &amount, &amountB);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf(" %c", &temp);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf("%lld", &temp2);
      |         ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%lld", &amountQ);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf("%lld %lld", &start, &end);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...