QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#299762#7569. LinesOAleksaWA 2ms9680kbC++141.8kb2024-01-07 06:55:402024-01-07 06:55:41

Judging History

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

  • [2024-01-07 06:55:41]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9680kb
  • [2024-01-07 06:55:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
const int N = 3e5 + 60;
int bst[4 * N], n, a[N], b[N], c[N];
struct line {
	int k, n;
	int fun(int x) {
		return k * x + n;
	}
	long double inter(line l) {
		return (l.n - n) / (k - l.k);
	}
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n;
  	for (int i = 0;i <= n;i++)
  		cin >> a[i];
  	for (int i = 0;i <= n;i++)
  		cin >> b[i];
  	for (int i = 0;i <= n;i++)
  		cin >> c[i];
  	vector<long double> pts;
  	auto Build = [&](int x[]) {
  		deque<line> g;
	    for (int i=n;i>=0;i--)
	    {
	      line t ={i,x[i]};
	      while (g.size()>=2 && t.inter(g[0])>=g[0].inter(g[1]))
	        g.pop_front();
	      g.push_front(t);
	      if (g.size()>=2)
	        pts.push_back(g[0].inter(g[1]));
	    }
	    return g;
  	};
  	deque<line> ca = Build(a);
  	deque<line> cb = Build(b);
  	deque<line> cc = Build(c);
  	vector<int> ans;
  	int pr = ca[0].k + cb[0].k + cc[0].k;
  	pts.push_back(-3e9);
  	pts.push_back(3e9);
  	sort(pts.begin(), pts.end());
  	for (auto x : pts) {
  		while (ca.size() >= 2 && ca[0].fun(x) <= ca[1].fun(x))
  			ca.pop_front();
  		while (cb.size() >= 2 && cb[0].fun(x) <= cb[1].fun(x))
  			cb.pop_front();
  		while (cc.size() >= 2 && cc[0].fun(x) <= cc[1].fun(x))
  			cc.pop_front();
  		int y = ca[0].k + cb[0].k + cc[0].k;
  		bst[y] = 1;
  	}
  	for (int i = 0;i <= pr;i++) {
  		if (bst[i])
  			break;
  		bst[i] = 1;
  	}
  	pr = ca[0].k + cb[0].k + cc[0].k;
  	for (int i = pr;i <= 3 * n;i++)
  		bst[i] = 1;
  	for (int i = 0;i <= 3 * n;i++) {
  		if (!bst[i])
  			ans.push_back(i);
  	}
  	cout << ans.size() << '\n';
  	for (auto u : ans)
  		cout << u << " ";
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9624kb

input:

3
3 1 8 7
9 1 3 1
5 1 1 6

output:

5
1 3 4 7 8 

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 9640kb

input:

1
1 2
1 2
1 2

output:

2
1 2 

result:

ok 3 number(s): "2 1 2"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 9680kb

input:

252
336470888 634074578 642802746 740396295 773386884 579721198 396628655 503722503 971207868 202647942 2087506 268792718 46761498 443917727 16843338 125908043 691952768 717268783 787375312 150414369 693319712 519096230 45277106 856168102 762263554 674936674 407246545 274667941 279198849 527268921 1...

output:

734
4 5 7 9 10 11 12 14 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 10...

result:

wrong answer 1st numbers differ - expected: '733', found: '734'