제출 #1060661

#제출 시각아이디문제언어결과실행 시간메모리
1060661wood자리 배치 (IOI18_seats)C++17
5 / 100
4101 ms66912 KiB
#include "seats.h" #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 constexpr int N = 3e6; int sizze = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0}; void segtree(int n){ while(sizze < n) sizze*=2; fill(xmin,xmin+N,INT_MAX); fill(ymin,ymin+N,INT_MAX); } void sset(int i, int xx, int yy, int x, int lx, int rx); void sset(int i, int xx, int yy){ sset(i, xx, yy, 0, 0, sizze); } void sset(int i, int xx, int yy, int x, int lx, int rx){ if(rx-lx==1){ xmin[x]=xmax[x]=xx; ymin[x]=ymax[x]=yy; return; } int m = (lx+rx)/2; if(i<m)sset(i,xx,yy,2*x+1,lx,m); else sset(i,xx,yy,2*x+2,m,rx); xmin[x] = min(xmin[2*x+1],xmin[2*x+2]); ymin[x] = min(ymin[2*x+1],ymin[2*x+2]); xmax[x] = max(xmax[2*x+1],xmax[2*x+2]); ymax[x] = max(ymax[2*x+1],ymax[2*x+2]); } vi getrange(int l, int r, int x, int lx, int rx); vi getrange(int l ,int r){ return getrange(l, r, 0, 0, sizze); } vi getrange(int l, int r, int x, int lx, int rx){ if(lx>=r||rx<=l)return vi({INT_MAX,0,INT_MAX,0}); else if(lx>=l&&rx<=r)return vi({xmin[x],xmax[x],ymin[x],ymax[x]}); int m = (rx+lx)/2; vi a = getrange(l,r,2*x+1,lx,m), b = getrange(l,r,2*x+2,m,rx); return vi({min(a[0],b[0]),max(a[1],b[1]),min(a[2],b[2]), max(a[3],b[3])}); } vi xs, ys; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { segtree(H*W); for(int i = 0; i<H*W; i++){ xmin[i + sizze - 1] = xmax[i + sizze - 1] = R[i]; xs.pb(R[i]); ymin[i + sizze - 1] = ymax[i + sizze - 1] = C[i]; ys.pb(C[i]); } for(int x = sizze - 2; x >= 0; x--){ xmin[x] = min(xmin[2*x+1],xmin[2*x+2]); ymin[x] = min(ymin[2*x+1],ymin[2*x+2]); xmax[x] = max(xmax[2*x+1],xmax[2*x+2]); ymax[x] = max(ymax[2*x+1],ymax[2*x+2]); } } int swap_seats(int a, int b) { int cur = 1; swap(xs[a],xs[b]); swap(ys[a],ys[b]); sset(a,xs[a],ys[a]); sset(b,xs[b],ys[b]); int cnt = 0; while(cur<=xs.size()){ vi v = getrange(0,cur); if((v[1]-v[0]+1)*(v[3]-v[2]+1)==cur){ cnt++; cur++; } else cur =(v[1]-v[0]+1)*(v[3]-v[2]+1); } return cnt; }

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

seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:88:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     while(cur<=xs.size()){
      |           ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...