L题 与能过的代码构造的是一模一样的 但是只通过76.47%
如题,以下是我的代码,其中get()是我的构造,get2()是我看有人ac的代码,两个构造出来的数组是一样的。。但是没ac
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
vector<int> a,b,c;
vector<int> a2,b2,c2;
// bool vis[5*N];
void get(){
int ai=1,bi=2,ci=4;
a.push_back(ai);
b.push_back(bi);
c.push_back(ci);
bool f=1;
while (ci<=1e6)
{
if(f){
ai+=2;
ci+=2;
}
else{
ai+=4;
ci+=4;
}
bi+=3;
a.push_back(ai);
b.push_back(bi);
c.push_back(ci);
if(f) f=0;
else f=1;
}
}
void get2(){
int n=1e6;
int ans=1e6/3;
for(int i=0;i<ans;i++){
if(n%6==3&&i==ans-2){
a2.push_back(i*3);
b2.push_back(2+i*3);
c2.push_back(6+i*3);
}
else if(n%6==3&&i==ans-1){
a2.push_back(1+i*3);
b2.push_back(2+i*3);
c2.push_back(i*3);
}
else if(i%2==0){
a2.push_back(1+i*3);
b2.push_back(2+i*3);
c2.push_back(4+i*3);
}
else{
a2.push_back(i*3);
b2.push_back(2+i*3);
c2.push_back(3+i*3);
}
}
}
void solve(){
int n;
cin>>n;
int sz = a.size();
int l=0,r=sz-1;
while (l<r)
{
int mid = l+r>>1;
if(c[mid]>n) r=mid;
else l=mid+1;
}
// auto it = upper_bound(c.begin(), c.end(), n);
int cnt= l+1;
cout<<cnt<<endl;
for(int i=0;i<cnt;i++){
cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
}
}
void cmp(){
for(int i=0;i<a2.size();i++){
if(a[i]!=a2[i]||b[i]!=b2[i]||c[i]!=c2[i]){
cout<<i<<" "<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\t";
cout<<i<<" "<<a2[i]<<" "<<b2[i]<<" "<<c2[i]<<endl;
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// int T;
// cin>>T;
get();
get2();
cmp();
// while(T--){
// solve();
// }
}
海康威视公司福利 1125人发布