我是竞争编程的初学者。我遇到了一个问题,所以我查看我遵循的个人密码。
I didn't understand this following part particularly:
int i,n,a[1005]={},b;
vector<int>v;
cin>>n;
for(i=0;i<n;i++)
{
cin>>b;
if(!a[b])v.push_back(b);
a[b]=i+1;
}
here, what does the condition "if(!a[b])" denote? I could not find it on google.
Please help me. Thank you
!
表示not
运算符。这就是检查变量值的对立面的方法。这是在检查元素b
处的数组a
是否存在。如果不存在!a[b]
,则将b
推入向量v
并更新a[b]
。否则,不执行任何操作,只更新a[b]
。