Submission #1048547

# Submission time Handle Problem Language Result Execution time Memory
1048547 2024-08-08T08:15:21 Z pcc Ancient Books (IOI17_books) C++17
0 / 100
5 ms 2396 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int mxn = 1e6+10;
int N;
int l[mxn],r[mxn];

long long minimum_walk(std::vector<int> p, int s) {
	ll ans = 0;
	N = p.size();
	for(int i = 0;i<N;i++){
		if(p[i] == i)continue;
		int a = i,b = p[i];
		if(a<b){
			l[a]++;
			l[b]--;
		}
		else{
			r[b]++;
			r[a]--;
		}
	}
	for(int i = 1;i<N;i++){
		l[i] += l[i-1];
		r[i] += r[i-1];
	}
	int rp = 0;
	for(int i = 0;i+1<N;i++){
		if(max(l[i],r[i]) != 0)rp = i;
	}
	for(int i = 0;i+1<N;i++)cerr<<l[i]<<' ';cerr<<endl;
	for(int i = 0;i+1<N;i++)cerr<<r[i]<<' ';cerr<<endl;
	for(int i = 0;i+1<N;i++){
		if(rp<i)break;
		ans += max({l[i],r[i],1})<<1;
	}
	return ans;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:33:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   33 |  for(int i = 0;i+1<N;i++)cerr<<l[i]<<' ';cerr<<endl;
      |  ^~~
books.cpp:33:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   33 |  for(int i = 0;i+1<N;i++)cerr<<l[i]<<' ';cerr<<endl;
      |                                          ^~~~
books.cpp:34:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   34 |  for(int i = 0;i+1<N;i++)cerr<<r[i]<<' ';cerr<<endl;
      |  ^~~
books.cpp:34:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   34 |  for(int i = 0;i+1<N;i++)cerr<<r[i]<<' ';cerr<<endl;
      |                                          ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '0', found: '2'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '0', found: '2'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '0', found: '2'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2392 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '0', found: '2'
10 Halted 0 ms 0 KB -