답안 #776076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776076 2023-07-07T09:22:37 Z peteza 고대 책들 (IOI17_books) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;

int qs[1000005];
int lnz = -1, rnz = -1;
long long minimum_walk(std::vector<int> p, int s) {
    int cur = 0, cv = 0, curcnt = 0;
    long long cans = 0;
    for(int i=0;i<=p.size();i++) qs[i] = 0;
    for(int i=0;i<p.size();i++) {
        qs[min(i, p[i])]++; qs[max(i, p[i])]--;
    }
    for(int i=0;i<p.size();i++) {
        cv += qs[i];
        cans += cv;
        if(cv) {
            lnz = (lnz == -1 ? i : lnz);
            rnz = i;
        }
    }

    cv = 0;
    for(int i=0;i<p.size();i++) {
        cv += qs[i];
        cur += (!cv && lnz <= i && i <= rnz);
    }
	return cans + 2*cur;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<=p.size();i++) qs[i] = 0;
      |                 ~^~~~~~~~~~
books.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<p.size();i++) {
      |                 ~^~~~~~~~~
books.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<p.size();i++) {
      |                 ~^~~~~~~~~
books.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<p.size();i++) {
      |                 ~^~~~~~~~~
books.cpp:8:26: warning: unused variable 'curcnt' [-Wunused-variable]
    8 |     int cur = 0, cv = 0, curcnt = 0;
      |                          ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -