QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#318141 | #3558. Constellation 3 | toj | Compile Error | / | / | C++14 | 1.2kb | 2024-01-30 16:22:43 | 2024-01-30 16:22:43 |
Judging History
This is the latest submission verdict.
- [2024-01-30 16:22:43]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-01-30 16:22:43]
- Submitted
answer
// S2OJ Submission #1173 @ 1706602962448
#include <bits/stdc++.h>
using namespace std;
//const int maxn = 2e5+5;
struct dsu{
vector<int> next;
dsu(int n) : next(n+2){
for(int i=0;i<=n+1;i++) next[i] = i;
}
int find(int x){
return next[x] == x? x:next[x] = find(next[x]);
}
};
struct fenwick{
vector<long long> a;
fenwick(int n) : a(n+1){
}
long long sum(int i){
long long ans = 0;
while(i>0) ans+=a[i],i-=i&-i;
return ans;
}
void add(int i,long long x){
while(i<a.size()){
a[i] += x;
i += i&-i;
}
}
};
int main(){
int n;
cin>>n;
vector<vector<int> > z(n+1);
for(int i=1;i<=n;i++){
int a;
cin>>a;
z[a].push_back(i);
}
int m;
cin>>m;
vector<vector<pair<int,int> > > star(n+1);
for(int i=0;i<m;i++){
int x,y,c;
cin>>x>>y>>c;
star[y].push_back({x,c});
}
fenwick cost(n);
dsu L(n),R(n);
for(int y = 1;y<=n;y++){
for(auto s : star[y]){
int x = s.first(),c = s.second();
long long C = cost.sum(x);
if(c<=C) ans+=c;
else{
ans += C;
int l =L.find(x),r = R.find(x);
cost.add(l+1,c-C);
cost.add(r,C-c);
}
}
}
for(int x:z[y]){
L.next[x] = x-1;
R.next[x] = x+1;
}
cout<<ans;
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:52:40: error: expression cannot be used as a function 52 | int x = s.first(),c = s.second(); | ~~~~~~~^~ answer.code:54:28: error: ‘c’ was not declared in this scope 54 | if(c<=C) ans+=c; | ^ answer.code:54:34: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 54 | if(c<=C) ans+=c; | ^~~ | abs answer.code:56:33: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 56 | ans += C; | ^~~ | abs answer.code:63:21: error: ‘y’ was not declared in this scope 63 | for(int x:z[y]){ | ^ answer.code:67:15: error: ‘ans’ was not declared in this scope; did you mean ‘abs’? 67 | cout<<ans; | ^~~ | abs