Submission #1339173

#TimeUsernameProblemLanguageResultExecution timeMemory
1339173settop고대 책들 (IOI17_books)C++20
Compilation error
0 ms0 KiB
#include "books.h"
#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fall(i,a,b) for(int i=a;i<=b;i++)
#define rfall(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
typedef tuple<int,vector<int>,int> trio;

long long minimum_walk(std::vector<int> p, int s){
	int n=sz(p);
	int r=-1,nf=0,nv=0,ans=0;
	ordered_set st;
	int r=-1,nf=0,nv=0,ans=0;
	ordered_set st;
	fall(i,0,n-1){
		if(r>=i) continue;
		r=i;
		int j=i;
		while(j<=r){
			r=max(r,p[j]);
			j++;
		}
		if(r==i){
			nf++;
            if(i) nv++;
			continue;
		}
		ans+=nf+nv; nf=nv=0;
		st.clear();
		fall(j,i,r-1){
			st.insert(p[j]);
			int vai=sz(st)-st.order_of_key(j+1); ans+=vai;
		}
		st.clear();
		rfall(j,r,i+1){
			st.insert(p[j]);
			ans+=st.order_of_key(j);
		}
        nv++;
        if(i!=0) ans++;
	}
	return ans;
}

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:21:13: error: redeclaration of 'int r'
   21 |         int r=-1,nf=0,nv=0,ans=0;
      |             ^
books.cpp:19:13: note: 'int r' previously declared here
   19 |         int r=-1,nf=0,nv=0,ans=0;
      |             ^
books.cpp:21:18: error: redeclaration of 'int nf'
   21 |         int r=-1,nf=0,nv=0,ans=0;
      |                  ^~
books.cpp:19:18: note: 'int nf' previously declared here
   19 |         int r=-1,nf=0,nv=0,ans=0;
      |                  ^~
books.cpp:21:23: error: redeclaration of 'int nv'
   21 |         int r=-1,nf=0,nv=0,ans=0;
      |                       ^~
books.cpp:19:23: note: 'int nv' previously declared here
   19 |         int r=-1,nf=0,nv=0,ans=0;
      |                       ^~
books.cpp:21:28: error: redeclaration of 'int ans'
   21 |         int r=-1,nf=0,nv=0,ans=0;
      |                            ^~~
books.cpp:19:28: note: 'int ans' previously declared here
   19 |         int r=-1,nf=0,nv=0,ans=0;
      |                            ^~~
books.cpp:22:21: error: redeclaration of '__gnu_pbds::tree<int, __gnu_pbds::null_type, std::less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> st'
   22 |         ordered_set st;
      |                     ^~
books.cpp:20:21: note: '__gnu_pbds::tree<int, __gnu_pbds::null_type, std::less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> st' previously declared here
   20 |         ordered_set st;
      |                     ^~