제출 #1237531

#제출 시각아이디문제언어결과실행 시간메모리
1237531hainam2k9Osumnjičeni (COCI21_osumnjiceni)C++20
110 / 110
223 ms25720 KiB
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 2e5+5;
const string NAME = "";
int n,q,nxt[20][MAXN];
pair<int,int> p[MAXN];
set<pair<int,int>> s;
inline bool check(pair<int,int> p){
    auto it=s.lb(p);
    if(it!=s.end()&&p.se>=it->fi) return 0;
    if(it!=s.begin()&&prev(it)->se>=p.fi) return 0;
    return 1;
}
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    cin >> n;
    for(int i = 1; i<=n; ++i)
        cin >> p[i].fi >> p[i].se;
    for(int i=1, j=0; i<=n; ++i){
        if(j<i) j=i, s.clear(), s.ins(p[i].fi,p[i].se);
        else s.erase(mp(p[i-1].fi,p[i-1].se));
        while(j<n&&check(p[j+1])) ++j, s.ins(p[j].fi,p[j].se);
        nxt[0][i]=j+1;
    }
    for(int i = 1; i<=__lg(n); ++i)
        for(int j = 1; j<=n; ++j)
            nxt[i][j]=nxt[i-1][nxt[i-1][j]];
    cin >> q;
    while(q--){
        int l,r,rs=0;
        cin >> l >> r;
        for(int i = __lg(n); i>=0; --i){
            if(nxt[i][l]==0||nxt[i][l]>r) continue;
            l=nxt[i][l], rs|=1<<i;
        }
        cout << rs+1 << "\n";
    }
}

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

Main.cpp: In function 'int main()':
Main.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:34:45: note: in expansion of macro 'fo'
   34 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
Main.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:34:45: note: in expansion of macro 'fo'
   34 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#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...