제출 #297214

#제출 시각아이디문제언어결과실행 시간메모리
297214muhammad_hokimiyon자리 배치 (IOI18_seats)C++14
0 / 100
2448 ms56696 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1000007; int h,w; int t[4 * maxn]; int lz[4 * maxn]; int mn[4 * maxn]; vector < vector < int > > a; int comb( int x1 , int x2 ) { if( mn[x1] == mn[x2] ){ return t[x1] + t[x2]; } if( mn[x1] < mn[x2] ){ return t[x1]; } return t[x2]; } void push( int x ) { lz[x + x] += lz[x]; lz[x + x + 1] += lz[x]; mn[x + x] += lz[x]; mn[x + x + 1] += lz[x]; lz[x] = 0; } void build( int x , int l , int r ) { t[x] = r - l + 1; if( l == r )return; int m = (l + r) / 2; build( x + x , l , m ); build( x + x + 1 , m + 1 , r ); } void upd( int x , int l , int r , int tl , int tr , int val ) { tr = min( tr , r ); if( tl > tr )return; if( tl == l && tr == r ){ lz[x] += val; mn[x] += val; return; } int m = (l + r) / 2; push( x ); upd( x + x , l , m , tl , min( tr , m ) , val ); upd( x + x + 1 , m + 1 , r , max( tl , m + 1 ) , tr , val ); t[x] = comb( x + x , x + x + 1 ); } void ok( int i , int j , int val ) { if( i > h || j > w )return; int cnt = 0; vector < int > g; g.push_back(a[i][j]); g.push_back(a[i - 1][j]); g.push_back(a[i][j - 1]); g.push_back(a[i - 1][j - 1]); sort( g.begin() , g.end() ); pair < int , int > res = {-1 , -1}; if( g[0] == a[i][j] ){ upd( 1 , 1 , h * w , g[0] , g[1] - 1 , val ); } if( g[3] != 1e9 ){ upd( 1 , 1 , h * w , g[2] , g[3] - 1 , val ); } } vector < int > r,c; void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { h = H; w = W; r = R; c = C; build( 1 , 1 , h * w ); a.resize(H + 10); for( int i = 0; i < H + 10; i++ ){ a[i].resize(W + 10); } for( int i = 0; i < W + 10; i++ ){ a[0][i] = a[h + 1][i] = 1e9; } for( int i = 0; i < H + 10; i++ ){ a[i][0] = a[i][W + 1] = 1e9; } for( int i = 0; i < H * W; i++ ){ a[R[i] + 1][C[i] + 1] = i + 1; } for( int i = 1; i <= H; i++ ){ for( int j = 1; j <= W; j++ ){ ok( i , j , 1 ); } } } int swap_seats(int a1, int b) { int x1 = r[a1] + 1; int y1 = c[a1] + 1; int x2 = r[b] + 1; int y2 = c[b] + 1; for( int i = 0; i <= 1; i++ ){ for( int j = 0; j <= 1; j++ ){ ok( i + x1 , j + y1 , -1 ); ok( i + x2 , j + y2 , -1 ); } } swap( a[r[a1] + 1][c[a1] + 1] , a[r[b] + 1][c[b] + 1] ); swap( r[a1] , r[b] ); swap( c[a1] , c[b] ); for( int i = 0; i <= 1; i++ ){ for( int j = 0; j <= 1; j++ ){ ok( i + x1 , j + y1 , 1 ); ok( i + x2 , j + y2 , 1 ); } } return t[1]; }

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

seats.cpp: In function 'void ok(int, int, int)':
seats.cpp:62:9: warning: unused variable 'cnt' [-Wunused-variable]
   62 |     int cnt = 0;
      |         ^~~
seats.cpp:69:24: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   69 |     pair < int , int > res = {-1 , -1};
      |                        ^~~
#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...