제출 #1237283

#제출 시각아이디문제언어결과실행 시간메모리
1237283alexandrosOsumnjičeni (COCI21_osumnjiceni)C++20
0 / 110
67 ms424 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll add(ll big)
{
    if(big == 0) return 0;
    if(big == 1) return 1;
    else return (ll)ceil(log2(big));
}

bool overlaps(ll l1, ll r1, ll l2, ll r2)
{
    return max(l1, l2) <= min(r1, r2);
}

bool hasOverlap(const vector<pair<ll, ll>>& intervals, ll newL, ll newR)
{
    for (const auto& [l, r] : intervals)
    {
        if (overlaps(l, r, newL, newR)) return true;
    }
    return false;
}

vector<bool> vec;
vector<pair<ll, ll>> sofar(0);

int main() {
    ll amount, amountq, temp, temp2, l, r, output, count;
    scanf("%lld", &amount);
    vec.assign(amount, false);
    for(int i = 0; i < amount; i++)
    {
        scanf("%lld %lld", &temp, &temp2);
        if(hasOverlap(sofar, temp, temp2))
        {
            vec[i] = true;
            sofar.clear();
        }
        else
        {
            sofar.push_back({temp, temp2});
        }
    }
    scanf("%lld", &amountq);
    for(int q = 0; q < amountq; q++)
    {
        scanf("%lld %lld", &l, &r);
        l--;
        r--;
        count = 0;
        output = 0;
        for(int i = l; i <= r; i++)
        {
            if(vec[i])
            {
                output += add(count);
                count = 0;
            }
            count++;
        }
        output += add(count);
        if(count == r - l + 1) printf("1\n");
        else printf("%lld\n", output);
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%lld", &amount);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         scanf("%lld %lld", &temp, &temp2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     scanf("%lld", &amountq);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         scanf("%lld %lld", &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...