QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#469414#8892. Power GridLynkcat#0 401ms19472kbC++201.8kb2024-07-09 18:59:362024-07-09 18:59:36

Judging History

This is the latest submission verdict.

  • [2024-07-09 18:59:36]
  • Judged
  • Verdict: 0
  • Time: 401ms
  • Memory: 19472kb
  • [2024-07-09 18:59:36]
  • Submitted

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];
map<int,int>f[N];
void dfs(int k,int sm)
{
    if (f[k].count(sm)) return;

    if (k==n)
    {
        if (sm!=0&&(n==m||sm%(n-m)!=0)) return;

        int o=0;
        if (sm!=0) o=sm/(n-m);
        for (int i=0;i<m;i++) a[i]-=o;
        for (int i=0;i<n;i++) b[i]-=o;

        for (int i=1;i<m;i++) ans[0][i]=a[i],b[0]-=a[i];
        for (int i=0;i<n;i++)
        {
            ans[i][0]=b[i];
        }
        for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++) cout<<ans[j][i]<<" ";
            cout<<'\n';
        }
        fflush(stdout);
        exit(0);
    }
    for (int i=-c[0][0];i<=c[0][0];i+=c[0][0])
    {
        b[k]=i;
        bool bl=1;
        for (int j=0;j<m;j++)
        {
            if (abs(b[k]-a[j])!=c[k][j])
            {
                bl=0;
                break;
            }
        }
        if (bl) dfs(k+1,sm+i);
    }
    f[k][sm]=1;
}
void BellaKira()
{
    cin>>n>>m;
    for (int i=0;i<n;i++)
        for (int j=0;j<m;j++)
            cin>>c[j][i];
    swap(n,m);
    for (int s=0;s<=m;s++)
    {
        poly g;
        for (int i=0;i<m;i++)
            if (i<s) a[i]=c[0][i];
            else a[i]=-c[0][i];
        int sm=0;
        for (int i=0;i<m;i++) sm-=a[i];
        dfs(1,sm);
        for (int i=1;i<n;i++) f[i].clear();
    }
}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	while (T--)
	{
		BellaKira();
	}
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 8
Accepted
time: 1ms
memory: 5768kb

input:

1 1
0

output:

0 

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 5688kb

input:

1 1
0

output:

0 

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 5756kb

input:

1 2
1 1

output:

-1 -1 

result:

ok correct

Test #4:

score: 0
Accepted
time: 1ms
memory: 7744kb

input:

3 1
0
3
1

output:

2 
-1 
1 

result:

ok correct

Test #5:

score: 0
Accepted
time: 1ms
memory: 5756kb

input:

2 2
1 1
1 1

output:

1 0 
-1 0 

result:

ok correct

Test #6:

score: -8
Wrong Answer
time: 1ms
memory: 5756kb

input:

3 3
2 1 1
2 1 1
0 1 3

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: 11
Accepted
time: 1ms
memory: 5780kb

input:

1 1
0

output:

0 

result:

ok correct

Test #24:

score: -11
Wrong Answer
time: 1ms
memory: 5784kb

input:

1 10
230 289 918 752 224 184 573 217 398 715

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #4:

score: 0
Wrong Answer

Test #30:

score: 6
Accepted
time: 1ms
memory: 5756kb

input:

2 2
0 0
0 0

output:

0 0 
0 0 

result:

ok correct

Test #31:

score: 0
Accepted
time: 1ms
memory: 5732kb

input:

2 2
7 7
7 7

output:

7 0 
-7 0 

result:

ok correct

Test #32:

score: 0
Accepted
time: 1ms
memory: 5764kb

input:

2 4
7 7 7 7
7 7 7 7

output:

7 -7 -7 -7 
-14 0 0 0 

result:

ok correct

Test #33:

score: 0
Accepted
time: 1ms
memory: 7892kb

input:

20 40
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80
80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ...

output:

2960 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 -80 
-160 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 
-160 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 correct

Test #34:

score: 0
Accepted
time: 1ms
memory: 5856kb

input:

20 40
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 ...

output:

370 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 
-20 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 
-20 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 correct

Test #35:

score: 0
Accepted
time: 401ms
memory: 18960kb

input:

1000 1000
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ...

output:

1000 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 0 0 0 0 0 0...

result:

ok correct

Test #36:

score: 0
Accepted
time: 16ms
memory: 15564kb

input:

496 499
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 1...

output:

986036 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984 -1984...

result:

ok correct

Test #37:

score: 0
Accepted
time: 21ms
memory: 14004kb

input:

499 498
117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 ...

output:

-28958085 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58383 58...

result:

ok correct

Test #38:

score: 0
Accepted
time: 19ms
memory: 14416kb

input:

499 499
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 0 0 0 0 ...

output:

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 0 0 0 0 0 0 0 0 ...

result:

ok correct

Test #39:

score: 0
Accepted
time: 12ms
memory: 18892kb

input:

177 1000
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 0 0 0 0...

output:

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 0 0 0 0 0 0 0 0 ...

result:

ok correct

Test #40:

score: 0
Accepted
time: 80ms
memory: 19004kb

input:

997 1000
871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871...

output:

287725269 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -288301 -2...

result:

ok correct

Test #41:

score: 0
Accepted
time: 0ms
memory: 5784kb

input:

8 3
7 7 7
7 7 7
7 7 7
7 7 7
7 7 7
7 7 7
7 7 7
7 7 7

output:

7 0 0 
7 0 0 
7 0 0 
7 0 0 
-7 0 0 
-7 0 0 
-7 0 0 
-7 0 0 

result:

ok correct

Test #42:

score: -6
Wrong Answer
time: 0ms
memory: 5828kb

input:

3 8
7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #5:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 0ms
memory: 5684kb

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
Time Limit Exceeded

Test #58:

score: 5
Accepted
time: 79ms
memory: 18860kb

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:

503 -1 -1 0 -1 0 -1 0 -1 -1 0 0 -1 -1 0 0 0 0 0 0 0 0 -1 -1 -1 0 -1 0 0 -1 0 0 -1 0 0 0 -1 -1 0 0 -1 -1 -1 0 0 -1 0 0 -1 0 0 0 -1 -1 -1 0 -1 -1 -1 0 -1 0 0 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 0 -1 -1 -1 -1 0 -1 0 0 -1 -1 -1 -1 -1 0 -1 0 0 -1 -1 0 0 -1 0 -1 0 0 0 0 -1 0 0 -1 -1 0 -1 0 -1 0 0 -1 0 -1 -1 -1 -...

result:

ok correct

Test #59:

score: 0
Accepted
time: 390ms
memory: 19472kb

input:

1000 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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0 0 0 0 0 -1 -1 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 0 -1 0 0 0 -1 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0...

result:

ok correct

Test #61:

score: 0
Accepted
time: 32ms
memory: 18964kb

input:

477 1000
1 0 0 0 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 1 1 1 0 1 0 1 0 0 1 0 0 1 1 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 0 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0...

output:

380 -1 -1 -1 -1 0 -1 0 -1 -1 0 0 -1 -1 0 -1 -1 0 -1 0 0 -1 0 -1 -1 -1 0 -1 0 0 -1 0 0 0 0 -1 0 -1 0 -1 -1 0 -1 -1 0 0 -1 -1 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 0 0 0 -1 -1 -1 0 -1 -1 -1 -1 0 0 -1 0 0 0 -1 -1 -1 0 0 -1 0 0 -1 -1 0 -1 -1 -1 0 -1 0 0 0 0 0 0 0 0 0 -1 0 -1 -1 0 0 -1 0...

result:

ok correct

Test #62:

score: -5
Time Limit Exceeded

input:

1000 871
0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 0 0 0 1 1 0 1 1 0 0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 1 0 1 1 1 1 0 1 1 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 1 1 1 1 0 1 1 1 1 0 0 0 0...

output:


result:


Subtask #7:

score: 0
Wrong Answer

Test #68:

score: 0
Wrong Answer
time: 1ms
memory: 5704kb

input:

2 2
5 52
52 5

output:


result:

wrong output format Unexpected end of file - int32 expected

Subtask #8:

score: 0
Skipped

Dependency #2:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

0%