QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#454565 | #8821. Nightmare | hos_lyric | RE | 578ms | 12528kb | C++14 | 9.4kb | 2024-06-25 04:13:04 | 2024-06-25 04:13:04 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
////////////////////////////////////////////////////////////////////////////////
// Barrett
struct ModInt {
static unsigned M;
static unsigned long long NEG_INV_M;
static void setM(unsigned m) { M = m; NEG_INV_M = -1ULL / M; }
unsigned x;
ModInt() : x(0U) {}
ModInt(unsigned x_) : x(x_ % M) {}
ModInt(unsigned long long x_) : x(x_ % M) {}
ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
ModInt &operator*=(const ModInt &a) {
const unsigned long long y = static_cast<unsigned long long>(x) * a.x;
const unsigned long long q = static_cast<unsigned long long>((static_cast<unsigned __int128>(NEG_INV_M) * y) >> 64);
const unsigned long long r = y - M * q;
x = r - M * (r >= M);
return *this;
}
ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
ModInt pow(long long e) const {
if (e < 0) return inv().pow(-e);
ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
}
ModInt inv() const {
unsigned a = M, b = x; int y = 0, z = 1;
for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
assert(a == 1U); return ModInt(y);
}
ModInt operator+() const { return *this; }
ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
explicit operator bool() const { return x; }
bool operator==(const ModInt &a) const { return (x == a.x); }
bool operator!=(const ModInt &a) const { return (x != a.x); }
friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
unsigned ModInt::M;
unsigned long long ModInt::NEG_INV_M;
// !!!Use ModInt::setM!!!
////////////////////////////////////////////////////////////////////////////////
using Mint = ModInt;
int N, P;
Mint G[510][510];
Mint g[510][510];
Mint ans[510][510];
struct Op {
int typ;
int i, j;
Mint c;
};
vector<Op> ops;
// swap(v[i], v[j]);
void sw(int i, int j) {
// cerr<<COLOR("94")<<"sw "<<i<<" "<<j<<COLOR()<<endl;
ops.push_back(Op{0, i, j, 0});
swap(g[i][i], g[j][j]);
for (int k = 0; k < N; ++k) if (i != k && j != k) {
swap(g[i][k], g[j][k]);
swap(g[k][i], g[k][j]);
}
}
// v[i] += c v[j]
void add(int i, int j, Mint c) {
// cerr<<COLOR("91")<<"add "<<i<<" "<<j<<" "<<c<<COLOR()<<endl;
assert(i != j);
ops.push_back(Op{1, i, j, c});
for (int k = 0; k < N; ++k) if (i != k && j != k) {
g[i][k] += c * g[j][k];
g[k][i] += c * g[k][j];
}
g[i][i] += c * g[i][j];
g[i][i] += c * g[j][i];
g[i][i] += c * c * g[j][j];
g[i][j] += c * g[j][j];
g[j][i] += c * g[j][j];
}
int main() {
for (; ~scanf("%d%d", &N, &P); ) {
Mint::setM(P);
memset(G, 0, sizeof(G));
for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
scanf("%u", &G[i][j].x);
}
#ifdef LOCAL
cerr<<string(80,'=')<<" N = "<<N<<", P = "<<P<<endl;
#endif
vector<int> sqr(P, -1);
for (int x = 0; x < P; ++x) {
const int y = (Mint(x) * Mint(x)).x;
if (!~sqr[y]) sqr[y] = x;
}
// z^2 + 1: quad. non-residue
Mint z = 0;
for (int x = 0; x < P; ++x) {
const int y = (Mint(x) * Mint(x) + 1).x;
if (!~sqr[y]) {
z = x;
break;
}
}
const int N0 = N;
for (; ; ) {
memcpy(g, G, sizeof(G));
memset(ans, 0, sizeof(ans));
ops.clear();
int h = 0;
for (; ; ) {
#ifdef LOCAL
cerr<<__LINE__<<": h = "<<h<<endl;for(int i=0;i<N;++i)pv(g[i],g[i]+N);
#endif
for (int i = h; i < N; ++i) {
if (g[i][i]) {
sw(h, i);
break;
}
}
if (h < N && g[h][h]) {
const Mint s = g[h][h].inv();
for (int i = h + 1; i < N; ++i) {
add(i, h, -s * g[h][i]);
}
h += 1;
continue;
}
for (int i = h; i < N; ++i) {
for (int j = i + 1; j < N; ++j) {
if (g[i][j]) {
sw(h, i);
sw(h + 1, j);
goto found2;
}
}
}
found2:{}
if (h + 1 < N && g[h][h + 1]) {
if (P == 2) {
if (h) {
/*
v0, v1, v2
100
001
010
v0 + v1 + v2, v0 + v1, v0 + v2
100
010
001
*/
add(h, h - 1, 1);
add(h + 1, h - 1, 1);
add(h - 1, h, 1);
add(h - 1, h + 1, 1);
h -= 1;
} else {
/*
similarly to diagonalization:
01
10
...
01
10
need 1 more because:
det(v v^T) = det(G) = 1
==> v: regular
==> (1,0,...,0) = \sum[i \in I] v[i]
==> norm is 1 = 0
*/
G[N][N] = 1;
++N;
goto failed;
}
} else {
add(h, h + 1, 1);
}
continue;
}
break;
}
assert(h);
{
Mint det = 1;
for (int i = 0; i < h; ++i) det *= g[i][i];
if (!~sqr[det.x]) {
/*
need 1 more because:
det(G) = det(v v^T) = det(v)^2 must be quad. residue
*/
G[N][N] = det;
++N;
goto failed;
}
}
for (int i = h - 1; i >= 0; ) {
if (~sqr[g[i][i].x]) {
ans[i][i] = sqr[g[i][i].x];
i -= 1;
} else {
for (int j = i; --j >= 0; ) {
if (~sqr[(g[j][j] * g[i][i]).x]) {
ans[j][j] = z;
ans[j][i] = -1;
ans[i][j] = 1;
ans[i][i] = z;
for (const int k : {j, i}) {
const Mint c = sqr[(g[k][k] / (z*z+1)).x];
ans[k][j] *= c;
ans[k][i] *= c;
}
i -= 2;
goto foundPair;
}
}
assert(false);
foundPair:{}
}
}
reverse(ops.begin(), ops.end());
for (const Op &op : ops) {
if (op.typ == 0) {
for (int k = 0; k < h; ++k) swap(ans[op.i][k], ans[op.j][k]);
} else if (op.typ == 1) {
for (int k = 0; k < h; ++k) ans[op.i][k] -= op.c * ans[op.j][k];
} else {
assert(false);
}
}
printf("%d\n", h);
for (int i = 0; i < N0; ++i) {
for (int k = 0; k < h; ++k) {
if (k) printf(" ");
printf("%u", ans[i][k].x);
}
puts("");
}
#ifdef LOCAL
for(int i=N0;i<N;++i){cerr<<"ans["<<i<<"] = ";pv(ans[i],ans[i]+h);}
for(int i=0;i<N;++i)for(int j=0;j<N;++j){
Mint dot=0;
for(int k=0;k<h;++k)dot+=ans[i][k]*ans[j][k];
if(G[i][j]!=dot){
cerr<<i<<" "<<j<<": "<<G[i][j]<<" "<<dot<<endl;
assert(false);
}
}
#endif
break;
failed:{}
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 6796kb
input:
2 2 1 1 1 1
output:
1 1 1
result:
ok accepted
Test #2:
score: 0
Accepted
time: 2ms
memory: 6868kb
input:
3 5 4 4 3 4 4 3 3 3 2
output:
2 2 0 2 0 4 1
result:
ok accepted
Test #3:
score: 0
Accepted
time: 354ms
memory: 8384kb
input:
500 2 1 0 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 0 ...
output:
423 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 1 0 1 0 0 1 1 1 1 1 1 1 1 0 1 1 0 1 0 0 0 1 0 0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 0 1 1 1 1 0 1 1 0 0 1 0 0 0 1 1 0 1 1 1 1 1 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 1 0 0 0 ...
result:
ok accepted
Test #17:
score: 0
Accepted
time: 374ms
memory: 8468kb
input:
500 2 0 0 1 1 0 1 1 0 1 1 0 0 0 1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 1 1 1 0 0 0 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 1 1 1 0 1 1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 1 0 1 1 0 0 0 0 1 0 0 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 1 ...
output:
451 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok accepted
Test #18:
score: -100
Runtime Error
input:
500 586939 348375 543104 2613 525830 529938 63001 57038 406207 446773 47968 73017 238901 268124 473469 570747 217880 286012 142821 179125 504343 438813 105553 332560 137383 123166 585260 335875 279206 541274 318826 12120 49682 487559 275080 491437 102596 71097 184988 184272 439469 251082 388754 2144...