Normal data structure vs Struct/Class

Revision en1, by Roll_no_68, 2025-01-01 14:36:19

So i had recently encountered with problem 380C - Sereja and Brackets I solved this problem using vector<vector<int>> of size (4*n X 3) which results in TLE. 299190493.

Basic segment tree was looking like this

vector<vector<int>> seg;
SegmentTree(int n) {
	seg.resize(4 * n, {0ll, 0ll, 0ll});
}

Then i just replace this part of code with

class node {
public:
	int full;
	int opn;
	int cls;
};
vector<node> seg;
SegmentTree(int n) {
	seg.resize(4 * n);
}

And this code got accepted.299237670

Does this means using class or struct can reduce time complexity although i know 1st code will occupy more memory as compared to 2nd but i am not sure about time. If anyone have any insights, could you please explain why this happened? Do they differ in terms of time complexity?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Roll_no_68 2025-01-01 14:36:19 896 Initial revision (published)