QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#916917#8892. Power GridDe3b0o11 3ms13492kbC++2012.5kb2025-02-27 01:46:142025-02-27 01:46:15

Judging History

This is the latest submission verdict.

  • [2025-02-27 01:46:15]
  • Judged
  • Verdict: 11
  • Time: 3ms
  • Memory: 13492kb
  • [2025-02-27 01:46:14]
  • Submitted

answer

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)

using namespace std;
using namespace __gnu_pbds;

/*

⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⣴⠟⠋⢠⣴⣾⣿⡟⠋⠉⡳⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠑⠒⠦⢤⣄⡀⠀⣴⡟⠋⡀⢠⣬⣿⣿⡿⠳⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣴⣫⡾⠋⠀⣶⣿⢿⣿⣥⠄⠠⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⣌⣩⣿⡯⠁⣬⣭⣽⣿⣿⡟⠁⠈⠉⠝⢦⠀⠀
⠀⠀⠀⠀⠀⠀⠀⡼⣽⣟⡀⣠⣼⣿⣿⠟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⠃⠀⢠⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠱⣄
⠀⠀⠀⠀⠀⠀⠸⠃⠻⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⣿⣧⣀⣼⠘⣿⠿⣸⠏⠀⣄⠀⠀⠀⠀⠀⠀⠈
⠀⠀⠀⠀⠀⠀⠇⠀⠀⠘⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣏⠀⠀⠈⡄⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠋⠀⠀⠀⠀⠀⠀⠀⢀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⡝⠳⠀⢰⢱⡀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢀⡾⠁⠀⠀⠀⠀⠀⠀⠀⢠⣾⣇⠀⢸⠀⠀⠀⠀⠀⠀⠀⢱⢹⣷⠀⠀⠀⠀⠀⠰⡆⠉⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣷⡄⠀⠀⡏⡇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢠⠞⠀⢀⡔⠀⠀⠀⠀⠀⢀⣿⡿⢹⠀⢸⠀⠀⠀⠀⠀⡀⠀⠘⣿⡿⣷⠀⠀⠀⠀⠀⠹⡀⠀⢳⡀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⡄⠀⢿⣻⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⡴⢣⡞⠀⠀⠀⠀⠀⢀⣾⡿⠁⢸⡇⢸⡇⠀⠀⠀⠀⣇⠀⠀⣿⠁⠙⣧⠀⠀⠀⠀⠀⢳⡀⠈⣇⠀⠀⠀⠀⠈⣿⣿⣿⣿⣿⣿⣆⢸⣟⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢀⡞⠀⠀⠀⠀⠀⠀⣼⡿⣁⣘⣀⢧⠈⣿⠀⠀⠀⠀⠸⡄⠀⣸⣀⣀⣹⣷⡀⠀⠀⠀⠀⢧⠀⢸⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⡿⣿⣿⢀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣼⠀⠀⠀⠀⠀⠀⣰⡿⠋⡽⠉⠉⠘⡆⣿⣧⠀⠀⠀⠀⢧⠀⣿⣿⠉⠉⠙⣯⡑⠒⠀⠀⠘⣧⠘⡇⠀⠀⠀⠀⠀⢿⠐⠂⣩⠏⠀⣿⢿⡜⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢸⠃⠀⠀⠀⠀⠀⢰⣿⠃⣴⠁⠀⠀⠀⢻⣼⠹⡆⠀⠀⠀⢸⡇⣿⡟⠀⠀⠀⠈⢿⣄⠀⠀⠀⠙⡆⣷⠀⠀⠀⠀⠀⢸⣄⣠⣏⠀⢠⣿⡎⢧⣂⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⣾⠏⢠⣀⣀⣀⡠⠄⠀⢿⣧⠹⡄⠀⠀⠀⣿⣿⣣⠀⠳⣄⠀⠀⠹⣧⡀⠀⠀⢻⢻⠀⠀⠀⠀⠀⠀⣿⣷⣾⣷⡾⣿⡇⠸⣿⠀⠀⠀
⠀⠀⠀⠀⠀⢰⡇⠀⠀⠀⠀⠀⣸⣿⢀⣶⡿⠟⢛⣿⣷⣄⠈⣿⣆⠹⡄⠀⠀⢸⡇⣿⣀⣴⣾⠿⢿⣷⣮⣍⡀⠀⠀⣾⠀⡀⠀⠀⠀⠀⣿⡟⢻⠋⣻⣿⡇⠀⢿⡄⠀⠀
⠀⠀⠀⠀⡀⡜⠀⠀⠀⠀⠀⠀⣿⣿⡿⠋⠀⠐⢻⣿⣿⣿⡀⠈⣿⣦⡙⣄⠀⠸⡇⢸⠛⠛⠀⠀⠠⣾⣿⣿⣿⣦⡀⢸⠀⡇⠀⠀⠀⠀⣿⣶⣾⣿⣿⣿⠃⠀⢸⡇⠀⠀
⠀⠀⠀⠀⡆⠀⠀⠀⠀⠀⠀⢠⣿⡼⠃⠀⠀⣶⣾⣿⣿⣿⡇⠀⠈⢷⡙⢮⣀⠀⣿⠈⠄⠀⠀⢠⣤⣿⣿⣿⣿⣿⣿⣾⢲⡇⠀⠀⠀⠀⡿⣿⣿⣿⣿⡟⠀⠀⢸⣷⠀⠀
⠀⠀⠀⣤⡇⢰⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀⠀⢻⡿⣿⣷⢿⠇⠀⠀⠀⠳⡄⠈⠳⢼⡀⠀⠀⠀⢸⣿⣿⣿⣿⣿⡟⢸⡏⣼⠁⠀⠀⢀⡶⣷⣿⣿⣿⣿⠃⠀⠀⠀⣿⠀⠀
⠀⠀⢰⣻⠀⢸⡇⠀⠀⠀⠀⣼⣿⣿⡄⠀⠀⠘⢧⣀⣰⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⡇⠀⠤⠀⣹⠁⢠⣣⠇⠀⠀⠀⢸⡇⣿⣿⣿⣿⣿⠀⠀⠀⠀⣿⠀⠀
⠀⠀⡄⠀⠀⢸⣇⠀⢀⠀⠀⣷⣿⡿⢿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠒⠒⠚⠃⠀⣸⡿⠀⠀⠀⠀⢸⡇⣿⣿⣿⣿⣿⠀⠀⠀⠀⣿⠀⠀
⠀⢰⠁⠀⠀⠀⣿⡄⠘⢦⠀⣿⡫⠐⣺⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣿⠀⠀⠀⠀⠀⢸⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀⠘⠀⠀
⠀⢸⠀⠀⠀⣷⣹⣷⠀⠈⡾⠋⠀⠀⣿⣳⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡼⢹⡇⣼⠀⠀⠀⠀⣼⣿⡟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠈⠁⠀⠀⠀⢷⡻⢧⡞⠁⠉⠉⠭⣅⣈⢧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⣼⣸⠃⠀⠀⠀⢀⣿⡏⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠁⠀⣿⣄⠀⠀⠀⠀⠈⠙⠳⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣷⡇⠀⠀⠀⡀⢸⡿⠀⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⡄⠀⠀⠀⠀⠀⠀⠀⠀⡟⢸⡷⣄⠀⠀⠀⠀⠀⠀⠉⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠴⣾⠙⣿⠁⠀⠀⢠⡇⣾⣷⣼⠥⠤⠤⣤⣄⣀⡀⠀⠀⠀⠀⠀
⡀⠀⠀⠀⠀⠀⠀⠀⢠⡇⣿⡇⣿⣳⣄⠀⠀⠀⠀⠀⠀⠈⠑⣦⣄⠀⠀⠀⠀⠀⠀⠀⢀⣠⡤⠒⠋⣀⡾⠃⢠⡏⠀⠀⢠⣿⣿⣯⣿⡏⢀⡔⠋⠁⠀⠈⠉⠲⡄⠀⠀⠀
⡇⠀⠀⠀⠀⠀⠀⠀⢸⡇⣿⣷⢸⣿⣿⡷⢤⠀⠀⠀⠀⠀⠀⠈⢻⣓⢦⣀⣀⣤⠶⠚⠉⠀⢀⡠⠞⠁⠀⢀⡾⠀⠀⢀⣾⣯⢿⣿⠋⠰⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⡃⠀⠀⠀⠀⠀⠀⠀⢸⡇⢸⣹⣯⣿⠃⢧⠀⡷⡄⠀⠀⠀⠀⠀⠀⢡⡿⠛⢙⣿⣦⣠⠴⠚⠉⠀⠀⢀⣠⡿⠁⠀⣠⣾⣯⡽⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⢸⡇⠈⠻⡆⠀⡾⠁⠀⠀⠀⠀⠀⠀⢀⣾⣧⠴⢺⣿⡉⠀⠀⠀⠀⢀⣤⢾⡟⠁⢀⣴⠟⠉⠁⢸⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠸⡇⡼⠀⠀⠀⢀⡼⠁⠀⠀⠀⠀⠀⠀⠀⣼⠋⠀⠀⠀⡝⢷⠀⢀⡤⠖⠋⣀⣮⠴⠚⠋⠁⠀⠀⢠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠁⠀⠀⢠⠞⠀⠀⠀⠀⠀⠀⠀⠀⣼⡇⠀⠀⢀⣼⣧⠈⡗⣿⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠀⡾⠁⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢰⡇⠀⣠⣶⠃⠀⠀⠀⠀⠀⠀⠀⠀⣸⡿⠀⠀⢠⣾⠉⢸⢷⣼⣿⡇⠀⠀⠀⢀⡠⠊⠀⠀⠀⡼⠁⢰⠟⢹⡗⢶⣶⡶⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⡼⠀⣰⣿⢿⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⡇⠀⣰⠟⢹⠀⠀⠈⡽⠛⢷⡀⠀⠀⠁⠀⠀⠀⠀⣸⠁⢠⣾⠀⣼⠃⢠⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢀⣧⣾⣏⢹⣿⠀⠀⠀⠀⠀⠀⠀⡸⠋⢰⡁⢰⠏⣰⣿⠀⠀⣼⣧⡴⠛⣿⠀⠀⠀⠀⠀⢀⡼⠃⠀⠘⢿⣿⣃⣀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

*/

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll N = 1009;

ll n , m;
ll a[N][N] , c[N][N];
ll dp[N][N];

bool solid()
{
    ll f = a[1][1]-a[2][1];
    bool g = 0;
    for(int i = 2 ; m>=i ; i++)
    {
        if(a[1][i]-a[2][i]==f)
            continue;
        if(-a[1][i]-a[2][i]==f)
        {
            a[1][i]*=-1;
            continue;
        }
        if(-a[1][i]+a[2][i]==f)
        {
            a[2][i]*=-1;
            continue;
        }
        if(a[1][i]+a[2][i]==f)
        {
            a[1][i]*=-1;
            a[2][i]*=-1;
            continue;
        }
        g=1;
    }
    if(g)
        return 0;
    f = a[1][2]-a[1][1];
    for(int i = 3 ; n>=i ; i++)
    {
        if(a[i][2]-a[i][1]==f)
            continue;
        if(-a[i][2]-a[i][1]==f)
        {
            a[i][2]*=-1;
            continue;
        }
        if(-a[i][2]+a[i][1]==f)
        {
            a[i][1]*=-1;
            continue;
        }
        if(a[i][2]+a[i][1]==f)
        {
            a[i][2]*=-1;
            a[i][1]*=-1;
            continue;
        }
        g=1;
    }
    if(g)
        return 0;
    for(int j = 3 ; m>=j ; j++)
    {
        f=a[1][j]-a[1][1];
        for(int i = 3 ; n>=i ; i++)
        {
            if(a[i][j]-a[i][1]==f)
                continue;
            if(-a[i][j]-a[i][1]==f)
            {
                a[i][j]*=-1;
                continue;
            }
            g=1;
        }
    }
    if(g)
        return 0;
    vector<ll> v;
    for(int i = 1 ; m>=i ; i++)
        v.pb(a[1][i]-a[1][1]);
    for(int i = 2 ; n>=i ; i++)
    {
        for(int j = 1 ; m>=j ; j++)
        {
            if(v[j-1]!=a[i][j]-a[i][1])
                g=1;
        }
    }
    if(g)
        return 0;
    ll d = 0;
    for(int i = 2 ; n>=i ; i++)
        d-=a[i][1]-a[1][1];
    for(int i = 2 ; m>=i ; i++)
        d-=a[1][i]-a[1][1];
    ll x , y;
    ll cc = a[1][1];
    if(n==m)
    {
        if(d!=n*cc)
            return 0;
        y = 1e7;
        x = 1e7+cc;
    }
    else
    {
        if((d-n*cc)%(n-m)!=0)
            return 0;
        y=(d-n*cc)/(n-m);
        x=y+cc;
    }
    ll mne = 0;
    ll row[n+1] , col[m+1];
    for(int i = 1 ; n>=i ; i++)
        row[i]=x+a[i][1]-a[1][1] , mne=min(mne,row[i]);
    for(int j = 1 ; m>=j ; j++)
        col[j]=y+a[1][1]-a[1][j] , mne=min(mne,col[j]);
    if(mne<0)
        return 0;
    for(int i = 1 ; n>=i ; i++)
    {
        for(int j = 1 ; m>=j ; j++)
        {
            ll mn = min(row[i],col[j]);
            cout << mn << " ";
            row[i]-=mn;
            col[j]-=mn;
        }
        lin
    }
}

int main()
{
    cin >> n >> m;
    for(int i = 1 ; n>=i ; i++)
    {
        for(int j = 1 ; m>=j ; j++)
            cin >> c[i][j];
    }
    if(n+m==2)
    {
        cout << 0;
        return 0;
    }
    if(n==1)
    {
        memset(dp,-1,sizeof(dp));
        ll b = m-1;
        ll sum = 0;
        for(int i = 1 ; m>=i ; i++)
            sum+=c[1][i];
        vector<ll> v;
        for(int i = 1 ; m>=i ; i++)
            v.pb((2*c[1][i])%b);
        dp[0][0]=-2;
        for(int i = 0 ; m>i ; i++)
        {
            for(int j = 0 ; b>j ; j++)
            {
                if(dp[i][j]==-1)
                    continue;
                ll x = j + v[i];
                if(x>=b)
                    x-=b;
                dp[i+1][x]=i;
                dp[i+1][j]=dp[i][j];
            }
        }
        vector<ll> e;
        ll x = m , y = sum%b;
        while(y)
        {
            if(dp[x][y]==-2)
                break;
            e.pb(dp[x][y]);
            ll xx = dp[x][y];
            ll yy = y-v[xx];
            if(yy<0)
                yy+=b;
            x=xx;
            y=yy;
        }
        ll md[m+1] = {0};
        for(auto it : e)
            md[it+1]=1;
        ll su = 0;
        for(int i = 1 ; m>=i ; i++)
        {
            if(md[i])
                md[i]=+c[1][i];
            else
                md[i]=-c[1][i];
            su+=md[i];
        }
        ll fe = -su/b;
        for(int i = 1 ; m>=i ; i++)
            cout << fe+md[i] << " ";
        return 0;
    }
    if(m==1)
    {
        memset(dp,-1,sizeof(dp));
        ll b = n-1;
        ll sum = 0;
        for(int i = 1 ; n>=i ; i++)
            sum+=c[i][1];
        vector<ll> v;
        for(int i = 1 ; n>=i ; i++)
            v.pb((2*c[i][1])%b);
        dp[0][0]=-2;
        for(int i = 0 ; n>i ; i++)
        {
            for(int j = 0 ; b>j ; j++)
            {
                if(dp[i][j]==-1)
                    continue;
                ll x = j + v[i];
                if(x>=b)
                    x-=b;
                dp[i+1][x]=i;
                dp[i+1][j]=dp[i][j];
            }
        }
        vector<ll> e;
        ll x = n , y = sum%b;
        while(y)
        {
            if(dp[x][y]==-2)
                break;
            e.pb(dp[x][y]);
            ll xx = dp[x][y];
            ll yy = y-v[xx];
            if(yy<0)
                yy+=b;
            x=xx;
            y=yy;
        }
        ll md[n+1] = {0};
        for(auto it : e)
            md[it+1]=1;
        ll su = 0;
        for(int i = 1 ; n>=i ; i++)
        {
            if(md[i])
                md[i]=+c[i][1];
            else
                md[i]=-c[i][1];
            su+=md[i];
        }
        ll fe = -su/b;
        for(int i = 1 ; n>=i ; i++)
            cout << fe+md[i] << "\n";
        return 0;
    }
    for(int i = 1 ; n>=i ; i++)
        for(int j = 1 ; m>=j ; j++)
            a[i][j]=c[i][j];
    if(solid())
        return 0;
    a[1][1]*=-1;
    if(solid())
        return 0;
    a[2][1]*=-1;
    if(solid())
        return 0;
    a[1][1]*=-1;
    solid();
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 8
Accepted
time: 0ms
memory: 5560kb

input:

1 1
0

output:

0

result:

ok correct

Test #2:

score: 8
Accepted
time: 0ms
memory: 5668kb

input:

1 1
0

output:

0

result:

ok correct

Test #3:

score: 8
Accepted
time: 0ms
memory: 12260kb

input:

1 2
1 1

output:

1 1 

result:

ok correct

Test #4:

score: 8
Accepted
time: 0ms
memory: 12936kb

input:

3 1
0
3
1

output:

2
-1
1

result:

ok correct

Test #5:

score: 0
Runtime Error

input:

2 2
1 1
1 1

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 11
Accepted

Test #23:

score: 11
Accepted
time: 0ms
memory: 5712kb

input:

1 1
0

output:

0

result:

ok correct

Test #24:

score: 11
Accepted
time: 1ms
memory: 12732kb

input:

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

output:

270 211 -418 -252 276 316 -73 283 102 -215 

result:

ok correct

Test #25:

score: 11
Accepted
time: 3ms
memory: 13140kb

input:

1 1000
298 440 513 326 225 36 897 92 347 346 919 370 28 957 593 332 736 960 346 969 329 893 380 523 104 345 860 451 290 958 164 386 508 786 605 778 453 500 376 670 86 283 844 408 282 541 479 827 9 558 473 251 184 694 920 905 1000 515 846 506 741 403 552 869 37 667 377 350 711 304 509 471 164 901 487...

output:

202 60 -13 174 275 464 -397 408 153 154 -419 130 472 -457 -93 168 -236 -460 154 -469 171 -393 120 -23 396 155 -360 49 210 -458 336 114 -8 -286 -105 -278 47 0 124 -170 414 217 -344 92 218 -41 21 -327 491 -58 27 249 316 -194 -420 -405 -500 -15 -346 -6 -241 97 -52 -369 463 -167 123 150 -211 196 -9 29 3...

result:

ok correct

Test #26:

score: 11
Accepted
time: 0ms
memory: 12668kb

input:

1 1000
684 573 532 550 99 296 284 671 559 397 215 977 399 460 710 152 111 966 525 184 613 982 274 805 541 238 258 357 884 969 343 700 55 610 351 470 212 842 908 911 752 593 257 396 343 937 253 395 452 718 513 754 990 149 853 895 783 329 20 728 119 602 15 202 475 49 578 427 27 349 547 225 223 209 197...

output:

-184 -73 -32 -50 401 204 216 -171 -59 103 285 -477 101 40 -210 348 389 -466 -25 316 -113 -482 226 -305 -41 262 242 143 -384 -469 157 -200 445 -110 149 30 288 -342 -408 -411 -252 -93 243 104 157 -437 247 105 48 -218 -13 -254 -490 351 -353 -395 -283 171 480 -228 381 -102 485 298 25 451 -78 73 473 151 ...

result:

ok correct

Test #27:

score: 11
Accepted
time: 3ms
memory: 12276kb

input:

1 1000
379 888 365 408 845 405 394 954 362 367 421 913 426 418 401 422 389 890 393 898 924 405 916 408 378 419 393 372 398 863 363 903 408 872 403 372 368 383 400 401 849 878 386 923 863 410 884 387 905 388 929 390 338 416 385 388 420 371 930 411 391 923 389 952 388 385 387 936 931 384 867 889 390 8...

output:

917 -350 173 946 1383 943 144 1492 176 171 117 -375 112 120 137 116 149 -352 145 -360 -386 133 -378 130 160 119 145 166 140 -325 175 -365 130 -334 135 166 170 155 138 137 -311 -340 152 -385 -325 128 -346 151 -367 150 -391 148 200 122 153 150 118 167 -392 127 147 -385 149 -414 150 153 151 -398 -393 1...

result:

ok correct

Test #28:

score: 11
Accepted
time: 1ms
memory: 11904kb

input:

1 1000
1 0 0 3 1 0 0 0 0 0 0 2 1 1 0 0 1 0 1 0 0 0 2 3 0 0 2 0 3 2 2 1 1 0 2 0 1 2 1 0 0 1 0 1 0 0 1 1 2 2 1 0 0 0 1 3 2 3 1 1 0 1 2 1 1 0 2 1 1 2 1 2 1 4 1 2 0 2 2 1 0 1 2 4 1 0 1 1 2 0 4 1 1 0 0 0 0 1 1 0 0 1 0 0 2 1 1 2 1 0 4 1 2 2 0 1 0 0 0 1 2 3 0 0 1 2 0 2 2 0 1 2 0 2 1 1 2 0 2 0 0 0 0 1 0 1 1...

output:

0 -1 -1 2 0 -1 -1 -1 -1 -1 -1 1 0 0 -1 -1 0 -1 0 -1 -1 -1 1 2 -1 -1 1 -1 2 1 1 0 0 -1 1 -1 0 1 0 -1 -1 0 -1 0 -1 -1 0 0 1 1 0 -1 -1 -1 0 2 1 2 0 0 -1 0 1 0 0 -1 1 0 0 1 0 1 0 3 0 1 -1 1 1 0 -1 0 1 3 0 -1 0 0 1 -1 3 0 0 -1 -1 -1 -1 0 0 -1 -1 0 -1 -1 1 0 0 1 0 -1 3 0 1 1 -1 0 -1 -1 -1 0 1 2 -1 -1 0 1 ...

result:

ok correct

Test #29:

score: 11
Accepted
time: 2ms
memory: 13492kb

input:

1 766
1 0 1 0 1 2 0 3 0 0 1 2 0 1 0 2 0 1 1 4 1 3 0 0 2 2 2 2 1 1 1 2 1 2 0 1 2 1 2 0 4 0 1 0 0 0 0 0 1 2 0 0 1 2 2 4 1 1 1 2 0 1 3 2 1 0 0 0 0 1 0 1 0 1 2 2 3 0 3 1 0 0 1 1 0 1 4 3 1 2 0 3 0 1 1 2 1 2 1 1 2 0 1 0 0 2 1 1 2 0 2 0 0 1 1 3 1 0 1 2 1 0 0 3 2 0 0 2 2 0 0 1 0 1 1 1 2 0 2 3 1 1 1 3 0 0 2 ...

output:

0 -1 0 -1 0 1 -1 2 -1 -1 0 1 -1 0 -1 1 -1 0 0 3 0 2 -1 -1 1 1 1 1 0 0 0 1 0 1 -1 0 1 0 1 -1 3 -1 0 -1 -1 -1 -1 -1 0 1 -1 -1 0 1 1 3 0 0 0 1 -1 0 2 1 0 -1 -1 -1 -1 0 -1 0 -1 0 1 1 2 -1 2 0 -1 -1 0 0 -1 0 3 2 0 1 -1 2 -1 0 0 1 0 1 0 0 1 -1 0 -1 -1 1 0 0 1 -1 1 -1 -1 0 0 2 0 -1 0 1 0 -1 -1 2 1 -1 -1 1 ...

result:

ok correct

Subtask #4:

score: 0
Runtime Error

Test #30:

score: 0
Runtime Error

input:

2 2
0 0
0 0

output:


result:


Subtask #5:

score: 0
Wrong Answer

Test #46:

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

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:

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

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%