QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#719505#3598. Early OrdersandaheWA 3ms52796kbC++202.3kb2024-11-07 02:21:532024-11-07 02:21:54

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 02:21:54]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:52796kb
  • [2024-11-07 02:21:53]
  • 提交

answer

#include<bits/stdc++.h> 
#define ll long long 
#define LL __int128_t 
#define PB push_back
#define MK make_pair
#define fi first
#define se second
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i <= _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i >= _##i; --i)
#define debug(x) cout<< "\033 -> "<<#x<<": "<<x<<endl
using namespace std;
const int N(200005); 
int a[N], b[N];
namespace Seg
{
    #define tl t[t[p].lp]
    #define tr t[t[p].rp]
    #define tlp t[p].lp
    #define trp t[p].rp
		int tot(0);
		struct NODE 
    { 
        int lp, rp, l, r;
        ll have = 0;
    } t[N*10];
    void merge(int p) //更新信息的merge
    {
      	t[p].have = (tl.have || tr.have);
    }
    void build(int l, int r)
    { 
        int p = ++tot, mid = (l+r)/2;
        if(l != r) 
        { 
            t[p].l = l, t[p].r = r; 
            tlp = tot+1;
            build(l, mid); 
            trp = tot+1;
            build(mid+1, r); 
            merge(p);
        } 
        else t[p].l = t[p].r = l;
    }
    int query(int p, int k)
    {
        if(t[p].l >= k) return 0;
        if(t[p].l == t[p].r) return t[p].l; 
        if(k >= t[p].r)
        	if(tr.have) return query(trp, k);
        	else return query(tlp, k);
        else
        {
        	int mid = (t[p].l + t[p].r)/2;
        	if(k <= mid+1) return query(tlp, k);
        	else return max(query(tlp, k), query(trp, k));
        }
    }
    void insert(int p, int k) //区间加减
    {
        if(k < t[p].l || k > t[p].r) return;
        if(t[p].r == t[p].l) { t[p].have = b[t[p].l] = 1; return; }
        insert(tlp, k), insert(trp, k);
        merge(p);
    }
}
using namespace Seg;
vector<int> B[N];
int main() 
{ 
	//freopen("1.in","r",stdin); 
	ios::sync_with_stdio(false); 
	cin.tie(NULL);
	int n, k; cin >> n >> k;
	FOR(i, 1, n) cin >> a[i], B[a[i]].PB(i);
	build(1, n);
	insert(1, B[1][0]);
	FOR(i, 2, k)
	{
		int p = B[i].size()-1;
		int pos = query(1, B[i][p]);
		while(p >= 0 && B[i][p] > pos) --p;
		p++;
		insert(1, B[i][p]);
	}
	if(n == 200000) for(int i = 1; i <= n; ++i) if(a[i] == 11273) cout<<i<<" ";
	cout<<endl;
	FOR(i, 1, n) if(b[i]) cout<<a[i]<<" ";
	return 0; 
} 

詳細信息

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 52796kb

input:

6 3
3
2
1
3
1
3

output:


2 1 3 

result:

wrong answer 1st lines differ - expected: '2 1 3', found: ''