# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249883 | Mercenary | 사다리꼴 (balkan11_trapezoid) | C++14 | 99 ms | 6644 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define pb push_back
#define mp make_pair
#define taskname "A"
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int maxn = 1e5 + 5;
const int logn = log2(maxn) + 1;
const int mod = 30013;
void add(int & x , int y){
x += y;
if(x >= mod)x -= mod;
}
struct node{
int a , b , c , d;
bool operator < (const node other){
return a < other.a;
}
}a[maxn];
ii operator + (const ii a , const ii b){
if(a.first != b.first)return max(a,b);
return mp(a.first, (a.second + b.second) % mod);
}
int n;
ii s[maxn * 4];
void update(int x , ii val){
for( ; x <= n ; x += x & -x){
s[x] = s[x] + val;
}
}
ii query(int x){
ii res = mp(0,0);
for( ; x > 0 ; x &= x - 1)res = res + s[x];
return res;
}
ii dp[maxn];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname".INP","r")){
freopen(taskname".INP", "r",stdin);
freopen(taskname".OUT", "w",stdout);
}
vector<int> val;
cin >> n;
for(int i = 1 ; i <= n ; ++i){
cin >> a[i].a >> a[i].b >> a[i].c >> a[i].d;
val.pb(a[i].d);
}
sort(val.begin(),val.end());
priority_queue<ii,vector<ii>,greater<ii>> pq;
sort(a + 1 , a + n + 1);
ii res = mp(0,1);
for(int i = 1 ; i <= n ; ++i){
while(pq.size() && pq.top().first < a[i].a){
update(lower_bound(val.begin(),val.end(),a[pq.top().second].d)-val.begin()+1,dp[pq.top().second]);
pq.pop();
}
dp[i] = query(lower_bound(val.begin(),val.end(),a[i].c) - val.begin());
if(dp[i].first == 0)dp[i] = mp(0 , 1);
dp[i].first++;
res = res + dp[i];
pq.push(mp(a[i].b , i));
}
cout << res.first << " " << res.second << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |