Submission #721092

# Submission time Handle Problem Language Result Execution time Memory
721092 2023-04-10T10:05:07 Z bin9638 Comparing Plants (IOI20_plants) C++17
11 / 100
44 ms 7656 KB
#include <bits/stdc++.h>

#ifndef SKY
#include "plants.h"
#endif // SKY

using namespace std;

#define N 310
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back

int k,n,h[N],a[N],ktr[N][N];

bool check(int u)
{
    if(a[u]!=0)
        return 0;
    for(int j=1;j<k;j++)
        if(a[(u-j+n)%n]==0)
            return 0;
    return 1;
}

void init(int cc, vector<int> r)
{
	k=cc;
	n=r.size();
	for(int i=0;i<n;i++)
        a[i]=r[i];
    int dem=n;
    for(int t=0;t<n;t++)
    {
    for(int i=0;i<n;i++)
        if(check(i))
        {
            h[i]=--dem;
            for(int j=0;j<k;j++)
                a[(i-j+n)%n]--;
            break;
        }
    }
   // for(int i=0;i<n;i++)cout<<h[i]<<" ";cout<<endl;
    for(int i=0;i<n;i++)
        for(int j=1;j<k;j++)
        {
            if(h[i]>h[(i-j+n)%n])
                ktr[i][(i-j+n)%n]=1;//,cout<<i<<" "<<(i-j+n)%n<<endl;
             if(h[i]>h[(i+j+n)%n])
                ktr[i][(i+j+n)%n]=1;
        }
    for(int k=0;k<n;k++)
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                ktr[i][j]|=(ktr[i][k]&ktr[k][j]);
}

int compare_plants(int x, int y)
{
    if(ktr[x][y])
        return 1;
    if(ktr[y][x])
        return -1;
    return 0;
}

#ifdef SKY
int main()
{
    freopen("A.inp","r",stdin);
    freopen("A.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int>r(n);
    for(int i=0;i<n;i++)
        cin>>r[i];//,cout<<r[i]<<endl;
    init(k,r);
    int q;
    cin>>q;
    while(q--)
    {
        int x,y;
        cin>>x>>y;
        cout<<compare_plants(x,y)<<endl;
    }
    return 0;
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 44 ms 4044 KB Output is correct
7 Runtime error 37 ms 7592 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Runtime error 6 ms 1364 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Runtime error 6 ms 1364 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 35 ms 7656 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 3 ms 452 KB Output is correct
7 Correct 33 ms 1524 KB Output is correct
8 Correct 33 ms 1524 KB Output is correct
9 Correct 34 ms 1612 KB Output is correct
10 Correct 36 ms 1532 KB Output is correct
11 Correct 32 ms 1612 KB Output is correct
12 Correct 33 ms 1524 KB Output is correct
13 Correct 33 ms 1612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Runtime error 3 ms 1216 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 44 ms 4044 KB Output is correct
7 Runtime error 37 ms 7592 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -