제출 #610926

#제출 시각아이디문제언어결과실행 시간메모리
610926PiejanVDCRoller Coaster Railroad (IOI16_railroad)C++17
컴파일 에러
0 ms0 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; const int mxN = (int)2e5+5; vector<int>st(8*mxN); int l,r,val; vector<int>lazy(8*mxN); int query(int i, int j, int p) { if(i > r || j < l) return 0; if(i >= l && j <= r) return st[p]+lazy[p]; int mid = (i+j)/2; lazy[2*p] += lazy[p]; lazy[2*p+1] += lazy[p]; lazy[p] = 0; return query(i, mid, 2*p) + query(mid+1, j, 2*p+1); } void update(int i, int j, int p) { if(i > r || j < l) return; if(i >= l && j <= r) { lazy[p] += val; return; } int mid = (i+j)/2; lazy[2*p] += lazy[p]; lazy[2*p+1] += lazy[p]; lazy[p] = 0; update(i, mid, 2*p); update(mid+1, j, 2*p+1); } long long plan_roller_coaster(vector<int>s, vector<int>t) { set<int>S; int n = (int)s.size(); for(auto z : s) S.insert(z); for(auto z : t) S.insert(z); map<int,int>rev; auto it = S.begin(); for(int i = 0 ; i < 2*n ; i++, it++) rev[*it] = i; for(int i = 0 ; i < n ; i++) { if(s[i] < t[i]) { auto ff = S.lower_bound(s[i]); auto ss = S.lower_bound(t[i]); ss--; l = rev[*ff], r = rev[*ss]; val = 1; update(0, 2*n-1, 1); } else if(s[i] > t[i]) { auto ss = S.lower_bound(s[i]); auto ff = S.lower_bound(t[i]); ss--; l = rev[*ff], r = rev[*ss]; val = -1; update(0, 2*n-1, 1); } } long long ret = 0; vector<int>in(n,0); for(int i = 0 ; i < 2*n ; i++) { l = r = i; int R = query(0, 2*n-1, 1) if(R > 1) ret = 1; /*R--; R = abs(R); while(R--) adj[i].push_back(i+1), in[i+1]++; if(i) adj[i].push_back(i-1), in[i-1]++;*/ } /*for(int i = 0 ; i < n ; i++) if((int)adj[i].size() != in[i]) ret = 1; stack<int>q; q.push(0); */ return ret; }

컴파일 시 표준 에러 (stderr) 메시지

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:72:9: error: expected ',' or ';' before 'if'
   72 |         if(R > 1)
      |         ^~
railroad.cpp:71:13: warning: unused variable 'R' [-Wunused-variable]
   71 |         int R = query(0, 2*n-1, 1)
      |             ^