Submission #303192

# Submission time Handle Problem Language Result Execution time Memory
303192 2020-09-20T00:48:06 Z qiangbao Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 288 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, j;
    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){
                it++;
                continue;
            }
            f-=n;
            ans[f]=i;
            zero.erase(f), zero.erase(f+n);
            for(j=0;j<k;j++){
                int f2=(f+j)%n;
                r[f2]--;
                if(r[f2]==0)
                    zero.insert(f2);
            }
            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;
}

//int main()
//{
//    init(2, {1, 0, 1, 0});
//    cout << compare_plants(0, 1) << endl;
//    cout << compare_plants(0, 2) << endl;
//    cout << compare_plants(0, 3) << endl;
//    cout << compare_plants(1, 2) << endl;
//    cout << compare_plants(1, 3) << endl;
//    cout << compare_plants(2, 3) << endl;
//
//    return 0;
//}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -