Submission #36194066
Source Code Expand
#include <bits/stdc++.h>
namespace // to fold that junk code
{
#define filein(x) {freopen(x".in", "r", stdin);}
#define file(x) {freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);}
#define files(x) {freopen(x".in", "r", stdin); freopen(x".ans", "w", stdout);}
#define mem(x, a) memset(x, a, sizeof x);
#define cls(x) mem(x, 0)
using namespace std;
#define cT const T&
template<typename T>
inline T chkmin(T& x, cT y){if (x > y) x = y; return x;}
template<typename T>
inline T chkmax(T& x, cT y){if (x < y) x = y; return x;}
template <typename T>
inline bool inrange(cT x, cT l, cT r){return (l <= x) && (x <= r);}
template <typename T>
inline bool inrange(cT l, cT r, cT L, cT R){return (L <= l) && (r <= R);}
template <typename T>
inline bool separate(cT l, cT r, cT L, cT R){return (R < l) || (L > r);}
template <typename T>
inline T sqr(cT _){return _ * _;}
template <typename T>
inline T read(){T x; cin >> x; return x;}
template <typename T1, typename T2>
inline pair<T1, T2> read(){T1 x; T2 y; cin >> x >> y; return make_pair(x, y);}
template <typename T>
inline void clear(T& q){typename remove_reference<decltype(q)> :: type _; swap(q, _);} // remove_reference_t is since C++14
#undef cT
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template <typename T>
using pr = pair<T, T>;
template <typename T>
using maxheap = priority_queue<T>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T1, typename T2 = unsigned>
using umap = unordered_map<T1, T2>;
template <typename T1, typename T2 = unsigned>
using uset = unordered_set<T1, T2>;
typedef pr<int> pii;
typedef pr<ll> pll;
typedef pr<db> pdd;
typedef complex<double> cp;
typedef vector<int> vi;
inline void YN(bool x){puts(x ? "Yes" : "No");}
}
const int N = (1 << 18) + 233, P = 998244353;
inline void fstmod(int& x){if (x >= P) x -= P;}
struct matrix
{
int a[2][2];
matrix(int a=0, int b=0, int c=0, int d=0) : a{{a,b},{c,d}}{}
int* operator[](const int& i){return a[i];}
const int* operator[](const int& i) const {return a[i];}
inline matrix operator * (const matrix& rhs) const
{
matrix ans;
for (int i=0; i<2; i++)
for (int k=0; k<2; k++)
for (int j=0; j<2; j++) fstmod(ans[i][j] += 1ll * a[i][k] * rhs[k][j] % P);
return ans;
}
inline matrix& operator *= (const matrix rhs){return *this = *this * rhs;}
}M[2]{matrix(1, 0, 1, 1), matrix(1, 1, 0, 1)}, id(1, 0, 0, 1);
int n, q, a[N];
vi v[N];
int main()
{
scanf("%d%d", &n, &q); int m = 1 << n;
for (int i=0; i<m; i++) scanf("%d", a+i);
for (int i=1, x, y; i<=q; i++){scanf("%d%d", &x, &y); v[x].emplace_back(y);}
for (int i=0; i<n; i++) reverse(v[i].begin(), v[i].end());
for (int i=0; i<n; i++)
{
matrix now(id);
for (int x : v[i]) now *= M[x];
for (int j=0; j<m; j++)
if (j >> i & 1)
{
matrix tmp(a[j ^ (1 << i)], 0, a[j], 0); tmp = now * tmp;
a[j ^ (1 << i)] = tmp[0][0]; a[j] = tmp[1][0];
}
}
for (int i=0; i<m; i++) printf("%d ", a[i]);
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:73:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
73 | scanf("%d%d", &n, &q); int m = 1 << n;
| ~~~~~^~~~~~~~~~~~~~~~
./Main.cpp:74:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
74 | for (int i=0; i<m; i++) scanf("%d", a+i);
| ~~~~~^~~~~~~~~~~
./Main.cpp:75:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
75 | for (int i=1, x, y; i<=q; i++){scanf("%d%d", &x, &y); v[x].emplace_back(y);}
| ~~~~~^~~~~~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
700 / 700 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example0.txt, example1.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, example0.txt, example1.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 000.txt |
AC |
40 ms |
10376 KiB |
| 001.txt |
AC |
82 ms |
11588 KiB |
| 002.txt |
AC |
95 ms |
11296 KiB |
| 003.txt |
AC |
94 ms |
11896 KiB |
| 004.txt |
AC |
94 ms |
11340 KiB |
| 005.txt |
AC |
33 ms |
10376 KiB |
| 006.txt |
AC |
19 ms |
10164 KiB |
| 007.txt |
AC |
20 ms |
10116 KiB |
| 008.txt |
AC |
14 ms |
10076 KiB |
| 009.txt |
AC |
17 ms |
10056 KiB |
| 010.txt |
AC |
58 ms |
10820 KiB |
| 011.txt |
AC |
14 ms |
9916 KiB |
| 012.txt |
AC |
49 ms |
10576 KiB |
| 013.txt |
AC |
18 ms |
9948 KiB |
| 014.txt |
AC |
90 ms |
11564 KiB |
| 015.txt |
AC |
95 ms |
11492 KiB |
| 016.txt |
AC |
95 ms |
11764 KiB |
| 017.txt |
AC |
95 ms |
11628 KiB |
| 018.txt |
AC |
95 ms |
11624 KiB |
| 019.txt |
AC |
94 ms |
11636 KiB |
| 020.txt |
AC |
95 ms |
11812 KiB |
| 021.txt |
AC |
94 ms |
11672 KiB |
| 022.txt |
AC |
94 ms |
11580 KiB |
| 023.txt |
AC |
95 ms |
11684 KiB |
| 024.txt |
AC |
93 ms |
11612 KiB |
| example0.txt |
AC |
9 ms |
9836 KiB |
| example1.txt |
AC |
7 ms |
9884 KiB |