답안 #1041615

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041615 2024-08-02T06:16:24 Z EaglesV7(#11051) A Light Inconvenience (CEOI23_light) C++17
0 / 100
271 ms 600 KB
#include "light.h"
#include <bits/stdc++.h>
using namespace std;

long long cnt;
vector<long long> vec;

void prepare(){
	cnt = 1;
vec.push_back(1);
}

typedef pair<long long, std::vector<long long>> iv;

iv join(long long p){
    cnt+=p;
    vector<long long> nv;
    long long now=vec[0]+p;
if (now==cnt) now--;
    while (now>1) {
	if (now!=vec[0]+p)
        nv.push_back(now);
	now-=cnt-now;
    }
    nv.push_back(1);
    reverse(nv.begin(),nv.end());
    for(int i=0;i<vec.size();i++) {
        nv.push_back(vec[i]+p);
    }
    vec=nv;
    nv.clear();
assert(vec[0]==1);
	return {p,vec};
}

iv leave(long long p){
    cnt-=p;
    vector<long long> v2;
    for(int i=0;i<vec.size();i++) {
        if (vec[i]<cnt)
            v2.push_back(vec[i]);
	if (vec[i]+p<cnt)
		v2.push_back(vec[i]+p);
    }
if (v2.empty()) {
vec.clear();
vec.push_back(1);
return {p,vec};
}
    sort(v2.begin(),v2.end());
v2.erase(unique(v2.begin(),v2.end()),v2.end());
    vector<long long> nv;
    long long now=cnt;
    long long en=v2[v2.size()-1];
    while (now>en) {
        nv.push_back(now);
        now-=cnt-now;
if (now==cnt) now--;
    }
assert(!v2.empty());
assert(!nv.empty());
    long long pr=nv[nv.size()-1];
    for(int i=v2.size()-1;i>=0;i--) {
        if (i==0||pr-v2[i-1]>cnt-pr) {
if (pr-v2[i]>cnt-pr) {
en=pr;
now=pr;
    while (now>v2[i]) {
	if (now!=en)
        nv.push_back(now);
	now-=cnt-now;
if (now==cnt) now--;
    }
}
            nv.push_back(v2[i]);
            pr=v2[i];
        }
    }
reverse(nv.begin(),nv.end());
    vec=nv;
    nv.clear();
assert(vec[0]==1);
    return {p,vec};
}

Compilation message

light.cpp: In function 'iv join(long long int)':
light.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<vec.size();i++) {
      |                 ~^~~~~~~~~~~
light.cpp: In function 'iv leave(long long int)':
light.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<vec.size();i++) {
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct
2 Incorrect 1 ms 432 KB Not correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 258 ms 424 KB Correct
3 Correct 46 ms 432 KB Correct
4 Correct 271 ms 412 KB Correct
5 Correct 255 ms 344 KB Correct
6 Incorrect 1 ms 600 KB Not correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 258 ms 424 KB Correct
3 Correct 46 ms 432 KB Correct
4 Correct 271 ms 412 KB Correct
5 Correct 255 ms 344 KB Correct
6 Incorrect 1 ms 600 KB Not correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 258 ms 424 KB Correct
3 Correct 46 ms 432 KB Correct
4 Correct 271 ms 412 KB Correct
5 Correct 255 ms 344 KB Correct
6 Incorrect 1 ms 600 KB Not correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 258 ms 424 KB Correct
3 Correct 46 ms 432 KB Correct
4 Correct 271 ms 412 KB Correct
5 Correct 255 ms 344 KB Correct
6 Incorrect 1 ms 600 KB Not correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 258 ms 424 KB Correct
3 Correct 46 ms 432 KB Correct
4 Correct 271 ms 412 KB Correct
5 Correct 255 ms 344 KB Correct
6 Incorrect 1 ms 600 KB Not correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Correct
2 Incorrect 1 ms 344 KB Not correct
3 Halted 0 ms 0 KB -