Cod sursa(job #2831589)

Utilizator Vlad_AnicaAnica-Popa Vlad-Ioan Vlad_Anica Data 11 ianuarie 2022 18:39:46
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.32 kb
#include <iostream>
#include <fstream>

using namespace std;
const int BLOCKSIZE = 127, BLOCKBITS = 7, NRBLOCKS = (30000 >> 7) + 1, NMAX = 30000;

ifstream fin("order.in");
ofstream fout("order.out");


int blocks[NRBLOCKS];
bool gone[NMAX];

int getBlock(int pos);
int getFirst(int block);
int getLast(int block);
void rmv(int pos);
void initBlocks(int n);

int main()
{
    int n, i, x, j, r, nr, blockind, lastBlock;
    fin >> n;

    initBlocks(n);
    lastBlock = getBlock(n);
    r = n;
    j = 1;
    blockInd = 0;
    for (i = 1; i <= n; i++) {
        x = i % n;
        while (x > blocks[blockind] && blockind < lastBlock) {
            x -= blocks[blockind];
            blockind++;
        }
        if (blockind == bloc)
    }


    return 0;
}

int getBlock(int pos) {
    return  pos >> BLOCKBITS;
}
int getFirst(int pos) {
    int block = getBlock(pos);
    return block << BLOCKBITS;
}
int getLast(int pos) {
    int block = getBlock(pos);
    return (block << BLOCKBITS) + BLOCKSIZE - 1;
}
void rmv(int pos) {
    int nrblck = pos >> BLOCKBITS;
    blocks[nrblck]--;
    gone[pos] = 1;
}
void initBlocks(int n) {
    int mxBlck = (n + BLOCKSIZE) >> BLOCKBITS;
    int i;
    for (i = 0; i < mxBlck; i++)
        blocks[i] = BLOCKSIZE;
    blocks[mxBlck] = n - i;
}