QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#277194 | #4282. Intervals | PetroTarnavskyi# | WA | 1ms | 3524kb | C++20 | 1.5kb | 2023-12-06 16:14:36 | 2023-12-06 16:14:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int L = 1'000'000;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector a(n, VI(n));
for (VI& ai : a)
for (int& aij : ai)
cin >> aij;
unordered_set<int> unused;
FOR(i, 0, n)
unused.insert(i);
VI can(n), x(n);
while (!unused.empty())
{
int i = *unused.begin();
can[i] = 1;
VI vec;
while (true)
{
int j = -1;
for (int k : unused)
if (can[k])
j = k;
if (j == -1)
break;
unused.erase(j);
if (j != i)
{
unordered_map<int, int> mp;
int cntNonZero = 0;
for (int k : vec)
{
if (a[j][k] != 0)
{
mp[x[k] + L - a[j][k]]++;
mp[x[k] + a[j][k] - L]++;
cntNonZero++;
}
}
assert(cntNonZero != 0);
bool ok = false;
for (auto [cand, cntCand] : mp)
{
if (cntCand == cntNonZero)
{
ok = true;
x[j] = cand;
}
}
if (!ok)
{
cout << "No\n";
return 0;
}
}
vec.PB(j);
FOR(k, 0, n)
{
if (a[j][k] != 0)
can[k] = 1;
}
}
}
cout << "Yes\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3488kb
input:
3 1000000 500000 0 500000 1000000 500000 0 500000 1000000
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
3 1000000 500000 500000 500000 1000000 500000 500000 500000 1000000
output:
No
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
10 1000000 0 0 0 451708 0 0 0 0 0 0 1000000 123857 854215 0 789032 115663 874764 0 0 0 123857 1000000 269642 0 334825 0 249093 0 0 0 854215 269642 1000000 0 934817 0 979451 0 0 451708 0 0 0 1000000 0 0 0 0 0 0 789032 334825 934817 0 1000000 0 914268 0 0 0 115663 0 0 0 0 1000000 0 0 0 0 874764 249093...
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
10 1000000 0 333783 645285 0 0 0 0 91417 0 0 1000000 0 0 0 0 107222 0 0 461671 333783 0 1000000 688498 0 0 0 0 0 0 645285 0 688498 1000000 0 0 0 0 0 0 0 0 0 0 1000000 0 0 0 0 0 0 0 0 0 0 1000000 0 0 0 21662 0 107222 0 0 0 0 1000000 0 0 0 0 0 0 0 0 0 0 1000000 750265 0 91417 0 0 0 0 0 0 750265 100000...
output:
Yes
result:
ok answer is YES
Test #5:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
10 1000000 0 0 0 0 0 0 0 83267 0 0 1000000 0 0 0 0 0 0 0 979288 0 0 1000000 511234 0 0 0 0 0 0 0 0 511234 1000000 0 0 0 0 0 0 0 0 0 0 1000000 0 0 0 853421 0 0 0 0 0 0 1000000 0 592583 0 0 0 0 0 0 0 0 1000000 0 0 0 0 0 0 0 0 592583 0 1000000 0 0 83267 0 0 0 853421 0 0 0 1000000 0 0 979288 0 0 0 0 0 0...
output:
Yes
result:
ok answer is YES
Test #6:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
10 1000000 0 662921 128153 0 0 0 530784 0 0 0 1000000 0 0 454596 0 90389 0 0 0 662921 0 1000000 0 0 0 0 193705 0 0 128153 0 0 1000000 0 0 0 597369 0 0 0 454596 0 0 1000000 0 635793 0 0 0 0 0 0 0 0 1000000 0 0 0 0 0 90389 0 0 635793 0 1000000 0 0 0 530784 0 193705 597369 0 0 0 1000000 0 0 0 0 0 0 0 0...
output:
Yes
result:
ok answer is YES
Test #7:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
10 1000000 194114 0 372890 0 303429 0 0 0 0 194114 1000000 0 821224 0 0 0 0 0 514397 0 0 1000000 0 399458 0 0 0 0 425383 372890 821224 0 1000000 0 0 0 0 0 335621 0 0 399458 0 1000000 0 0 0 0 0 303429 0 0 0 0 1000000 0 0 0 0 0 0 0 0 0 0 1000000 372945 0 0 0 0 0 0 0 0 372945 1000000 0 0 0 0 0 0 0 0 0 ...
output:
Yes
result:
ok answer is YES
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3524kb
input:
10 1000000 0 0 218418 0 0 144052 0 0 0 0 1000000 0 0 0 0 0 953348 0 0 0 0 1000000 0 0 0 844845 0 0 0 218418 0 0 1000000 0 0 0 0 39414 0 0 0 0 0 1000000 0 0 0 91667 0 0 0 0 0 0 1000000 0 0 0 0 144052 0 844845 0 0 0 1000000 0 0 0 0 953348 0 0 0 0 0 1000000 0 466707 0 0 0 39414 91667 0 0 0 1000000 0 0 ...
output:
Yes
result:
wrong answer expected NO, found YES