| Task: | Island |
| Sender: | jsesok |
| Submission time: | 2026-09-22 15:33:18 +0300 |
| Language: | C++ (C++23) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:31:34: error: 'INT_MAX' was not declared in this scope
31 | vector<pair<int, int>> v(n, {INT_MAX, 0});
| ^~~~~~~
input/code.cpp:15:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
14 | #include <cmath>
+++ |+#include <climits>
15 | using namespace std;
input/code.cpp:31:45: error: no matching function for call to 'std::vector<std::pair<int, int> >::vector(int&, <brace-enclosed initializer list>)'
31 | vector<pair<int, int>> v(n, {INT_MAX, 0});
| ^
In file included from /usr/include/c++/13/vector:66,
from input/code.cpp:4:
/usr/include/c++/13/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> constexpr std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputItera...Code
#include <iostream>
#include <numeric>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, q, x, y, x2, y2, s=0;
cin>>n>>q;
vector<vector<char>> m(n, vector<char> (n));
for (int i=0; i<n; ++i)
{
for (int j=0; j<n; ++j)
{
cin>>m[i][j];
}
}
vector<pair<int, int>> v(n, {INT_MAX, 0});
for (int i=0; i<n; ++i)
{
for (int j=0; j<n; ++j)
{
if (m[i][j]=='#')
{
v[i].first=min(v[i].first, j);
v[i].second=j;
}
}
}
for (int i=0; i<q; ++i)
{
s=0;
cin>>x>>y>>x2>>y2;
x-=1;
y-=1;
x2-=1;
y2-=1;
if (x>x2)
{
swap(x, x2);
swap(y, y2);
}
s+=x2-x;
for (int j=x; j<=x2; ++j)
{
s+=max(0, v[j].first-y);
y+=max(0, v[j].first-y);
s+=max(0, y-v[j].second);
y-=max(0, y-v[j].second);
}
s+=abs(y-y2);
cout<<s<<"\n";
}
return 0;
}
