제출 #988070

#제출 시각아이디문제언어결과실행 시간메모리
988070wood자리 배치 (IOI18_seats)C++17
17 / 100
4046 ms56512 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 namespace potato{ int H,W; vi R,C; } vector<bool> res; int ressum = 1; vi rmin,rmax,cmin,cmax; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { potato::H = H, potato::W = W, potato::R = R, potato::C = C; int n = H*W; res.resize(n); rmin.resize(n); rmax.resize(n); cmin.resize(n); cmax.resize(n); rmin[0] = R[0], rmax[0] = R[0], cmin[0] = C[0], cmax[0] = C[0]; for (size_t i = 1; i < H*W; i++) { rmin[i] = min(rmin[i-1],R[i]); rmax[i] = max(rmax[i-1],R[i]); cmin[i] = min(cmin[i-1],C[i]); cmax[i] = max(cmax[i-1],C[i]); if(i+1==(rmax[i]-rmin[i]+1)*(cmax[i]-cmin[i]+1)){ ressum++; res[i] = true;; } } } int swap_seats(int a, int b) { using namespace potato; swap(R[a],R[b]); swap(C[a],C[b]); if(a>b) swap(a,b); rmin[0] = R[0], rmax[0] = R[0], cmin[0] = C[0], cmax[0] = C[0]; for(int i = max(a,1); i<b; i++){ if(res[i]) ressum--; res[i] = false; rmin[i] = min(rmin[i-1],R[i]); rmax[i] = max(rmax[i-1],R[i]); cmin[i] = min(cmin[i-1],C[i]); cmax[i] = max(cmax[i-1],C[i]); if(i+1==(rmax[i]-rmin[i]+1)*(cmax[i]-cmin[i]+1)){ ressum++; res[i] = true; } } return ressum; } // int main(int argc, char const *argv[]) // { // give_initial_chart(1,3,{0,0,0},{0,1,2}); // cout<<swap_seats(1,2)<<'\n'; // cout<<swap_seats(1,2)<<'\n'; // return 0; // }

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

seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:39:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     for (size_t i = 1; i < H*W; i++)
      |                        ~~^~~~~
seats.cpp:43:15: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   43 |         if(i+1==(rmax[i]-rmin[i]+1)*(cmax[i]-cmin[i]+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...