error messages:
No operator ">>" matches these operands
-- Operand type: std::istream>>graphC/C++(349)
source code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
inth,w;
vector<vector<int>>P[9][10001];
cin>>h>>w;
for(inti=1;i<=h;i++){
For(int j=1;j<=w;j++)cin>>P[i][j];// An error occurs in the > part of this line.
}
return 0;
}
Subjectively, what we were looking for was an array of arrays in two dimensions.
std::vector<T>v1;
by itself, where v1
is a variable-length array (in this notation, the number of elements is 0)
std::vector<std::vector<T>>v2;
, where v2
is "variable length array with variable length array elements" (this is not practical since there are only 0 arrays with zero elements).
Therefore, std::vector<std::vector<int>v3[9][10001];
becomes a "fixed length array of fixed length arrays" of "variable length arrays with variable length arrays as elements" and becomes a four-dimensional array.
If you want a fixed-length two-dimensional array, the answer is int P[9][10001];
.
The following is an aside
The first step for tomorrow: std::vector<int>vec(10001);
and cCompatible ArrayTr[1000] memory placement is different.When you can imagine this
The second step for tomorrow: std::vector<std::vector<int>>v2;
will now be able to imagine what memory placement looks like.Then you will understand what code is needed to increase the number of elements in v2
.
Furthermore
The default stack size for Win32(x86) is 1MiB
intP[9][10001];
is 351.6KiB
So you can't create at most three P
automatic variables. You can create as many vector
as memory allows, so it's not bad to learn how to use vector
properly for the future, but it's also a good option to make it a normal automatic variable based on YAGNI rules.
#include<bits/stdc++.h>do not manage
or large area
to be able to ask questions tagged with c++ in the futureThis writing style is non-standard specific to the competition programming industry.If Oira's subordinates write something like this, I'll go back to the source code review.
© 2024 OneMinuteCode. All rights reserved.