45202023-03-29 12:12:24gortomiTrükkcpp17Wrong answer 0/60112ms13256 KiB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
void solve()
{
    int n, k;
    cin >> n >> k;
    vector<set<pair<int, int> > > s(n + 2);
    for(int i = 0; i < k; i++)
    {
        int l, r;
        cin >> l >> r;
        s[l].insert({r, 0});
    }
    int db = k;
    for(int i = 1; i <= n; i++)
    {
        for(auto it = s[i].begin(); it != s[i].end(); it++)
        {
            int x = it -> first, type = it -> second;
            auto nxt = it;
            nxt++;
            if(nxt == s[i].end()) break;
            int n_x = nxt -> first, n_type = nxt -> second;
            if(x == n_x)
            {
                if((type == 0 && n_type == 1) || (type == 1 && n_type == 2))
                {
                    cout << "0\n";
                    return;
                }
                if(type == 0 && n_type == 2)
                {
                    db--;
                }
            }
            else
            {
                if(type > n_type) swap(type, n_type);
                if((type == 0 && n_type == 2) || (type == 0 && n_type == 0) || (type == 2 && n_type == 2))
                {
                    s[x + 1].insert({n_x, 1});
                }
                if(type == 1 && n_type == 1)
                {
                    s[x + 1].insert({n_x, 1});
                }
                if((type == 0 && n_type == 1) || (type == 1 && n_type == 2))
                {
                    s[x + 1].insert({n_x, 2});
                }
            }
        }
    }
    int ans = 1;
    for(int i = 0; i < n - db; i++)
    {
        ans <<= 1;
        ans %= MOD;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) solve();
}
SubtaskSumTestVerdictTimeMemory
base0/60
1Accepted0/03ms1824 KiB
2Wrong answer0/037ms5668 KiB
3Wrong answer0/33ms2280 KiB
4Wrong answer0/33ms2496 KiB
5Wrong answer0/33ms2692 KiB
6Wrong answer0/33ms2864 KiB
7Wrong answer0/286ms10152 KiB
8Wrong answer0/264ms10112 KiB
9Wrong answer0/264ms10284 KiB
10Wrong answer0/278ms9720 KiB
11Wrong answer0/261ms9800 KiB
12Wrong answer0/259ms9924 KiB
13Wrong answer0/264ms8180 KiB
14Wrong answer0/261ms8188 KiB
15Wrong answer0/261ms7948 KiB
16Wrong answer0/270ms8756 KiB
17Wrong answer0/270ms8700 KiB
18Wrong answer0/268ms9060 KiB
19Wrong answer0/2112ms13256 KiB
20Wrong answer0/275ms13124 KiB
21Wrong answer0/294ms13052 KiB
22Wrong answer0/272ms12176 KiB
23Wrong answer0/263ms12288 KiB
24Wrong answer0/259ms12568 KiB
25Wrong answer0/259ms12832 KiB
26Wrong answer0/250ms9752 KiB
27Wrong answer0/264ms12284 KiB
28Wrong answer0/246ms9120 KiB
29Wrong answer0/228ms7720 KiB
30Wrong answer0/226ms7692 KiB