Submission #303187

# Submission time Handle Problem Language Result Execution time Memory
303187 2020-09-20T00:39:04 Z qiangbao Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 256 KB
#include <iostream>
#include <vector>
#include <set>
#include "plants.h"

#define INF 1000000007

using namespace std;

int n;

set<int> zero;
set<int> cur;
set<int>:: iterator it, it2;

int ans[200001];

void init(int k, vector<int> r)
{
    int i;
    n=r.size();
    
    for(i=0;i<n;i++)
        if(r[i]==0)
            zero.insert(i);
    for(i=1;i<=n;i++){
        cur.clear();
        it=zero.begin();
        while(it!=zero.end()){
            cur.insert(*it), cur.insert(*it+n);
            it++;
        }
        it=cur.begin();
        while(it!=cur.end()){
            it2=it, it2++;
            if(it2==cur.end())
                break;
            if(*it2-*it<k){
                cur.erase(*it2);
                cur.erase(*it2+n);
            }
            it++;
        }
        it=cur.begin();
        while(it!=cur.end()){
            int f=*it;
            if(f>=n)
                f-=n;
            ans[f]=i;
            zero.erase(f), zero.erase(f+n);
            it++;
        }
    }
}

int compare_plants(int x, int y)
{
    if(ans[x]==ans[y])
        return 0;
    else if(ans[x]>ans[y])
        return 1;
    return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -