交互题checker.cc求助
  • 板块学术版
  • 楼主BlackPanda
  • 当前回复20
  • 已保存回复20
  • 发布时间2023/2/2 16:50
  • 上次更新2023/10/24 02:02:15
查看原帖
交互题checker.cc求助
486799
BlackPanda楼主2023/2/2 16:50
#include "testlib.h"
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[500010], f[500010], cnt, sum;
int main(int argc, char* argv[]) {
	setName("Interactor LCS");
    registerInteraction(argc, argv);
    rnd.setSeed(time(NULL));
    int n = rnd.next(1,100000);
	cout << n << endl;
	for (int i = 1; i <= n; i ++ )
	{
		 a[i] = rnd.next(1000000000);
		cout <<  a[i] << " ";
	}
    cin >> sum;
    cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (f[cnt] <  a[i]) {
            f[++cnt] =  a[i];
        }
        else {
            *(lower_bound(f + 1, f + cnt,  a[i])) =  a[i];
        }
    }
    if (sum != cnt)
    {
    	quitf(_wa, "LCS expected %d, found %d",cnt, sum); 
	}
	else
	{
		quitf(_ok, "answer of LCS is %d",cnt);
	}
    return 0;
}
2023/2/2 16:50
加载中...