제출 #993511

#제출 시각아이디문제언어결과실행 시간메모리
993511wood던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> p32; typedef pair<ll,ll> p64; #define pb push_back #define eb emplace_back #define fi first #define se second #define vi vector<int> #define vp32 vector<p32> #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define MOD %1000000007 #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //never guess //never debug without reviewing code //never try adding ones or substracting them //only step by step debug when necessay struct segtree { int size = 1, ops[(int)1e6] = {0}; segtree(int n){while(size<n) size*=2;} void upd(int l, int r){ upd(l,r,0,0,size); } void upd(int l, int r, int x, int lx, int rx) { if(lx>=r||rx<=l) return; if(lx>=l&&rx<=r){ ops[x]++; return; } int m = (rx+lx)/2; upd(l,r,2*x+1,lx,m); upd(l,r,2*x+2,m,rx); } int get(int i){ return get(i,0,0,size); } int get(int i, int x, int l, int r){ if(r-l==1) return ops[x]; int m = (r+l)/2; if(i<m) return get(i,2*x+1,l,m)+ops[x]; else return get(i,2*x+2,m,r)+ops[x]; } }; int main() { fast_cin(); #ifndef ONLINE_JUDGE #ifdef _WIN32 freopen("input.in", "r", stdin); freopen("input.out", "w", stdout); #endif #endif int n; cin>>n; p32 arr [n]; for(p32 & sub : arr){ cin>>sub.fi>>sub.se; } sort(arr,arr+n); segtree sgt(1e5); for (size_t i = 0; i < n; i++) { int left = arr[i].fi-arr[i].se; int l = -1, r = arr[i].fi; while(r-l>1){ int m = (r+l)/2; if(sgt.get(m)>=sgt.get(left)) l = m; else r = m; } int done = 0; if(r<arr[i].fi){ sgt.upd(r,arr[i].fi); done = arr[i].fi - r; } l = -1, r = arr[i].fi; while(r-l>1){ int m = (r+l)/2; if(sgt.get(m)>sgt.get(left)) l = m; else r = m; } sgt.upd(r,r-done+arr[i].se); } ll res = 0; for (size_t i = 0; i < 1e5; i++) { ll x = sgt.get(i); res+=x*(x-1)/2; } cout<<res<<'\n'; return 0; }

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

dungeons.cpp: In function 'int main()':
dungeons.cpp:71:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |     for (size_t i = 0; i < n; i++)
      |                        ~~^~~
/usr/bin/ld: /tmp/ccZQr9xC.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccfjwtbC.o:dungeons.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccZQr9xC.o: in function `main':
grader.cpp:(.text.startup+0x3bd): undefined reference to `init(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x440): undefined reference to `simulate(int, int)'
collect2: error: ld returned 1 exit status