Submission #958652

# Submission time Handle Problem Language Result Execution time Memory
958652 2024-04-06T09:45:18 Z Mher777 Trading (IZhO13_trading) C++17
0 / 100
1 ms 2392 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int N = 100005;

int n, m, a[4][N], dp[N][(1 << 2) + 4], msk[N];

int main()
{
    cin >> n >> m;
    while (m--)
    {
        int y, x;
        scanf("%d%d", &x, &y);
        y--;
        msk[x] |= (1 << y);
    }
    dp[0][3] = 1;
    for (int i = 0; i <= n; i++)
    {
        for (int mask = 0; mask < (1 << 2); mask++)
        {
            if ((mask & msk[i]) != msk[i])
                continue;
            //cout << "dp[" << i << "][" << mask << "]=" << dp[i][mask] << endl;
            for (int nxt = 0; nxt < (1 << 2); nxt++)
            {
                if ((nxt & msk[i + 1]) != msk[i + 1])
                    continue;
                LL x = 1;
                for (int j = 0; j <= 1; j++)
                {
                    int bit1 = (bool)(mask & (1 << j));
                    int bit2 = (bool)(nxt & (1 << j));
                    if (bit1 == 0 && (bit2 == 0 || ((1 << j) & msk[i + 1]) != 0))
                        x = 0;
                }
                dp[i + 1][nxt] += (x * dp[i][mask]) % mod;
                dp[i + 1][nxt] %= mod;
            }
        }
        if (msk[i + 1] == 0)
        {
            dp[i + 1][3] += dp[i][3];
            dp[i + 1][3] %= mod;
        }
    }
    cout << dp[n][3] << endl;
    return 0;
}

/*



 
*/

Compilation message

trading.cpp: In function 'int main()':
trading.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%d%d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -