QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#469686 | #8892. Power Grid | Lynkcat | 0 | 1ms | 5720kb | C++20 | 2.1kb | 2024-07-09 21:58:06 | 2024-07-09 21:58:07 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N
using namespace std;
const int N=1005;
int n,m;
int ans[N][N],b[N],a[N];
int c[N][N];
int fa[N],va[N],sum[N][2];
mt19937_64 rnd(time(0));
inline int gf(int x)
{
while (x!=fa[x]) x=fa[x]=fa[fa[x]];
return x;
}
inline void merge(int x,int y)
{
x=gf(x),y=gf(y);
if (x==y) return;
va[x]&=va[y];
fa[y]=x;
}
void BellaKira()
{
cin>>n>>m;
for (int i=0;i<n;i++)
for (int j=0;j<m;j++)
cin>>c[i][j];
//when a[0]==b[0]-c[0][0]
{
bool bl=1;
a[0]=-c[0][0];
for (int i=1;i<=n+m;i++) fa[i]=i,va[i]=3,sum[i][0]=sum[i][1]=0;
for (int i=1;i<n;i++)
for (int j=1;j<m;j++)
{
int st=0;
if (abs((a[0]-c[i][0]) - (b[0]-c[0][i]))==c[i][j])
{
st|=1;
}
if (abs((a[0]-c[i][0]) - (b[0]+c[0][i]))==c[i][j])
{
st|=2;
}
if (abs((a[0]+c[i][0]) - (b[0]+c[0][i]))==c[i][j])
{
st|=4;
}
if (abs((a[0]+c[i][0]) - (b[0]+c[0][i]))==c[i][j])
{
st|=8;
}
assert(__builtin_popcount(st)!=3);
}
for (int i=1;i<n;i++)
{
sum[gf(i)][0]-=a[0]-c[i][0];
sum[gf(i)][1]-=a[0]+c[i][0];
}
for (int i=1;i<m;i++)
{
sum[gf(n+i)][0]+=-c[0][i];
sum[gf(n+i)][1]+=c[0][i];
}
int nw=0;
for (int i=1;i<n+m;i++)
if (i!=n&&gf(i)==i)
{
if (va[i]==0) bl=0;
else
if (va[i]==1) nw+=sum[i][0];
else
if (va[i]==2) nw+=sum[i][1];
else
{
nw+=sum[i][0];
}
}
}
}
signed main()
{
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5652kb
input:
1 1 0
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 1ms
memory: 5712kb
input:
1 1 0
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #4:
score: 0
Wrong Answer
Test #30:
score: 0
Wrong Answer
time: 1ms
memory: 5704kb
input:
2 2 0 0 0 0
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #5:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 1ms
memory: 5720kb
input:
2 4 253 431 207 483 243 65 289 13
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #6:
score: 0
Runtime Error
Test #58:
score: 0
Runtime Error
input:
1000 1000 1 0 0 1 0 1 0 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 0 1 1 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 0 1 1 ...
output:
result:
Subtask #7:
score: 0
Runtime Error
Test #68:
score: 0
Runtime Error
input:
2 2 5 52 52 5
output:
result:
Subtask #8:
score: 0
Skipped
Dependency #2:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%