Submission #927730

#TimeUsernameProblemLanguageResultExecution timeMemory
927730MrDebooSeats (IOI18_seats)C++17
0 / 100
4107 ms262144 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; using ordered_set = tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>; vector<pair<int,int>>v; bool hehe=0; map<int,ordered_set>a,b; int slv(int in){ pair<pair<int,int>,pair<int,int>>pr={{v[in].first,v[in].first},{v[in].second,v[in].second}}; for(int i=in;i>=0;i--){ pr.first.first=min(pr.first.first,v[i].first); pr.first.second=max(pr.first.second,v[i].first); pr.second.first=min(pr.second.first,v[i].second); pr.second.second=max(pr.second.second,v[i].second); } return (in+1==(pr.second.second-pr.second.first+1)*(pr.first.second-pr.first.first+1)); } void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { if(H==1)hehe=1; v.resize(H*W); for(int i=0;i<H*W;i++){ v[i]={R[i],C[i]}; if(i)a[C[i]+i].insert(C[i]); if(i)b[C[i]-i].insert(C[i]); } } void rmv(int in){ if(in==0)return; a[v[in].second+in].erase(v[in].second); b[v[in].second-in].erase(v[in].second); } void ad(int in){ if(in==0)return; a[v[in].second+in].insert(v[in].second); b[v[in].second-in].insert(v[in].second); } int clc(){ int g=v[0].second; int ans=0; ans+=a[g].order_of_key(g); ans+=b[g].size()-b[g].order_of_key(g); } int swap_seats(int a, int b){ if(hehe){ rmv(a); rmv(b); swap(v[a],v[b]); ad(a); ad(b); return clc(); } int ans=0; swap(v[a],v[b]); pair<pair<int,int>,pair<int,int>>pr={{v[0].first,v[0].first},{v[0].second,v[0].second}}; for(int i=0;i<v.size();i++){ pr.first.first=min(pr.first.first,v[i].first); pr.first.second=max(pr.first.second,v[i].first); pr.second.first=min(pr.second.first,v[i].second); pr.second.second=max(pr.second.second,v[i].second); if(i+1==(pr.second.second-pr.second.first+1)*(pr.first.second-pr.first.first+1))ans++; } return ans; }

Compilation message (stderr)

seats.cpp: In function 'int clc()':
seats.cpp:44:1: warning: no return statement in function returning non-void [-Wreturn-type]
   44 | }
      | ^
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
#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...