QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#298392 | #7569. Lines | sofija6 | Compile Error | / | / | C++23 | 5.4kb | 2024-01-06 07:17:00 | 2024-01-06 07:17:00 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define MAXN 300010
using namespace std;
ll a[MAXN],b[MAXN],c[MAXN];
bool maxx[3*MAXN];
struct line
{
long double k,m;
long double Calc(long double x)
{
return k*x+m;
}
long double Intersect(line l)
{
return (m-l.m)/(l.k-k);
}
};
set<long double> t;
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
for (ll i=0;i<=n;i++)
cin >> a[i];
for (ll i=0;i<=n;i++)
cin >> b[i];
for (ll i=0;i<=n;i++)
cin >> c[i];
deque<line> da,db,dc;
da.push_back({n,a[n]});
for (ll i=n-1;i>=0;i--)
{
line cur={i,a[i]};
while (da.size()>=2 && cur.Intersect(da[0])>=da[0].Intersect(da[1]))
da.pop_front();
da.push_front(cur);
if (da.size()>=2)
t.insert(da[0].Intersect(da[1]));
}
db.push_back({n,b[n]});
for (ll i=n-1;i>=0;i--)
{
line cur={i,b[i]};
while (db.size()>=2 && cur.Intersect(db[0])>=db[0].Intersect(db[1]))
db.pop_front();
db.push_front(cur);
if (db.size()>=2)
t.insert(db[0].Intersect(db[1]));
}
dc.push_back({n,c[n]});
for (ll i=n-1;i>=0;i--)
{
line cur={i,c[i]};
while (dc.size()>=2 && cur.Intersect(dc[0])>=dc[0].Intersect(dc[1]))
dc.pop_front();
dc.push_front(cur);
if (dc.size()>=2)
t.insert(dc[0].Intersect(dc[1]));
}
ll sum;
sum=da[0].k+db[0].k+dc[0].k;
t.insert(2e9);
t.insert(-2e9);
for (auto x : t)
{
while (da.size()>1 && da[0].Calc(x)<da[1].Calc(x))
da.pop_front();
while (db.size()>1 && db[0].Calc(x)<db[1].Calc(x))
db.pop_front();
while (dc.size()>1 && dc[0].Calc(x)<dc[1].Calc(x))
dc.pop_front();
vector<ll> inda,indb,indc;
inda.push_back((ll)da[0].k);
indb.push_back((ll)db[0].k);
indc.push_back((ll)dc[0].k);
for (ll i : inda)
{
for (ll j : indb)
{
for (ll k : indc)
maxx[i+j+k]=true;
}
}
}
for (ll i=0;i<=sum;i++)
{
if (maxx[i])
break;
maxx[i]=true;
}
sum=da[0].k+db[0].k+dc[0].k;
for (ll i=sum;i<=3*n;i++)
maxx[i]=true;
vector<ll> ans;
for (ll i=0;i<=3*n;i++)
{
if (!maxx[i])
ans.push_back(i);
}
cout << ans.size() << "\n";
for (ll i : ans)
cout << i << " ";
return 0;
}
/**
3
3 1 8 7
9 1 3 1
5 1 1 6
1
1 2
1 2
1 2
**/
#include <bits/stdc++.h>
#define ll long long
#define MAXN 300010
using namespace std;
ll a[MAXN],b[MAXN],c[MAXN];
bool maxx[3*MAXN];
struct line
{
long double k,m;
long double Calc(long double x)
{
return k*x+m;
}
long double Intersect(line l)
{
return (m-l.m)/(l.k-k);
}
};
set<long double> t;
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
for (ll i=0;i<=n;i++)
cin >> a[i];
for (ll i=0;i<=n;i++)
cin >> b[i];
for (ll i=0;i<=n;i++)
cin >> c[i];
deque<line> da,db,dc;
da.push_back({n,a[n]});
for (ll i=n-1;i>=0;i--)
{
line cur={i,a[i]};
while (da.size()>=2 && cur.Intersect(da[0])>=da[0].Intersect(da[1]))
da.pop_front();
da.push_front(cur);
if (da.size()>=2)
t.insert(da[0].Intersect(da[1]));
}
db.push_back({n,b[n]});
for (ll i=n-1;i>=0;i--)
{
line cur={i,b[i]};
while (db.size()>=2 && cur.Intersect(db[0])>=db[0].Intersect(db[1]))
db.pop_front();
db.push_front(cur);
if (db.size()>=2)
t.insert(db[0].Intersect(db[1]));
}
dc.push_back({n,c[n]});
for (ll i=n-1;i>=0;i--)
{
line cur={i,c[i]};
while (dc.size()>=2 && cur.Intersect(dc[0])>=dc[0].Intersect(dc[1]))
dc.pop_front();
dc.push_front(cur);
if (dc.size()>=2)
t.insert(dc[0].Intersect(dc[1]));
}
ll sum;
sum=da[0].k+db[0].k+dc[0].k;
t.insert(2e9);
t.insert(-2e9);
for (auto x : t)
{
while (da.size()>1 && da[0].Calc(x)<da[1].Calc(x))
da.pop_front();
while (db.size()>1 && db[0].Calc(x)<db[1].Calc(x))
db.pop_front();
while (dc.size()>1 && dc[0].Calc(x)<dc[1].Calc(x))
dc.pop_front();
vector<ll> inda,indb,indc;
inda.push_back((ll)da[0].k);
indb.push_back((ll)db[0].k);
indc.push_back((ll)dc[0].k);
for (ll i : inda)
{
for (ll j : indb)
{
for (ll k : indc)
maxx[i+j+k]=true;
}
}
}
for (ll i=0;i<=sum;i++)
{
if (maxx[i])
break;
maxx[i]=true;
}
sum=da[0].k+db[0].k+dc[0].k;
for (ll i=sum;i<=3*n;i++)
maxx[i]=true;
vector<ll> ans;
for (ll i=0;i<=3*n;i++)
{
if (!maxx[i])
ans.push_back(i);
}
cout << ans.size() << "\n";
for (ll i : ans)
cout << i << " ";
return 0;
}
/**
3
3 1 8 7
9 1 3 1
5 1 1 6
1
1 2
1 2
1 2
**/
詳細信息
answer.code: In function ‘int main()’: answer.code:32:19: warning: narrowing conversion of ‘n’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 32 | da.push_back({n,a[n]}); | ^ answer.code:32:24: warning: narrowing conversion of ‘a[n]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 32 | da.push_back({n,a[n]}); | ~~~^ answer.code:35:19: warning: narrowing conversion of ‘i’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 35 | line cur={i,a[i]}; | ^ answer.code:35:24: warning: narrowing conversion of ‘a[i]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 35 | line cur={i,a[i]}; | ~~~^ answer.code:42:19: warning: narrowing conversion of ‘n’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 42 | db.push_back({n,b[n]}); | ^ answer.code:42:24: warning: narrowing conversion of ‘b[n]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 42 | db.push_back({n,b[n]}); | ~~~^ answer.code:45:19: warning: narrowing conversion of ‘i’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 45 | line cur={i,b[i]}; | ^ answer.code:45:24: warning: narrowing conversion of ‘b[i]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 45 | line cur={i,b[i]}; | ~~~^ answer.code:52:19: warning: narrowing conversion of ‘n’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 52 | dc.push_back({n,c[n]}); | ^ answer.code:52:24: warning: narrowing conversion of ‘c[n]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 52 | dc.push_back({n,c[n]}); | ~~~^ answer.code:55:19: warning: narrowing conversion of ‘i’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 55 | line cur={i,c[i]}; | ^ answer.code:55:24: warning: narrowing conversion of ‘c[i]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 55 | line cur={i,c[i]}; | ~~~^ answer.code: At global scope: answer.code:122:4: error: redefinition of ‘long long int a [300010]’ 122 | ll a[MAXN],b[MAXN],c[MAXN]; | ^ answer.code:5:4: note: ‘long long int a [300010]’ previously declared here 5 | ll a[MAXN],b[MAXN],c[MAXN]; | ^ answer.code:122:12: error: redefinition of ‘long long int b [300010]’ 122 | ll a[MAXN],b[MAXN],c[MAXN]; | ^ answer.code:5:12: note: ‘long long int b [300010]’ previously declared here 5 | ll a[MAXN],b[MAXN],c[MAXN]; | ^ answer.code:122:20: error: redefinition of ‘long long int c [300010]’ 122 | ll a[MAXN],b[MAXN],c[MAXN]; | ^ answer.code:5:20: note: ‘long long int c [300010]’ previously declared here 5 | ll a[MAXN],b[MAXN],c[MAXN]; | ^ answer.code:123:6: error: redefinition of ‘bool maxx [900030]’ 123 | bool maxx[3*MAXN]; | ^~~~ answer.code:6:6: note: ‘bool maxx [900030]’ previously declared here 6 | bool maxx[3*MAXN]; | ^~~~ answer.code:124:8: error: redefinition of ‘struct line’ 124 | struct line | ^~~~ answer.code:7:8: note: previous definition of ‘struct line’ 7 | struct line | ^~~~ answer.code:136:18: error: redefinition of ‘std::set<long double> t’ 136 | set<long double> t; | ^ answer.code:19:18: note: ‘std::set<long double> t’ previously declared here 19 | set<long double> t; | ^ answer.code:137:5: error: redefinition of ‘int main()’ 137 | int main() | ^~~~ answer.code:20:5: note: ‘int main()’ previously defined here 20 | int main() | ^~~~ answer.code: In function ‘int main()’: answer.code:149:19: warning: narrowing conversion of ‘n’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 149 | da.push_back({n,a[n]}); | ^ answer.code:149:24: warning: narrowing conversion of ‘a[n]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 149 | da.push_back({n,a[n]}); | ~~~^ answer.code:152:19: warning: narrowing conversion of ‘i’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 152 | line cur={i,a[i]}; | ^ answer.code:152:24: warning: narrowing conversion of ‘a[i]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 152 | line cur={i,a[i]}; | ~~~^ answer.code:159:19: warning: narrowing conversion of ‘n’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 159 | db.push_back({n,b[n]}); | ^ answer.code:159:24: warning: narrowing conversion of ‘b[n]’ from ‘long long int’ to ‘long double’ [-Wnarrowing] 159 | db.push_back({n,b[n]}); | ~~~^ answer.code:162:19: warning: narrowing conversion of ‘i’ from ‘long long int’ to ‘long ...