Submission #1041804

# Submission time Handle Problem Language Result Execution time Memory
1041804 2024-08-02T08:27:17 Z GEN(#11054) A Light Inconvenience (CEOI23_light) C++17
0 / 100
1 ms 344 KB
#include "light.h"
#include <vector>
using namespace std;
#include <bits/stdc++.h>
#define int long long

int N = 1;
vector<int> V;
void prepare(){
	N = 1;
	V.clear();
	V.push_back(1);
}
/*
1557 -1 -> error
*/
std::pair<long long, std::vector<long long>> join(long long p){
	N += p;
	vector<int> V2;
	int i, j;
	int c = N;
	while(true) {
        //cout << c << '\n';
        if(c==1) {
            V2.push_back(c);
            break;
        }
        int val = N;
        for(int i=V.size()-1;i>=0;i--) {
            int n = V[i];
            if(n <= c && c <= n+p) val = c;
            if(n < c-p) break;
        }
        if(val != c) {
            for(i=V.size()-1;i>=0;i--) {
                int n = V[i];
                if(n >= c) {
                    val = min(val, n);
                    break;
                }
                if(n < c) break;
            }
        }
        c = val;
        V2.push_back(c);
        c = max(1LL, 2*(c-1)-N);
	}
	reverse(V2.begin(),V2.end());
	int v = 0;
	for(int n : V2) {
        int mi = 1e17;
        for(int m : V) {
            if(m <= n) mi = min(mi, n-m);
        }
        v = max(v, mi);
	}
	V = V2;
	return {v, V};
}

std::pair<long long, std::vector<long long>> leave(long long p){
	N -= p;
	int c = N;
	vector<int> V2;
	int i, j;
	while(true) {
        cout << c << '\n';
        if(c==1) {
            V2.push_back(c);
            break;
        }
        int val = N;
        for(int i=V.size()-1;i>=0;i--) {
            int n = V[i];
            if(n <= c && c <= n+p) val = c;
            if(n < c-p) break;
        }
        if(val != c) {
            for(i=V.size()-1;i>=0;i--) {
                int n = V[i];
                if(n >= c) {
                    val = min(val, n);
                }
                if(n < c) break;
            }
        }
        c = val;
        V2.push_back(c);
        c = max(1LL, 2*(c-1)-N);
	}
	reverse(V2.begin(),V2.end());
	int v = 0;
	for(int n : V2) {
        int mi = 1e17;
        for(int m : V) {
            if(m <= n) mi = min(mi, n-m);
        }
        v = max(v, mi);
	}
	V = V2;
	return {v, V};
}

Compilation message

light.cpp: In function 'std::pair<long long int, std::vector<long long int> > join(long long int)':
light.cpp:20:9: warning: unused variable 'j' [-Wunused-variable]
   20 |  int i, j;
      |         ^
light.cpp: In function 'std::pair<long long int, std::vector<long long int> > leave(long long int)':
light.cpp:65:9: warning: unused variable 'j' [-Wunused-variable]
   65 |  int i, j;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Security violation!
2 Halted 0 ms 0 KB -