submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s195937662 | p03706 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
int main() {
string S;
cin >> S;
int N = S.size();
int ans = (N-1)*(N-1);
for(int i=0; i<N; i++){
if(i == 0 || i == N-1){
continue;
}
else if(S[i] == "U"){
ans += i;
}
else{
ans += N-1-i;
}
}
cout << ans << endl;
}
| cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:13:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
13 | else if(S[i] == "U"){
|
s358850515 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N=2010;
int sump[N][N],sume1[N][N],sume2[N][N];
bool mp[N][N];
int main()
{
static char s[N];
int n,m,q;cin>>n>>m>>q;
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
for(int j=1;j<=m;j++)
mp[i][j]=(s[j]=='1');
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
sump[i][j]=sump[i-1][j]+sump[i][j-1]-sump[i-1][j-1]+mp[i][j];
sume1[i][j]=sume1[i-1][j]+sume1[i][j-1]-sume1[i-1][j-1]+(mp[i][j]&&mp[i][j+1]);
sume2[i][j]=sume2[i-1][j]+sume2[i][j-1]-sume2[i-1][j-1]+(mp[i][j]&&mp[i+1][j]);
}
while(q--)
{
int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int n=sump[x2][y2]-sump[x1-1][y2]-sump[x2][y1-1]+sump[x1-1][y1-1];
int m=sume1[x2][y2-1]-sume1[x2][y1-1]-sume1[x1-1][y2-1]+sume1[x1-1][y1-1];
m+=sume2[x2-1][y2]-sume2[x2-1][y1-1]-sume2[x1-1][y2]+sume2[x1-1][y1-1];
printf("%d\n",n-m);
}
flush();
return 0;
} | a.cc: In function 'int main()':
a.cc:33:10: error: no matching function for call to 'flush()'
33 | flush();
| ~~~~~^~
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
766 | flush(basic_ostream<_CharT, _Traits>& __os)
| ^~~~~
/usr/include/c++/14/ostream:766:5: note: candidate expects 1 argument, 0 provided
|
s764777630 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 998244353;
const int N = 1005;
const int K = 3000;
const ll INF = 1e18;
ll n,m,q;
int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
char w;
int main () {
faster
cin>>n>>m>>q;
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
cin>>w;
if (w == '1') a[i][j] = 1;
}
}
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + (a[i][j] == a[i][j-1] && a[i][j] == 1);
r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + (a[i][j] == a[i-1][j] && a[i][j] == 1);
cnt[i][j] = cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1] + a[i][j];
}
}
for (int i = 1; i<=q; i++) {
cin>>x1>>y1>>x2>>y2;
ll ans = 0;
ans += cnt[x2][y2] - cnt[x2][y1-1] - cnt[x1-1][y2] + cnt[x1-1][y1-1];
ans -= c[x2][y2] - c[x2][y1] - c[x1-1][y2] + c[x1-1][y1];
ans -= r[x2][y2] - r[x1][y2] - r[x2][y1-1] + r[x1][y1-1];
cout<<ans<<endl;
}
return 0;
}
| a.cc:19:45: error: 'int y1' redeclared as different kind of entity
19 | int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:39:24: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
39 | cin>>x1>>y1>>x2>>y2;
| ~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
39 | cin>>x1>>y1>>x2>>y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:26: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
39 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std: |
s914347910 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 998244353;
const int N = 1005;
const int K = 3000;
const ll INF = 1e18;
const double EPS = 1e-6;
ll n,m,q;
int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
char w;
int main () {
faster
cin>>n>>m>>q;
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
cin>>w;
a[i][j] = (w == '1');
}
}
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + (a[i][j] == a[i][j-1] && a[i][j] == 1);
r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + (a[i][j] == a[i-1][j] && a[i][j] == 1);
cnt[i][j] = cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1] + a[i][j];
}
}
for (int i = 1; i<=q; i++) {
cin>>x1>>y1>>x2>>y2;
ll ans = 0;
ans += cnt[x2][y2] - cnt[x2][y1-1] - cnt[x1-1][y2] + cnt[x1-1][y1-1];
ans -= c[x2][y2] - c[x2][y1] - c[x1-1][y2] + c[x1-1][y1];
ans -= r[x2][y2] - r[x1][y2] - r[x2][y1-1] + r[x1][y1-1];
cout<<ans<<endl;
}
return 0;
}
| a.cc:20:45: error: 'int y1' redeclared as different kind of entity
20 | int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:24: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
40 | cin>>x1>>y1>>x2>>y2;
| ~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
40 | cin>>x1>>y1>>x2>>y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std: |
s063123395 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 998244353;
const int N = 1005;
const int K = 3000;
const ll INF = 1e18;
const double EPS = 1e-6;
ll n,m,q;
ll a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
char w;
int main () {
faster
cin>>n>>m>>q;
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
cin>>w;
a[i][j] = (w == '1');
}
}
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + (a[i][j] == a[i][j-1] && a[i][j] == 1);
r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + (a[i][j] == a[i-1][j] && a[i][j] == 1);
cnt[i][j] = cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1] + a[i][j];
}
}
for (int i = 1; i<=q; i++) {
cin>>x1>>y1>>x2>>y2;
ll ans = 0;
ans += cnt[x2][y2] - cnt[x2][y1-1] - cnt[x1-1][y2] + cnt[x1-1][y1-1];
ans -= c[x2][y2] - c[x2][y1] - c[x1-1][y2] + c[x1-1][y1];
ans -= r[x2][y2] - r[x1][y2] - r[x2][y1-1] + r[x1][y1-1];
cout<<ans<<endl;
}
return 0;
}
| a.cc:20:44: error: 'long long int y1' redeclared as different kind of entity
20 | ll a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:24: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
40 | cin>>x1>>y1>>x2>>y2;
| ~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
40 | cin>>x1>>y1>>x2>>y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_typ |
s653458939 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 998244353;
const int N = 1005;
const int K = 3000;
const ll INF = 1e18;
const double EPS = 1e-6;
ll n,m,q;
int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
char w;
int main () {
faster
cin>>n>>m>>q;
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
cin>>w;
a[i][j] = (w == '1');
}
}
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + (a[i][j] == a[i][j-1] && a[i][j] == 1);
r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + (a[i][j] == a[i-1][j] && a[i][j] == 1);
cnt[i][j] = cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1] + a[i][j];
}
}
for (int i = 1; i<=q; i++) {
cin>>x1>>y1>>x2>>y2;
ll ans = 0;
ans += cnt[x2][y2] - cnt[x2][y1-1] - cnt[x1-1][y2] + cnt[x1-1][y1-1];
ans -= c[x2][y2] - c[x2][y1] - c[x1-1][y2] + c[x1-1][y1];
ans -= r[x2][y2] - r[x1][y2] - r[x2][y1-1] + r[x1][y1-1];
cout<<ans<<endl;
}
return 0;
}
| a.cc:20:45: error: 'int y1' redeclared as different kind of entity
20 | int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:24: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
40 | cin>>x1>>y1>>x2>>y2;
| ~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
40 | cin>>x1>>y1>>x2>>y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std: |
s382012071 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 998244353;
const int N = 2005;
const int K = 3000;
const ll INF = 1e18;
const double EPS = 1e-6;
ll n,m,q;
int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
char w;
int main () {
faster
cin>>n>>m>>q;
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
cin>>w;
a[i][j] = (w == '1');
}
}
for (int i = 1; i<=n; i++) {
for (int j = 1; j<=m; j++) {
c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + (a[i][j] == a[i][j-1] && a[i][j] == 1);
r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + (a[i][j] == a[i-1][j] && a[i][j] == 1);
cnt[i][j] = cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1] + a[i][j];
}
}
for (int i = 1; i<=q; i++) {
cin>>x1>>y1>>x2>>y2;
ll ans = 0;
ans += cnt[x2][y2] - cnt[x2][y1-1] - cnt[x1-1][y2] + cnt[x1-1][y1-1];
ans -= c[x2][y2] - c[x2][y1] - c[x1-1][y2] + c[x1-1][y1];
ans -= r[x2][y2] - r[x1][y2] - r[x2][y1-1] + r[x1][y1-1];
cout<<ans<<endl;
}
return 0;
}
| a.cc:20:45: error: 'int y1' redeclared as different kind of entity
20 | int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:24: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
40 | cin>>x1>>y1>>x2>>y2;
| ~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
40 | cin>>x1>>y1>>x2>>y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:40:26: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:40:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
40 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std: |
s572791024 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
char S[2020][2020];
int P[2020][2020];
int Q[2020][2020];
int R[2020][2020];
int cj(int T[][2020], int x1, int y1, int x2, int y2){
return T[x2][y2] - T[x1-1][y2] - T[x2][y1-1] + T[x1-1][y1-1];
}
void ck(int n,int m,int q){
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) {
P[i][j] = P[i-1][j] + P[i][j-1] - P[i-1][j-1] + (S[i][j] - '0');
Q[i][j] = Q[i-1][j] + Q[i][j-1] - Q[i-1][j-1] + (S[i][j] - '0') * (i?(S[i-1][j] - '0'):0);
R[i][j] = R[i-1][j] + R[i][j-1] - R[i-1][j-1] + (S[i][j] - '0') * (j?(S[i][j-1] - '0'):0);
}
for(int i=0;i<q;i++){
int x1, y1, x2, y2;
cin>>x1>>y1>>x2>>y2;
int ans=cj(P, x1, y1, x2, y2);
ans-=cj(Q, x1+1, y1, x2, y2);
ans-=cj(R, x1, y1+1, x2, y2);
cout<<ans;
}
}
int main(){
int n,m,q;
cin>>n>>m>>q;
for(int i=0;i<n;i++)
cin>>s[i];
int Tc = 1;
for(int i=0;i<Tc;i++){
ck(n,m,q);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:31:14: error: 's' was not declared in this scope
31 | cin>>s[i];
| ^
|
s369837558 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
char S[2020][2020];
int P[2020][2020];
int Q[2020][2020];
int R[2020][2020];
int cj(int T[][2020], int x1, int y1, int x2, int y2){
return T[x2][y2] - T[x1-1][y2] - T[x2][y1-1] + T[x1-1][y1-1];
}
void ck(){
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) {
P[i][j] = P[i-1][j] + P[i][j-1] - P[i-1][j-1] + (S[i][j] - '0');
Q[i][j] = Q[i-1][j] + Q[i][j-1] - Q[i-1][j-1] + (S[i][j] - '0') * (i?(S[i-1][j] - '0'):0);
R[i][j] = R[i-1][j] + R[i][j-1] - R[i-1][j-1] + (S[i][j] - '0') * (j?(S[i][j-1] - '0'):0);
}
for(int i=0;i<q;i++){
int x1, y1, x2, y2;
cin>>x1>>y1>>x2>>y2;
int ans=cj(P, x1, y1, x2, y2);
ans-=cj(Q, x1+1, y1, x2, y2);
ans-=cj(R, x1, y1+1, x2, y2);
cout<<ans;
}
}
int main(){
int n,m,q;
cin>>n>>m>>q;
for(int i=0;i<n;i++)
cin>>s[i];
int Tc = 1;
for(int i=0;i<Tc;i++){
ck();
}
return 0;
} | a.cc: In function 'void ck()':
a.cc:11:20: error: 'n' was not declared in this scope
11 | for(int i=1;i<=n;i++)
| ^
a.cc:12:24: error: 'm' was not declared in this scope
12 | for(int j=1;j<=m;j++) {
| ^
a.cc:17:19: error: 'q' was not declared in this scope
17 | for(int i=0;i<q;i++){
| ^
a.cc: In function 'int main()':
a.cc:31:14: error: 's' was not declared in this scope
31 | cin>>s[i];
| ^
|
s005936152 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N=2010;
int sump[N][N],sume1[N][N],sume2[N][N];
bool mp[N][N];
int main()
{
static char s[N];
int n,m,q;cin>>n>>m>>q;
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
for(int j=1;j<=m;j++)
mp[i][j]=(s[j]=='1');
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
sump[i][j]=sump[i-1][j]+sump[i][j-1]-sump[i-1][j-1]+mp[i][j];
sume1[i][j]=sume1[i-1][j]+sume1[i][j-1]-sume1[i-1][j-1]+(mp[i][j]&&mp[i][j+1]);
sume2[i][j]=sume2[i-1][j]+sume2[i][j-1]-sume2[i-1][j-1]+(mp[i][j]&&mp[i+1][j]);
}
while(q--)
{
int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int n=sump[x2][y2]-sump[x1-1][y2]-sump[x2][y1-1]+sump[x1-1][y1-1];
int m=sume1[x2][y2-1]-sume1[x2][y1-1]-sume1[x1-1][y2-1]+sume1[x1-1][y1-1];
m+=sume2[x2-1][y2]-sume2[x2-1][y1-1]-sume2[x1-1][y2]+sume2[x1-1][y1-1];
printf("%d\n",n-m);
}
flush();
return 0;
} | a.cc: In function 'int main()':
a.cc:33:10: error: no matching function for call to 'flush()'
33 | flush();
| ~~~~~^~
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
766 | flush(basic_ostream<_CharT, _Traits>& __os)
| ^~~~~
/usr/include/c++/14/ostream:766:5: note: candidate expects 1 argument, 0 provided
|
s082616435 | p03707 | C++ | #include <bits/std++.h>
using namespace std;
const int MAXN = 2e3 + 10;
vector<string> grid;
int pref1[MAXN][MAXN], pref2[MAXN][MAXN], pref3[MAXN][MAXN];
int main(){
//freopen("sample_input.txt", "r", stdin);
//freopen("sample_output.txt", "w", stdout);
int t = 1;
//cin>> t;
while(t--){
//memset(grid, 0, sizeof grid);
memset(pref1, 0, sizeof pref1);
memset(pref2, 0, sizeof pref2);
memset(pref3, 0, sizeof pref3);
int n, m, q, ran;
cin>> n >> m >> q;
grid.clear();
/*for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
string s;
cin>> s;
grid.push_back(s);
}
//cout<<endl;
}*/
for(int i = 0; i < n; i++){
string s;
cin>> s;
grid.push_back(s);
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
pref1[i+1][j+1] = pref1[i][j+1] + pref1[i+1][j] - pref1[i][j] + (grid[i][j]=='1');
if(j != m - 1)
pref2[i+1][j+1] = pref2[i][j+1] + pref2[i+1][j] - pref2[i][j] + (grid[i][j]=='1' and grid[i][j+1]=='1');
if(i != n - 1)
pref3[i+1][j+1] = pref3[i][j+1] + pref3[i+1][j] - pref3[i][j] + (grid[i][j]=='1' and grid[i+1][j]=='1');
}
}
//cin>> q >> ran;
while(q--){
int x1, y1, x2, y2;
cin>> x1 >> y1 >> x2 >> y2;
x1--; y1--;
int ans = pref1[x2][y2] - pref1[x1][y2] - pref1[x2][y1] + pref1[x1][y1];
ans -= pref2[x2][y2-1] - pref2[x1][y2 - 1] - pref2[x2][y1] + pref2[x1][y1];
ans -= pref3[x2-1][y2] - pref3[x1][y2] - pref3[x2 - 1][y1] + pref3[x1][y1];
//cout<< x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << ans << endl;
cout<< ans << endl;
}
}
}
| a.cc:1:10: fatal error: bits/std++.h: No such file or directory
1 | #include <bits/std++.h>
| ^~~~~~~~~~~~~~
compilation terminated.
|
s940411412 | p03707 | C++ | #include <vector>
#include <iostream>
using namespace std;
const int MAXN = 2e3 + 10;
vector<string> grid;
int pref1[MAXN][MAXN], pref2[MAXN][MAXN], pref3[MAXN][MAXN];
int main(){
//freopen("sample_input.txt", "r", stdin);
//freopen("sample_output.txt", "w", stdout);
int t = 1;
//cin>> t;
while(t--){
//memset(grid, 0, sizeof grid);
memset(pref1, 0, sizeof pref1);
memset(pref2, 0, sizeof pref2);
memset(pref3, 0, sizeof pref3);
int n, m, q, ran;
cin>> n >> m >> q;
grid.clear();
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
string s;
cin>> s;
grid.push_back(s);
}
//cout<<endl;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
pref1[i+1][j+1] = pref1[i][j+1] + pref1[i+1][j] - pref1[i][j] + (grid[i][j]=='1');
if(j != m - 1)
pref2[i+1][j+1] = pref2[i][j+1] + pref2[i+1][j] - pref2[i][j] + (grid[i][j]=='1' and grid[i][j+1]=='1');
if(i != n - 1)
pref3[i+1][j+1] = pref3[i][j+1] + pref3[i+1][j] - pref3[i][j] + (grid[i][j]=='1' and grid[i+1][j]=='1');
}
}
//cin>> q >> ran;
while(q--){
int x1, y1, x2, y2;
cin>> x1 >> y1 >> x2 >> y2;
x1--; y1--;
int ans = pref1[x2][y2] - pref1[x1][y2] - pref1[x2][y1] + pref1[x1][y1];
ans -= pref2[x2][y2-1] - pref2[x1][y2 - 1] - pref2[x2][y1] + pref2[x1][y1];
ans -= pref3[x2-1][y2] - pref3[x1][y2] - pref3[x2 - 1][y1] + pref3[x1][y1];
//cout<< x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << ans << endl;
cout<< ans << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:19:17: error: 'memset' was not declared in this scope
19 | memset(pref1, 0, sizeof pref1);
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <iostream>
+++ |+#include <cstring>
3 | using namespace std;
|
s947381468 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x) \
for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
T x;
cin >> x;
return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
cin >> head;
CIN(move(tail)...);
}
#define CCIN(...) \
char __VA_ARGS__; \
CIN(__VA_ARGS__)
#define DCIN(...) \
double __VA_ARGS__; \
CIN(__VA_ARGS__)
#define LCIN(...) \
ll __VA_ARGS__; \
CIN(__VA_ARGS__)
#define SCIN(...) \
string __VA_ARGS__; \
CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v) \
{ \
FOREACH(x, v) { cout << x << " "; } \
cout << "\n"; \
}
template <typename T = string> inline void eputs(T s) {
cout << s << "\n";
exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;
typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
void cinfast() {
cin.tie(0);
ios::sync_with_stdio(false);
}
ll S[2000][2000], sum[2020][2020], csum[2020][2020], rsum[2020][2020];
signed main() {
cinfast()
LCIN(N, M, Q);
REP(i, N) REP(j, M) {
CCIN(s);
S[i][j] = (s == '1');
sum[i + 1][j + 1] +=
sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + S[i][j];
if(j)
rsum[i + 1][j + 1] += rsum[i + 1][j] + rsum[i][j + 1] - rsum[i][j] +
(S[i][j] & S[i][j - 1]);
if(i)
csum[i + 1][j + 1] += csum[i + 1][j] + csum[i][j + 1] - csum[i][j] +
(S[i][j] & S[i - 1][j]);
}
REP(i, Q) {
LCIN(x1, y1, x2, y2);
x1--, y1--, x2--, y2--;
ll ans = 0;
ans += sum[x2 + 1][y2 + 1] - sum[x1][y2 + 1] - sum[x2 + 1][y1] +
sum[x1][y1];
ans -= rsum[x2 + 1][y2 + 1] - rsum[x1][y2 + 1] - rsum[x2 + 1][y1 + 1] +
rsum[x1][y1 + 1];
ans -= csum[x2 + 1][y2 + 1] - csum[x1 + 1][y2 + 1] - csum[x2 + 1][y1] +
csum[x1 + 1][y1];
cout << ans << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:82:14: error: expected ';' before 'll'
82 | cinfast()
| ^
| ;
a.cc:83:10: error: 'N' was not declared in this scope
83 | LCIN(N, M, Q);
| ^
a.cc:37:9: note: in definition of macro 'LCIN'
37 | CIN(__VA_ARGS__)
| ^~~~~~~~~~~
a.cc:83:13: error: 'M' was not declared in this scope
83 | LCIN(N, M, Q);
| ^
a.cc:37:9: note: in definition of macro 'LCIN'
37 | CIN(__VA_ARGS__)
| ^~~~~~~~~~~
a.cc:83:16: error: 'Q' was not declared in this scope
83 | LCIN(N, M, Q);
| ^
a.cc:37:9: note: in definition of macro 'LCIN'
37 | CIN(__VA_ARGS__)
| ^~~~~~~~~~~
|
s584457208 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N=2010;
int sump[N][N],sume1[N][N],sume2[N][N];
bool mp[N][N];
int main()
{
static char s[N];
int n,m,q;cin>>n>>m>>q;
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
for(int j=1;j<=m;j++)
mp[i][j]=(s[j]=='1');
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
sump[i][j]=sump[i-1][j]+sump[i][j-1]-sump[i-1][j-1]+mp[i][j];
sume1[i][j]=sume1[i-1][j]+sume1[i][j-1]-sume1[i-1][j-1]+(mp[i][j]&&mp[i][j+1]);
sume2[i][j]=sume2[i-1][j]+sume2[i][j-1]-sume2[i-1][j-1]+(mp[i][j]&&mp[i+1][j]);
}
while(q--)
{
int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int n=sump[x2][y2]-sump[x1-1][y2]-sump[x2][y1-1]+sump[x1-1][y1-1];
int m=sume1[x2][y2-1]-sume1[x2][y1-1]-sume1[x1-1][y2-1]+sume1[x1-1][y1-1];
m+=sume2[x2-1][y2]-sume2[x2-1][y1-1]-sume2[x1-1][y2]+sume2[x1-1][y1-1];
printf("%d\n",n-m);
}
flush();
return 0;
} | a.cc: In function 'int main()':
a.cc:33:10: error: no matching function for call to 'flush()'
33 | flush();
| ~~~~~^~
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
766 | flush(basic_ostream<_CharT, _Traits>& __os)
| ^~~~~
/usr/include/c++/14/ostream:766:5: note: candidate expects 1 argument, 0 provided
|
s179533081 | p03707 | C++ | #include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>
#include <string>
const int MAX_N = 2050;
const int MAX_Q = 200000;
int N, M, Q;
char S[MAX_N][MAX_N];
int x1[MAX_Q], y1[MAX_Q], x2[MAX_Q], y2[MAX_Q];
int ac_node[MAX_N][MAX_N] = {};
int ac_edge_hor[MAX_N][MAX_N] = {};
int ac_edge_ver[MAX_N][MAX_N] = {};
int main(int argc, char **argv) {
std::cin >> N >> M >> Q;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
std::cin >> S[i][j];
}
}
for (int i = 1; i <= Q; i++) {
std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
}
for (int i = 1; i <= N; i++) {
int ac_tmp = 0;
for (int j = 1; j <= M; j++) {
if (S[i][j] == '1') {
ac_tmp++;
}
ac_node[i][j] = ac_node[i-1][j] + ac_tmp;
}
int ac_tmp_edge_hor = 0;
int ac_tmp_edge_ver = 0;
for (int j = 1; j <= M; j++) {
if (S[i][j] == '1' && S[i][j-1] == '1') {
ac_tmp_edge_ver++;
}
if (S[i][j] == '1' && S[i-1][j] == '1') {
ac_tmp_edge_hor++;
}
ac_edge_ver[i][j] = ac_edge_ver[i-1][j] + ac_tmp_edge_ver;
ac_edge_hor[i][j] = ac_edge_hor[i-1][j] + ac_tmp_edge_hor;
}
}
for (int i = 1; i <= Q; i++) {
int node_num = ac_node[x2[i]][y2[i]] - ac_node[x2[i]][y1[i] - 1] - ac_node[x1[i] - 1][y2[i]] + ac_node[x1[i] - 1][y1[i] - 1];
int edge_num_hor = ac_edge_hor[x2[i]][y2[i]] - ac_edge_hor[x2[i]][y1[i] - 1] - ac_edge_hor[x1[i]][y2[i]] + ac_edge_hor[x1[i]][y1[i] - 1];
int edge_num_ver = ac_edge_ver[x2[i]][y2[i]] - ac_edge_ver[x2[i]][y1[i]] - ac_edge_ver[x1[i] - 1][y2[i]] + ac_edge_ver[x1[i] - 1][y1[i]];
//std::cout << "check:" << node_num << " " << edge_num << std::endl;
std::cout << node_num - edge_num_hor - edge_num_ver << std::endl;
}
return 0;
} | a.cc:30:24: error: 'int y1 [200000]' redeclared as different kind of entity
30 | int x1[MAX_Q], y1[MAX_Q], x2[MAX_Q], y2[MAX_Q];
| ^
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/stdio.h:28,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main(int, char**)':
a.cc:46:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ^
a.cc:46:27: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~~~~~~~~~~~~~~ ^~ ~~~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/fstream:40,
from a.cc:3:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(short int)(y1 + ((sizetype)i))' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(short unsigned int)(y1 + ((sizetype)i))' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(int)(y1 + ((sizetype)i))' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(unsigned int)(y1 + ((sizetype)i))' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(long int)(y1 + ((sizetype)i))' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(long unsigned int)(y1 + ((sizetype)i))' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(long long int)(y1 + ((sizetype)i))' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(long long unsigned int)(y1 + ((sizetype)i))' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
46 | std::cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
| ~~~~^
| |
| double (*)(double) noexcept
a.cc:46:34: error: cannot bind rvalue '(void*)(y1 + ((sizetype)i))' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:46:34: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermiss |
s956649600 | p03707 | C++ | //#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>
#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)
using namespace std;
int main(void)
{
//変数の宣言
int n,m,q;
static char c[2010];
static int s[2010][2010];
static int x1[200010];
static int y1[200010];
static int x2[200010];
static int y2[200010];
static int memo[2010];
static int tate[2010][2010];
static int yoko[2010][2010];
static int ruiseki[2010][2010];
//よく使う変数
int i,j,k,l;
int flag=0;
ll int ans=0;
int count=0;
int temp=0;
int temp1=0;
int temp2=0;
int max=0;
int min=INFINT;
int len=0;
int sum=0;
int ok=0;
int ng=0;
//データの読み込み
/*
// scanf("%d",&n);
scanf_s("%d",&n);
for(i=0;i<n;i++){
// scanf("%d %d",&a[i],&b[i]);
scanf_s("%d %d",&a[i],&b[i]);
}*/
scanf("%d %d %d",&n,&m,&q);
for(i=0;i<n;i++){
scanf("%s",&s);
for(j=0;j<m;j++){
sint[i][j]=s[j]-'0';
}
}
for(i=0;i<q;i++){
scanf("%d %d %d %d",&x1[i],&y1[i],&x2[i],&y2[i]);
}
/* scanf_s("%d %d %d",&n,&m,&q);
for(i=0;i<n;i++){
scanf_s("%s",&c,2010);
for(j=0;j<m;j++){
s[i][j]=c[j]-'0';
}
}
for(i=0;i<q;i++){
scanf_s("%d %d %d %d",&x1[i],&y1[i],&x2[i],&y2[i]);
}*/
// printf("nは%dです\n", n);
// printf("データの読み込み終了\n");
//実際の処理
for(i=0;i<n-1;i++){
for(j=0;j<m;j++){
if(j==0){
if(s[i][j]==1&&s[i+1][j]==1){
tate[i][0]=1;
}else{
tate[i][0]=0;
}
}else if(s[i][j]==1&&s[i+1][j]==1){
tate[i][j]=tate[i][j-1]+1;
}else{
tate[i][j]=tate[i][j-1];
}
}
}
for(i=0;i<n;i++){
for(j=0;j<m-1;j++){
if(i==0){
if(s[i][j]==1&&s[i][j+1]==1){
yoko[0][j]=1;
}else{
yoko[0][j]=0;
}
}else if(s[i][j]==1&&s[i][j+1]==1){
yoko[i][j]=yoko[i-1][j]+1;
}else{
yoko[i][j]=yoko[i-1][j];
}
}
}
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(j==0){
memo[j]=s[i][j];
}else if(s[i][j-1]==0){
memo[j]=memo[j-1]+s[i][j];
}else{
memo[j]=memo[j-1];
}
}
if(i==0){
for(j=0;j<m;j++){
ruiseki[0][j]=memo[j];
}
}else{
for(j=0;j<m;j++){
ruiseki[i][j]=ruiseki[i-1][j]+memo[j]-tate[i-1][j];
}
}
}
for(i=0;i<q;i++){
ans=ruiseki[x2[i]-1][y2[i]-1];
if(x1[i]==1&&y1[i]==1){
//nothing
}else if(x1[i]==1){
ans=ans-ruiseki[x2[i]-1][y1[i]-2]+yoko[x2[i]-1][y1[i]-2];
}else if(y1[i]==1){
ans=ans-ruiseki[x1[i]-2][y2[i]-1]+tate[x1[i]-2][y2[i]-1];
}else{
ans=ans-ruiseki[x2[i]-1][y1[i]-2]+yoko[x2[i]-1][y1[i]-2];
ans=ans-ruiseki[x1[i]-2][y2[i]-1]+tate[x1[i]-2][y2[i]-1];
ans=ans+ruiseki[x1[i]-2][y1[i]-2]-yoko[x1[i]-2][y1[i]-2]-tate[x1[i]-2][y1[i]-2];
}
printf("%d\n",ans);
}
printf("yoko[i][j]\n");
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%d ",yoko[i][j]);
}
printf("\n");
}
printf("tate[i][j]\n");
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%d ",tate[i][j]);
}
printf("\n");
}
printf("ruiseki[i][j]\n");
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%d ",ruiseki[i][j]);
}
printf("\n");
}
// printf("計算部分終了\n");
//出力
// printf("結果の出力終了\n");
return 0;
}
| a.cc: In function 'int main()':
a.cc:78:25: error: 'sint' was not declared in this scope; did you mean 'uint'?
78 | sint[i][j]=s[j]-'0';
| ^~~~
| uint
|
s557811512 | p03707 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
const int N=2003;
struct node
{
int hang;
int lie;
int v;
}dp[N][N];
char a[N][N];
int n,m,q;
int x1,x2,y1,y2;
int main()
{
// freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
// freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
gbtb;
cin>>n>>m>>q;
repd(i,1,n)
{
repd(j,1,m)
{
cin>>a[i][j];
}
}
repd(i,1,n)
{
repd(j,1,m)
{
dp[i][j].v=dp[i][j-1].v+dp[i-1][j].v-dp[i-1][j-1].v+(a[i][j]=='1'?1:0);
dp[i][j].lie=dp[i][j-1].lie+dp[i-1][j].lie-dp[i-1][j-1].lie;
dp[i][j].hang=dp[i][j-1].hang+dp[i-1][j].hang-dp[i-1][j-1].hang;
if(a[i][j]=='1')
{
if(a[i][j]==a[i-1][j])
{
dp[i][j].lie++;
}
if(a[i][j]==a[i][j-1])
{
dp[i][j].hang++;
// num++;
}
}
}
}
repd(qq,1,q)
{
cin>>x1>>y1>>x2>>y2;
int cnt=dp[x2][y2].v-dp[x2][y1-1].v-dp[x1-1][y2].v+dp[x1-1][y1-1].v;
cnt-=dp[x2][y2].hang-dp[x2][y1].hang-dp[x1-1][y2].hang+dp[x1-1][y1].hang;
cnt-=dp[x2][y2].lie-dp[x1][y2].lie-dp[x2][y1-1].lie+dp[x1][y1-1].lie;
cout<<cnt<<endl;
}
return 0;
}
inline void getInt(int* p) {char ch;do {ch = getchar();}
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9')
{*p = *p * 10 + ch - '0';}}}
| a.cc:49:11: error: 'int y1' redeclared as different kind of entity
49 | int x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/bits/requires_hosted.h:31,
from /usr/include/c++/14/iostream:38,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:88:24: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
88 | cin>>x1>>y1>>x2>>y2;
| ~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
88 | cin>>x1>>y1>>x2>>y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:88:26: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
88 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed:
a.cc:88:26: error: |
s050506775 | p03707 | C++ | #include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;
const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;
int b[2002][2002];
int tate[2002][2002];
int yoko[2002][2002];
int main(){
int n,m,q; cin>>n>>m>>q;
FOR(i,0,n)FOR(j,0,m){
char c; cin>>c;
b[i+1][j+1]=c-'0';
}
FOR(i,1,n)FOR(j,0,m){
tate[i][j]=(b[i][j+1]==1&&b[i+1][j+1]==1);
}
FOR(i,0,n)FOR(j,1,m){
yoko[i][j]=(b[i+1][j]==1&&b[i+1][j+1]==1);
}
FOR(i,1,n)FOR(j,0,m){
tate[i][j]+=tate[i-1][j];
yoko[i][j]+=yoko[i-1][j];
}
FOR(i,0,n)FOR(j,1,m){
tate[i][j]+=tate[i][j-1];
yoko[i][j]+=yoko[i][j-1];
}
FOR(i,1,n+1)FOR(j,0,m+1){
b[i][j]+=b[i-1][j];
}
FOR(i,0,n+1)FOR(j,1,m+1){
b[i][j]+=b[i][j+1];
}
while(q--){
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
int blue=b[x2][y2]-b[x1-1][y2]-b[x2][y1-1]+b[x1-1][y1-1];
int edge=
}
}
| a.cc: In function 'int main()':
a.cc:59:9: error: expected primary-expression before '}' token
59 | }
| ^
|
s300125816 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
namespace whatever{
int readu(){
char ch=getchar();
while(!isdigit(ch))
ch=getchar();
int value=ch-'0';
ch=getchar();
while(isdigit(ch)){
value=value*10+ch-'0';
ch=getchar();
}
return value;
}
void writeu(int n){
if(n<10)
putchar(n+'0');
else{
writeu(n/10);
putchar(n%10+'0');
}
}
void run(){
int n=readu();
int m=readu();
int q=readu();
static char s[2002][2002];
for(int i=1; i<=n; ++i)
gets(s[i]+1);
static int vertex[2002][2002];
static int edge[2][2002][2002];
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j)
if(s[i][j]=='1'){
++vertex[i][j];
static pair<int, int> delta[2]={{-1, 0}, {0, -1}};
for(int k=0; k<2; ++k)
if(s[i+delta[k].first][j+delta[k].second]=='1')
++edge[k][i][j];
}
cerr<<"clock(): "<<clock()/double(CLOCKS_PER_SEC)<<endl;
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j){
vertex[i][j]+=vertex[i][j-1];
edge[0][i][j]+=edge[0][i][j-1];
edge[1][i][j]+=edge[1][i][j-1];
}
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j){
vertex[i][j]+=vertex[i-1][j];
edge[0][i][j]+=edge[0][i-1][j];
edge[1][i][j]+=edge[1][i-1][j];
}
cerr<<"clock(): "<<clock()/double(CLOCKS_PER_SEC)<<endl;
while(--q!=-1){
int x1=readu();
int y1=readu();
int x2=readu();
int y2=readu();
int vertex_result=vertex[x2][y2]+vertex[x1-1][y1-1]-vertex[x2][y1-1]-vertex[x1-1][y2];
int edge_0_result=edge[0][x2][y2]+edge[0][x1][y1-1]-edge[0][x2][y1-1]-edge[0][x1][y2];
int edge_1_result=edge[1][x2][y2]+edge[1][x1-1][y1]-edge[1][x2][y1]-edge[1][x1-1][y2];
writeu(vertex_result-edge_0_result-edge_1_result);
putchar('\n');
}
cerr<<"clock(): "<<clock()/double(CLOCKS_PER_SEC)<<endl;
}
}
int main(){
whatever::run();
} | a.cc: In function 'void whatever::run()':
a.cc:30:25: error: 'gets' was not declared in this scope; did you mean 'getw'?
30 | gets(s[i]+1);
| ^~~~
| getw
|
s271569188 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
namespace whatever{
int readu(){
char ch=getchar();
while(!isdigit(ch))
ch=getchar();
int value=ch-'0';
ch=getchar();
while(isdigit(ch)){
value=value*10+ch-'0';
ch=getchar();
}
return value;
}
void writeu(int n){
if(n<10)
putchar(n+'0');
else{
writeu(n/10);
putchar(n%10+'0');
}
}
void run(){
int n=readu();
int m=readu();
int q=readu();
static char s[2002][2002];
for(int i=1; i<=n; ++i)
gets(s[i]+1);
static int vertex[2002][2002];
static int edge[2][2002][2002];
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j)
if(s[i][j]=='1'){
++vertex[i][j];
static pair<int, int> delta[2]={{-1, 0}, {0, -1}};
for(int k=0; k<2; ++k)
if(s[i+delta[k].first][j+delta[k].second]=='1')
++edge[k][i][j];
}
cerr<<"clock(): "<<clock()/double(CLOCKS_PER_SEC)<<endl;
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j){
vertex[i][j]+=vertex[i][j-1];
edge[0][i][j]+=edge[0][i][j-1];
edge[1][i][j]+=edge[1][i][j-1];
}
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j){
vertex[i][j]+=vertex[i-1][j];
edge[0][i][j]+=edge[0][i-1][j];
edge[1][i][j]+=edge[1][i-1][j];
}
cerr<<"clock(): "<<clock()/double(CLOCKS_PER_SEC)<<endl;
while(--q!=-1){
int x1=readu();
int y1=readu();
int x2=readu();
int y2=readu();
int vertex_result=vertex[x2][y2]+vertex[x1-1][y1-1]-vertex[x2][y1-1]-vertex[x1-1][y2];
int edge_0_result=edge[0][x2][y2]+edge[0][x1][y1-1]-edge[0][x2][y1-1]-edge[0][x1][y2];
int edge_1_result=edge[1][x2][y2]+edge[1][x1-1][y1]-edge[1][x2][y1]-edge[1][x1-1][y2];
writeu(vertex_result-edge_0_result-edge_1_result);
putchar('\n');
}
cerr<<"clock(): "<<clock()/double(CLOCKS_PER_SEC)<<endl;
}
}
int main(){
whatever::run();
} | a.cc: In function 'void whatever::run()':
a.cc:30:25: error: 'gets' was not declared in this scope; did you mean 'getw'?
30 | gets(s[i]+1);
| ^~~~
| getw
|
s987939641 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
int main() {
int n,m,q;
scanf("%d %d %d",&n,&m,&q);
char ch[n][m];
string s;
rep(i,0,n){cin >> s;
rep(j,0,m){
ch[i][j] = s[j];
}
}
int tyo[n+1][m+1] = {};
rep(i,1,n+1){
rep(j,1,m+1){
tyo[i][j]= tyo[i-1][j] + tyo[i][j-1] - tyo[i-1][j-1];
if(ch[i-1][j-1] == '1'){
tyo[i][j] += 1;
}
}
}
int hen[n+1][m+1] = {};
rep(i,1,n+1){
rep(j,1,m+1){
hen[i][j]= hen[i-1][j] + hen[i][j-1] - hen[i-1][j-1];
if((ch[i-1][j-1] == '1') && (ch[i-1][j] == '1') && (j <= m-1)){
hen[i][j] += 1;
}
}
}
int hen2[n+1][m+1] = {};
rep(i,1,n+1){
rep(j,1,m+1){
hen2[i][j]= hen2[i-1][j] + hen2[i][j-1] - hen2[i-1][j-1];
if((ch[i-1][j-1] == '1') && (ch[i][j-1] == '1') && (i <= n-1)){
hen2[i][j] += 1;
}
}
}
std::vector<std::vector<int>> query;
rep(i,0,q){
std::vector<int> v;
int x1,y1,x2,y2;
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
v = {x1,y1,x2,y2};
query.pb(v);
}
int ans = 0;
for(auto $q:query){
ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
std::cout << ans << '\n';
}
} | a.cc: In function 'int main()':
a.cc:70:16: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:70:22: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:70:34: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:70:40: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:70:54: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:70:62: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:70:74: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:70:82: error: invalid types 'int[int]' for array subscript
70 | ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
| ^
a.cc:71:18: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:71:24: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:71:38: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:71:44: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:71:58: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:71:66: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:71:80: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:71:88: error: invalid types 'int[int]' for array subscript
71 | ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
| ^
a.cc:72:19: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
a.cc:72:27: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
a.cc:72:40: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
a.cc:72:48: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
a.cc:72:63: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
a.cc:72:71: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
a.cc:72:84: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
a.cc:72:92: error: invalid types 'int[int]' for array subscript
72 | ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
| ^
|
s158130792 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
int main() {
int n,m,q;
scanf("%d %d %d",&n,&m,&q);
static char ch[n][m];
string s;
rep(i,0,n){cin >> s;
rep(j,0,m){
ch[i][j] = s[j];
}
}
static int tyo[n+1][m+1] = {};
rep(i,1,n+1){
rep(j,1,m+1){
tyo[i][j]= tyo[i-1][j] + tyo[i][j-1] - tyo[i-1][j-1];
if(ch[i-1][j-1] == '1'){
tyo[i][j] += 1;
}
}
}
static int hen[n+1][m+1] = {};
rep(i,1,n+1){
rep(j,1,m+1){
hen[i][j]= hen[i-1][j] + hen[i][j-1] - hen[i-1][j-1];
if((ch[i-1][j-1] == '1') && (ch[i-1][j] == '1') && (j <= m-1)){
hen[i][j] += 1;
}
}
}
static int hen2[n+1][m+1] = {};
rep(i,1,n+1){
rep(j,1,m+1){
hen2[i][j]= hen2[i-1][j] + hen2[i][j-1] - hen2[i-1][j-1];
if((ch[i-1][j-1] == '1') && (ch[i][j-1] == '1') && (i <= n-1)){
hen2[i][j] += 1;
}
}
}
std::vector<std::vector<int>> query;
rep(i,0,q){
std::vector<int> v;
int x1,y1,x2,y2;
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
v = {x1,y1,x2,y2};
query.pb(v);
}
int ans = 0;
for(auto q:query){
ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
std::cout << ans << '\n';
}
} | a.cc: In function 'int main()':
a.cc:26:21: error: storage size of 'ch' isn't constant
26 | static char ch[n][m];
| ^~
a.cc:33:14: error: storage size of 'tyo' isn't constant
33 | static int tyo[n+1][m+1] = {};
| ^~~
a.cc:42:14: error: storage size of 'hen' isn't constant
42 | static int hen[n+1][m+1] = {};
| ^~~
a.cc:51:14: error: storage size of 'hen2' isn't constant
51 | static int hen2[n+1][m+1] = {};
| ^~~~
|
s544042299 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N=2010;
int sump[N][N],sume1[N][N],sume2[N][N];
bool mp[N][N];
int main()
{
static char s[N];
int n,m,q;cin>>n>>m>>q;
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
for(int j=1;j<=m;j++)
mp[i][j]=(s[j]=='1');
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
sump[i][j]=sump[i-1][j]+sump[i][j-1]-sump[i-1][j-1]+mp[i][j];
sume1[i][j]=sume1[i-1][j]+sume1[i][j-1]-sume1[i-1][j-1]+(mp[i][j]&&mp[i][j+1]);
sume2[i][j]=sume2[i-1][j]+sume2[i][j-1]-sume2[i-1][j-1]+(mp[i][j]&&mp[i+1][j]);
}
while(q--)
{
int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int n=sump[x2][y2]-sump[x1-1][y2]-sump[x2][y1-1]+sump[x1-1][y1-1];
int m=sume1[x2][y2-1]-sume1[x2][y1-1]-sume1[x1-1][y2-1]+sume1[x1-1][y1-1];
m+=sume2[x2-1][y2]-sume2[x2-1][y1-1]-sume2[x1-1][y2]+sume2[x1-1][y1-1];
printf("%d\n",n-m);
}
flush();
return 0;
} | a.cc: In function 'int main()':
a.cc:33:10: error: no matching function for call to 'flush()'
33 | flush();
| ~~~~~^~
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
766 | flush(basic_ostream<_CharT, _Traits>& __os)
| ^~~~~
/usr/include/c++/14/ostream:766:5: note: candidate expects 1 argument, 0 provided
|
s962385045 | p03707 | C++ | package main
import (
"bufio"
"fmt"
"io/ioutil"
"os"
)
const MAXN=2000
const MAXQ=200000
type IOTp struct {
iBuffer []byte
iPos int
}
func (this *IOTp) GetChar() byte {
res:=this.iBuffer[this.iPos]
this.iPos++
return res
}
func (this *IOTp) ReadInt() int {
res:=0
k:=1
for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
if ch=='-' {
k=-1
}
this.iPos++
}
for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
res=res*10+int(ch-'0')
this.iPos++
}
res*=k
return res
}
func NewIOTp() *IOTp {
now:=new(IOTp)
now.iBuffer,_=ioutil.ReadAll(os.Stdin)
now.iPos=0
return now
}
type Query struct {
x1,y1,x2,y2 int
}
var cin *bufio.Reader
var cout *bufio.Writer
var sum,sumh,suml [MAXN+5][MAXN+5]int
func query(sum *[MAXN+5][MAXN+5]int,x1,y1,x2,y2 int) int {
if x2<x1 {return 0}
if y2<y1 {return 0}
return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1]
}
func main() {
IO:=NewIOTp()
cout=bufio.NewWriter(os.Stdout)
var a [5 + MAXQ]Query
var n,m,q int
n=IO.ReadInt()
m=IO.ReadInt()
q=IO.ReadInt()
//fmt.Println(n,m,q)
var s [MAXN+5][MAXN+5]byte
for i:=0; i<n; i++ {
for j:=0; j<m; j++ {
for s[i][j]=IO.GetChar(); s[i][j]!='0' && s[i][j]!='1'; s[i][j]=IO.GetChar(){
}
}
for j:=0; j<m; j++ {
sum[i+1][j+1]=int(s[i][j]-'0')
}
}
for i:=1; i<=n; i++ {
for j:=1; j<=m; j++ {
if sum[i][j]>0 {
if sum[i][j+1]>0 {
suml[i][j]=1
}
if sum[i+1][j]>0 {
sumh[i][j]=1
}
}
}
}
for i:=1; i<=n; i++ {
for j:=1; j<=m; j++ {
sum[i][j]=sum[i][j]-sum[i-1][j-1]+sum[i][j-1]+sum[i-1][j]
sumh[i][j]=sumh[i][j]-sumh[i-1][j-1]+sumh[i][j-1]+sumh[i-1][j]
suml[i][j]=suml[i][j]-suml[i-1][j-1]+suml[i][j-1]+suml[i-1][j]
}
}
/*for i:=1; i<=n; i++ {
for j:=1; j<=m; j++ {
fmt.Print(suml[i][j])
}
fmt.Println()
}*/
for i:=1; i<=q; i++ {
a[i].x1=IO.ReadInt()
a[i].y1=IO.ReadInt()
a[i].x2=IO.ReadInt()
a[i].y2=IO.ReadInt()
}
for i:=1; i<=q; i++ {
x1,y1,x2,y2:=a[i].x1,a[i].y1,a[i].x2,a[i].y2
//fmt.Println(query(&sum,x1,y1,x2,y2),query(&sumh,x1,y1,x2,y2-1),query(&suml,x1,y1,x2-1,y2))
ans:=query(&sum,x1,y1,x2,y2)-query(&suml,x1,y1,x2,y2-1)-query(&sumh,x1,y1,x2-1,y2)
fmt.Fprintln(cout,ans)
}
cout.Flush()
}
| a.cc:1:1: error: 'package' does not name a type
1 | package main
| ^~~~~~~
a.cc:16:6: error: expected constructor, destructor, or type conversion before '(' token
16 | func (this *IOTp) GetChar() byte {
| ^
a.cc:21:6: error: expected constructor, destructor, or type conversion before '(' token
21 | func (this *IOTp) ReadInt() int {
| ^
a.cc:37:1: error: 'func' does not name a type
37 | func NewIOTp() *IOTp {
| ^~~~
a.cc:43:1: error: 'type' does not name a type; did you mean 'typeof'?
43 | type Query struct {
| ^~~~
| typeof
a.cc:46:1: error: 'var' does not name a type
46 | var cin *bufio.Reader
| ^~~
a.cc:54:1: error: 'func' does not name a type
54 | func main() {
| ^~~~
|
s647211612 | p03707 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,m,q;
int f[2001][2001],h[2001][2001],g[2001][2001];
char s[N][N];
int main()
{
cin>>n>>m>>q
for(int i=1; i<=n; i++)
cin>>s[i]+1;
fill(f,f+n+1,0);
fiil(h,h+m+1,0);
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]-'0');
int cnt[2];
cnt[1]=cnt[2]=0;
if(s[i][j]=='1')
{
if(s[i-1][j]=='1') cnt[0]++;
if(s[i][j-1]=='1') cnt[1]++;
}
h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+cnt[0];
g[i][j]=g[i-1][j]+g[i][j-1]-g[i-1][j-1]+cnt[1];
}
}
while(q--)
{
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
int k1=f[x2][y2]-f[x2][y1-1]-f[x1-1][y2]+f[x1-1][y1-1];
int k2=h[x2][y2]-h[x2][y1]-h[x1-1][y2]+h[x1-1][y1];
int k3=g[x2][y2]-g[x1][y2]-g[x2][y1-1]+g[x1][y1-1];
cout<<k1-k2-k3<<endl;
}
return 0;
}
| a.cc:5:8: error: 'N' was not declared in this scope
5 | char s[N][N];
| ^
a.cc:5:11: error: 'N' was not declared in this scope
5 | char s[N][N];
| ^
a.cc: In function 'int main()':
a.cc:8:17: error: expected ';' before 'for'
8 | cin>>n>>m>>q
| ^
| ;
9 | for(int i=1; i<=n; i++)
| ~~~
a.cc:9:18: error: 'i' was not declared in this scope
9 | for(int i=1; i<=n; i++)
| ^
a.cc:12:9: error: 'fiil' was not declared in this scope
12 | fiil(h,h+m+1,0);
| ^~~~
a.cc:17:54: error: 's' was not declared in this scope
17 | f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]-'0');
| ^
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[2001]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[2001]; _Tp = int]'
998 | { std::__fill_a1(__first, __last, __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[2001]; _Tp = int]'
1029 | std::__fill_a(__first, __last, __value);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:9: required from here
11 | fill(f,f+n+1,0);
| ~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [2001]'
952 | *__first = __tmp;
| ~~~~~~~~~^~~~~~~
|
s332384144 | p03707 | C++ | /*************************************************
*************************************************
*************************************************
*** _________________ | | | /***
*** | | | | / ***
*** | | | | / ***
*** | | | | / ***
*** | | | | / ***
*** | |____________| |/ en ***
*** | | | |\ ***
*** | | | | \ ***
*** _____ | | | | \ ***
*** | | | | | \ ***
*** \ / | | | \ ***
*** \___/ | | | \***
*************************************************
*************Written by: JiangHaoKai*************
*************************************************/
#pragma GCC optimize(2)
#pragma G++ optimize(2)
//#include <bits/stdc++.h>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
//#include <conio.h>
//#include <windows.h>
using namespace std;
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double ld;
typedef pair<int,int> pii;
#define ui(n) ((unsigned int)(n))
#define ll(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define ld(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)
const int INF=1061109567;
const LL LINF=4557430888798830399;
#define PI 3.1415926535897932384626433832795028841971
#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define mod 1000000007
#define sz(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repa(i,a,n) for(int i=a;i<n;i++)
#define repa1(i,a,n) for(int i=a;i<=n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define repd1(i,n) for(int i=n;i>=1;i--)
#define FOR(i,a,n,step) for(int i=a;i<n;i+=step)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define sqr(x) ((x)*(x))
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define file(filename,name) fstream name(filename,ios::in|ios::out)
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define PC(x) putchar(x)
#define GC(x) x=getchar()
#define Endl PC('\n')
#define SF scanf
#define PF printf
inline int Read()
{
int X=0,w=0;char ch=0;while(!isdigit(ch)){w|=ch=='-';ch=getchar();}while(isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
return w?-X:X;
}
inline void Write(int x){if(x<0)putchar('-'),x=-x;if(x>9)Write(x/10);putchar(x%10+'0');}
inline LL powmod(LL a,LL b){LL res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline LL gcdll(LL a,LL b){return b?gcdll(b,a%b):a;}
inline string itoa(LL a){string res="";while(a>0)res+=(a%10+'0'),a/=10;reverse(All(res));return res==""?"0":res;}
inline LL atoi(string s){LL res=0;repV(i,s)res=res*10+i-'0';return res;}
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={1,0,-1,0,-1,-1,1,1};
/**************************************************************Begin***************************************************************/
const int maxn=2010;
int n,m,q,cnt[maxn][maxn],ed1[maxn][maxn],ed2[maxn][maxn],x1,y1,x2,y2;
string a[maxn];
int main()
{
SF("%d%d%d",&n,&m,&q);
rep1(i,n)
{
cin>>a[i];a[i]=" "+a[i];
rep1(j,m)
{
cnt[i][j]=cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1]+(a[i][j]=='1');
ed1[i][j]=ed1[i-1][j]+ed1[i][j-1]-ed1[i-1][j-1]+(a[i][j]=='1'&&a[i-1][j]=='1');
ed2[i][j]=ed2[i-1][j]+ed2[i][j-1]-ed2[i-1][j-1]+(a[i][j]=='1'&&a[i][j-1]=='1');
}
}
while(q--)
{
SF("%d%d%d%d",&x1,&y1,&x2,&y2);
int poi=cnt[x2][y2]-cnt[x2][y1-1]-cnt[x1-1][y2]+cnt[x1-1][y1-1],
edge=ed1[x2][y2]-ed1[x2][y1-1]-ed1[x1][y2]+ed1[x1][y1-1] + ed2[x2][y2]-ed2[x2][y1]-ed2[x1-1][y2]+ed2[x1-1][y1];
PF("%d\n",poi-edge);
}
return 0;
}
/***************************************************************End****************************************************************/
| a.cc:159:62: error: 'int y1' redeclared as different kind of entity
159 | int n,m,q,cnt[maxn][maxn],ed1[maxn][maxn],ed2[maxn][maxn],x1,y1,x2,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from a.cc:23:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:179:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
179 | int poi=cnt[x2][y2]-cnt[x2][y1-1]-cnt[x1-1][y2]+cnt[x1-1][y1-1],
| ~~^~
a.cc:179:44: error: invalid types 'int [2010][double (*)(double) noexcept]' for array subscript
179 | int poi=cnt[x2][y2]-cnt[x2][y1-1]-cnt[x1-1][y2]+cnt[x1-1][y1-1],
| ^
a.cc:179:77: warning: pointer to a function used in arithmetic [-Wpointer-arith]
179 | int poi=cnt[x2][y2]-cnt[x2][y1-1]-cnt[x1-1][y2]+cnt[x1-1][y1-1],
| ~~^~
a.cc:179:74: error: invalid types 'int [2010][double (*)(double) noexcept]' for array subscript
179 | int poi=cnt[x2][y2]-cnt[x2][y1-1]-cnt[x1-1][y2]+cnt[x1-1][y1-1],
| ^
a.cc:181:31: error: 'edge' was not declared in this scope
181 | PF("%d\n",poi-edge);
| ^~~~
|
s576303018 | p03707 | C++ | #include <cstdio>
#define N 2005
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int n,m,Q;
char mp[N][N];
int l[N][N];
int u[N][N];
int dp[N][N];
void Init()
{
scanf("%d %d %d\n",&n,&m,&Q);
rep(i,1,n+1)
{
gets(mp[i]+1);
}
rep(i,1,n+1)
{
rep(j,1,m+1)
{
dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+(mp[i][j]=='1');
}
}
rep(i,1,n+1)
{
rep(j,1,m+1)
{
l[i][j]=l[i][j-1];
if(mp[i][j]=='1' && mp[i][j-1]=='1')l[i][j]++;
}
}
rep(i,1,n+1)
{
rep(j,1,m+1)
{
l[i][j]+=l[i-1][j];
}
}
rep(i,1,n+1)
{
rep(j,1,m+1)
{
u[i][j]=u[i-1][j];
if(mp[i][j]=='1' && mp[i-1][j]=='1')u[i][j]++;
}
}
rep(i,1,n+1)
{
rep(j,1,m+1)
{
u[i][j]+=u[i][j-1];
}
}
rep(i,1,n+1)
{
rep(j,1,m+1)
{
printf("%d ",dp[i][j]);
}
puts("");
}
}
void Solve()
{
while(Q--)
{
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int point_count=dp[x2][y2]-dp[x1-1][y2]-dp[x2][y1-1]+dp[x1-1][y1-1];
int edge_count=0;
edge_count+=l[x2][y2]-l[x1-1][y2]-l[x2][y1-1]+l[x1-1][y1-1];
edge_count+=u[x2][y2]-u[x1-1][y2]-u[x2][y1-1]+u[x1-1][y1-1];
rep(i,x1,x2+1)
{
if(mp[i][y1]=='1' && mp[i][y1-1]=='1')edge_count--;
}
rep(j,y1,y2+1)
{
if(mp[x1][j]=='1' && mp[x1-1][j]=='1')edge_count--;
}
printf("point_count:%d\n",point_count);
printf("edge_count:%d\n",edge_count);
printf("%d\n",point_count-edge_count);
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
Init();
Solve();
return 0;
} | a.cc: In function 'void Init()':
a.cc:15:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
15 | gets(mp[i]+1);
| ^~~~
| getw
|
s228239767 | p03707 | C++ | #include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const int SIZE=2005;
int n,m,q,x1,x2,y1,y2;
bool a[SIZE][SIZE],visited[SIZE][SIZE];
int go(int x,int y){
if(!(x>=x1 && x<=x2 && y>=y1 && y<=y2)) return 0;
if(x<0 || x>=n || y<0 || y>=m) return 0;
if(!a[x][y]) return 0;
if(visited[x][y]) return 0;
visited[x][y]=true;
for(int i=0;i<4;i++){
int ux=dx[i]+x,uy=dy[i]+y;
go(ux,uy);
}
return 1;
}
int main(){
cin>>n>>m>>q;
for(int i=0;i<n;i++){
string tmp;
cin>>tmp;
for(int j=0;j<m;j++){
a[i][j]=tmp[j]-'0';
}
}
for(int k=0;k<q;k++){
int ans=0;
cin>>x1>>y1>>x2>>y2;
--x1;
--x2;
--y1;
--y2;
memset(visited,0,sizeof(visited));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(!visited[i][j]){
ans+=go(i,j);
}
}
}
cout<<ans<<endl;
}
}
| a.cc:21:17: error: 'int y1' redeclared as different kind of entity
21 | int n,m,q,x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/bits/requires_hosted.h:31,
from /usr/include/c++/14/iostream:38,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int go(int, int)':
a.cc:25:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
25 | if(!(x>=x1 && x<=x2 && y>=y1 && y<=y2)) return 0;
| ~^~~~
a.cc: In function 'int main()':
a.cc:48:24: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
48 | cin>>x1>>y1>>x2>>y2;
| ~~~~~~~^~~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
48 | cin>>x1>>y1>>x2>>y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:48:26: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:48:26: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
48 | cin>>x1>>y1>>x2>>y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istr |
s164539994 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
int n,m,dp1[2005][2005],dp2[2005][2005],dp3[2005][2005],q,x1,x2,y1,y2;
char a[2005][2005];
int32_t main(){
ios_base :: sync_with_stdio(0);
cin >> n >> m >> q;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> a[i][j];
dp1[i][j]=dp1[i-1][j]+dp1[i][j-1]-dp1[i-1][j-1]+(int)(a[i][j]=='1');
dp2[i][j]=dp2[i-1][j]+dp2[i][j-1]-dp2[i-1][j-1]+(int)(a[i][j]=='1' && a[i][j-1]=='1');
dp3[i][j]=dp3[i-1][j]+dp3[i][j-1]-dp3[i-1][j-1]+(int)(a[i][j]=='1' && a[i-1][j]=='1');
}
}
for(int i=1;i<=q;i++){
cin >> x1 >> y1 >> x2 >> y2;
cout << dp1[x2][y2]-dp1[x1-1][y2]-dp1[x2][y1-1]+dp1[x1-1][y1-1]-(dp2[x2][y2]-dp2[x1-1][y2]-dp2[x2][y1]+dp2[x1-1][y1])-(dp3[x2][y2]-dp3[x1][y2]-dp3[x2][y1-1]+dp3[x1][y1-1]) << '\n';
}
}
| a.cc:17:65: error: 'int y1' redeclared as different kind of entity
17 | int n,m,dp1[2005][2005],dp2[2005][2005],dp3[2005][2005],q,x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int32_t main()':
a.cc:33:19: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
33 | cin >> x1 >> y1 >> x2 >> y2;
| ~~~~~~~~~ ^~ ~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:33:22: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:33:22: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
33 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__i |
s211024713 | p03707 | C++ | 5 5 6
11010
01110
10101
11101
01010
1 1 5 5
1 2 4 5
2 3 3 4
3 3 3 3
3 1 3 5
1 1 3 4 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 5 5 6
| ^
|
s848312287 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define N 2001
int n, m, sum[N][N], ngang[N][N], doc[N][N], Q;
int x1, y1, x2, y2;
char a[N][N];
// Tinh số thành pahanf liên thông của HCN giới hạn bởi 4 đường x1 y1 x2 y2;
// Theo đề bài : Graph các đỉnh xanh LÀ 1 CÂY
// =>> Số thành phần liên thông của cây : = số đình - số cạnh
// => Duy trì mảng sum (i, j) : Tổng số đỉnh trong khoảng HCN (1, 1) -> (i, j)
// => Duy trì mảng ngang (i, j) : Tổng số cạnh ngang trong khoảng HCN (1, 1) -> (i, j)
// => Duy trì mảng doc (i, j) : Tổng số cạnh dọc trong khoảng HCN (1, 1) -> (i, j)
void Init()
{
cin >> n >> m >> Q;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
sum[i][j] = 0, doc[i][j] = 0, ngang[i][j] = 0;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
{
cin >> a[i][j];
sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + (a[i][j] - '0'); // a(i,j) = 1 khi dinh> mau xanh
ngang[i][j] = ngang[i][j - 1] + ngang[i - 1][j] - ngang[i - 1][j - 1] + (a[i][j] == '1' && a[i][j - 1] == '1' ? 1 : 0); // Nếu có cạnh nối từ a(i,j) xuống HCN(1,1) (i, j - 1) thì số cạnh tăng 1
doc[i][j] = doc[i][j - 1] + doc[i - 1][j] - doc[i - 1][j - 1] + (a[i][j] == '1' && a[i - 1][j] == '1' ? 1 : 0); // Nếu có cạnh nối từ a(i,j) về HCN(1,1) (i - 1, j) thì số cạnh tăng 1
}
}
void Solve()
{
for(int i = 1; i <= Q; i++)
{
cin >> x1 >> y1 >> x2 >> y2;
int cnt_dinh = sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
int cnt_ngang = ngang[x2][y2] - ngang[x1 - 1][y2] - ngang[x2][y1] + ngang[x1 - 1][y1];
int cnt_doc = doc[x2][y2] - doc[x1][y2] - doc[x2][y1 - 1] + doc[x1][y1 - 1];
// Vs đếm ngang thì sẽ tính giới hạn cột từ x1 + 1 đến x2 để tránh cột x1 liên thông svs bên ngoài, tương tự vs đếm dọc
cout << cnt_dinh - cnt_doc - cnt_ngang << endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("NUSKE.INP", "r", stdin);
// freopen("NUSKE.OUT", "w", stdout);
Init();
Solve();
}
| a.cc:6:9: error: 'int y1' redeclared as different kind of entity
6 | int x1, y1, x2, y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'void Solve()':
a.cc:38:19: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
38 | cin >> x1 >> y1 >> x2 >> y2;
| ~~~~~~~~~ ^~ ~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:38:22: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:38:22: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
38 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of |
s454044687 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define N 2001
vector <int> e[N];
int n, m, sum[N][N], ngang[N][N], doc[N][N], Q;
int x1, y1, x2, y2;
char a[N][N];
/// Tinh số thành pahanf liên thông của HCN giới hạn bởi 4 đường x1 y1 x2 y2;
/// Theo đề bài : Graph các đỉnh xanh LÀ 1 CÂY
/// =>> Số thành phần liên thông của cây : = số đình - số cạnh
/// => Duy trì mảng sum (i, j) : Tổng số đỉnh trong khoảng HCN (1, 1) -> (i, j)
/// => Duy trì mảng ngang (i, j) : Tổng số cạnh ngang trong khoảng HCN (1, 1) -> (i, j)
/// => Duy trì mảng doc (i, j) : Tổng số cạnh dọc trong khoảng HCN (1, 1) -> (i, j)
void Init()
{
cin >> n >> m >> Q;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
sum[i][j] = 0, doc[i][j] = 0, ngang[i][j] = 0;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
{
cin >> a[i][j];
sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + (a[i][j] - '0'); /// a(i,j) = 1 khi dinh> mau xanh
ngang[i][j] = ngang[i][j - 1] + ngang[i - 1][j] - ngang[i - 1][j - 1] + (a[i][j] == '1' && a[i][j - 1] == '1' ? 1 : 0); /// Nếu có cạnh nối từ a(i,j) xuống HCN(1,1) (i, j - 1) thì số cạnh tăng 1
doc[i][j] = doc[i][j - 1] + doc[i - 1][j] - doc[i - 1][j - 1] + (a[i][j] == '1' && a[i - 1][j] == '1' ? 1 : 0); /// Nếu có cạnh nối từ a(i,j) về HCN(1,1) (i - 1, j) thì số cạnh tăng 1
}
}
void Solve()
{
for(int i = 1; i <= Q; i++)
{
cin >> x1 >> y1 >> x2 >> y2;
int cnt_dinh = sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
int cnt_ngang = ngang[x2][y2] - ngang[x1 - 1][y2] - ngang[x2][y1] + ngang[x1 - 1][y1];
int cnt_doc = doc[x2][y2] - doc[x1][y2] - doc[x2][y1 - 1] + doc[x1][y1 - 1];
/// Vs đếm ngang thì sẽ tính giới hạn cột từ x1 + 1 đến x2 để tránh cột x1 liên thông svs bên ngoài, tương tự vs đếm dọc
cout << cnt_dinh - cnt_doc - cnt_ngang << endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("NUSKE.INP", "r", stdin);
// freopen("NUSKE.OUT", "w", stdout);
Init();
Solve();
}
| a.cc:7:9: error: 'int y1' redeclared as different kind of entity
7 | int x1, y1, x2, y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'void Solve()':
a.cc:39:19: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
39 | cin >> x1 >> y1 >> x2 >> y2;
| ~~~~~~~~~ ^~ ~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:39:22: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:39:22: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
39 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of |
s472348236 | p03707 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
int N,M,Q;
char A[2001][2001];
int sm[2000][2000];
int smLeft[2000][2000];
int smUp[2000][2000];
void psum(int v[2000][2000])
{
for(int i=0;i<N;i++)
for(int j=0;j<M;j++)
{
if(i) v[i][j] += v[i-1][j];
if(j) v[i][j] += v[i][j-1];
if(i && j) v[i][j] -= v[i-1][j-1];
}
}
int main()
{
scanf("%d %d %d",&N,&M,&Q);
for(int i=0;i<N;i++)
{
scanf("%s",A[i]);
for(int j=0;j<M;j++)
{
if(A[i][j]=='1')
{
sm[i][j]++;
if(i && A[i-1][j]=='1') smUp[i][j]++;
if(j && A[i][j-1]=='1') smLeft[i][j]++;
}
}
}
psum(sm);
psum(smLeft);
psum(smUp);
int x1,y1,x2,y2;
for(int i=0;i<Q;i++)
{
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
x1--,y1--,x2--,y2--;
int ans = sm[x2][y2] - smUp[x2][y2] - smLeft[x2][y2];
if(x1) ans -= (sm[x1-1][y2] - smUp[x1][y2] - smLeft[x1-1][y2]);
if(y1) ans -= (sm[x2][y1-1] - smUp[x2][y1-1] - smLeft[x2][y1]);
if(x1 && y1) ans += (sm[x1-1][y1-1] - smUp[x1][y1-1] - smLeft[x1-1][y1]);
cout << ans << '\n';
}
} | a.cc: In function 'int main()':
a.cc:50:17: error: 'cout' was not declared in this scope
50 | cout << ans << '\n';
| ^~~~
a.cc:3:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include <algorithm>
+++ |+#include <iostream>
3 | using namespace std;
|
s693976439 | p03707 | C++ | 123 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 123
| ^~~
|
s937802550 | p03707 | C++ | #include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int n, m, Q;
bool vis[2002][2002];
int G[2002][2002];
int g[2002][2002];
int x1,x2,y1,y2;
int cnt;
void dfs(int i, int j){
if(vis[i][j] || G[i][j] == 0) return;
if(i<x1||i>x2||j<y1||j>y2) return;
vis[i][j] = true;
dfs(i+1,j);
dfs(i-1,j);
dfs(i,j+1);
dfs(i,j-1);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> Q;
string s;
for(int i = 1; i <= n; i++){
cin >> s;
for(int j = 1; j <= m; j++){
G[i][j] = s[j-1] == '0' ? 0 : 1;
// if(G[i][j] == 0) g[i][j] = 0;
}
}
for(int q = 1; q <= Q; q++){
cin >> x1 >> y1 >> x2 >> y2;
if(x1 > x2) swap(x1, x2);
if(y1 > y2) swap(y1, y2);
mem(vis,false);
cnt = 0;
for(int i = x1; i <= x2; i++){
for(int j = y1; j <= y2; j++){
if(!vis[i][j] && G[i][j] != 0)
dfs(i,j),cnt++;
}
}
cout << cnt << endl;
}
return 0;
} | a.cc:8:11: error: 'int y1' redeclared as different kind of entity
8 | int x1,x2,y1,y2;
| ^~
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:12:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if(i<x1||i>x2||j<y1||j>y2) return;
| ~^~~
a.cc: In function 'int main()':
a.cc:34:19: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
34 | cin >> x1 >> y1 >> x2 >> y2;
| ~~~~~~~~~ ^~ ~~
| | |
| | double(double) noexcept
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(short int)y1' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(int)y1' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(long int)y1' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(long long int)y1' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
a.cc:34:22: error: cannot bind rvalue '(void*)y1' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:34:22: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
34 | cin >> x1 >> y1 >> x2 >> y2;
| ^~
| |
| double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::bas |
s641742144 | p03707 | C++ | import sys
import numpy as np
import copy
n, m, q = [int(x) for x in sys.stdin.readline().split()]
def lister(n):
s = []
for _ in range(n):
a = input()
s.append(list(map(int, a)))
return s
def normal_accumulator(s):
for i in s:
for j,k in enumerate(i):
if j != 0:
i[j] = k + i[j-1]
for i in range(m):
for j in range(n):
if j != 0:
s[j][i] += s[j-1][i]
return s
def horizontal_accumulator(s):
sh = []
for i in s:
st = []
for j,k in enumerate(i):
if j == 0:
st.append(0)
else:
if k == 1 and i[j-1] == 1:
st.append(st[j-1]+1)
else:
st.append(st[j-1])
sh.append(st)
for i in range(m):
for j in range(n):
if j != 0:
sh[j][i] += sh[j-1][i]
return sh
def vertical_accumulator(s):
sv = np.zeros((n,m),dtype=int)
for i in range(m):
for j in range(1,n):
if s[j][i] == 1 and s[j-1][i] == 1:
sv[j][i] = sv[j-1][i] + 1
for i in sv:
for j,k in enumerate(i):
if j != 0:
i[j] = k + i[j-1]
return sv
def devider(s,x1,y1,x2,y2):
return s[x1-1][y1-1] + s[x2][y2] - s[x1-1][y2] - s[x2][y1-1]
s = lister(n)
s_copy = copy.deepcopy(s)
sa = normal_accumulator(s_copy)
sh = horizontal_accumulator(s)
sv = vertical_accumulator(s)
sc = sh + sv
for _ in range(q):
x1,y1,x2,y2 = [int(x) for x in sys.stdin.readline().split()]
ans = devider(sa, x1, y1, x2, y2) - devider(sc, x1, y1, x2, y2)
print(ans) | a.cc:1:1: error: 'import' does not name a type
1 | import sys
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s619068163 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gc getchar
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
const int tb[]={0,1,0,-1};
const int tk[]={1,0,-1,0};
int petas[2][2005][2005]={},baris,kolom,q,prefiks[2][2005][2005]={},prefikslain[2][2005][2005]={};
template <typename T> void fastscan(T &angka){
angka=0;
char input=gc();
while(!(48<=input&&input<=57)) input=gc();
while(48<=input&&input<=57) angka=(angka<<3)+(angka<<1)+input-48,input=gc();
}
bool masuk(int bar,int kol){
return (1<=bar&&bar<=baris&&1<=kol&&kol<=kolom);
}
void isipetas(){
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
if(petas[0][i][j]==0)
continue;
for(int k=0;k<4;k++)
{
//cout<<"dari "<<i<<" "<<j<<" ke "<<i+tb[k]<<" "<<j+tk[k]<<endl;
if(!masuk(i+tb[k],j+tk[k]))
continue;
petas[1][i][j]+=petas[0][i+tb[k]][j+tk[k]];
}
}
}
}
void buatprefiks(int jenis){
for(int i=1;i<=baris;i++)
for(int j=1;j<=kolom;j++)
prefiks[jenis][i][j]=prefiks[jenis][i-1][j]+prefiks[jenis][i][j-1]-prefiks[jenis][i-1][j-1]+petas[jenis][i][j];
}
void buatprefiks(){
buatprefiks(1);
buatprefiks(0);
}
int total(int jenis,pii awal,pii akhir){
int ret=prefiks[jenis][akhir.fi][akhir.se]-prefiks[jenis][awal.fi-1][akhir.se]-prefiks[jenis][akhir.fi][awal.se-1]+prefiks[jenis][awal.fi-1][awal.se-1];
return ret;
}
//0 itu melintang, 1 itu menurun
isiprefikslain(int jenis){
if(jenis==0)
{
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][0]=0;
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i][j-1]+((petas[0][i][j]==1&&petas[0][i-1][j]==1)?1:0);
}
}
}
else
{
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][0][j]=0;
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i-1][j]+((petas[0][i][j-1]==1&&petas[0][i][j]==1)?1:0);
}
}
}
}
void isiprefikslain(){
isiprefikslain(0);
isiprefikslain(1);
}
int main()
{
fastscan(baris),fastscan(kolom),fastscan(q);
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
char input=gc();
while(!(48<=input&&input<=49)) input=gc();
petas[0][i][j]=input-48;
}
}
isipetas();
buatprefiks();
isiprefikslain();
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[1][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<prefikslain[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
for(int i=1;i<=q;i++)
{
pii awal,akhir;
fastscan(awal.fi),fastscan(awal.se);
fastscan(akhir.fi),fastscan(akhir.se);
int a=total(0,awal,akhir),b=total(1,awal,akhir);
//a itu nodes, b itu edge
//cout<<"awalnya "<<a<<" "<<b<<endl;
b-=prefikslain[0][awal.fi][akhir.se]-prefikslain[0][awal.fi][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[0][akhir.fi+1][akhir.se]-prefikslain[0][akhir.fi+1][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][awal.se]-prefikslain[1][awal.fi-1][awal.se];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][akhir.se+1]-prefikslain[1][awal.fi-1][akhir.se+1];
//cout<<"akhirnya "<<a<<" "<<b<<endl;
b=b>>1;
//cout<<"akhirnya "<<a<<" "<<b<<endl;
printf("%d\n",a-b);
}
} | a.cc:55:1: error: ISO C++ forbids declaration of 'isiprefikslain' with no type [-fpermissive]
55 | isiprefikslain(int jenis){
| ^~~~~~~~~~~~~~
a.cc: In function 'int isiprefikslain(int)':
a.cc:78:1: warning: no return statement in function returning non-void [-Wreturn-type]
78 | }
| ^
|
s357211607 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gc getchar
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
const int tb[]={0,1,0,-1};
const int tk[]={1,0,-1,0};
int petas[2][2005][2005]={},baris,kolom,q,prefiks[2][2005][2005]={},prefikslain[2][2005][2005]={};
template <typename T> void fastscan(T &angka){
angka=0;
char input=gc();
while(!(48<=input&&input<=57)) input=gc();
while(48<=input&&input<=57) angka=(angka<<3)+(angka<<1)+input-48,input=gc();
}
bool masuk(int bar,int kol){
return (1<=bar&&bar<=baris&&1<=kol&&kol<=kolom);
}
void isipetas(){
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
if(petas[0][i][j]==0)
continue;
for(int k=0;k<4;k++)
{
//cout<<"dari "<<i<<" "<<j<<" ke "<<i+tb[k]<<" "<<j+tk[k]<<endl;
if(!masuk(i+tb[k],j+tk[k]))
continue;
petas[1][i][j]+=petas[0][i+tb[k]][j+tk[k]];
}
}
}
}
void buatprefiks(int jenis){
for(int i=1;i<=baris;i++)
for(int j=1;j<=kolom;j++)
prefiks[jenis][i][j]=prefiks[jenis][i-1][j]+prefiks[jenis][i][j-1]-prefiks[jenis][i-1][j-1]+petas[jenis][i][j];
}
/*void buatprefiks(){
buatprefiks(1);
buatprefiks(0);
}*/
int total(int jenis,pii awal,pii akhir){
int ret=prefiks[jenis][akhir.fi][akhir.se]-prefiks[jenis][awal.fi-1][akhir.se]-prefiks[jenis][akhir.fi][awal.se-1]+prefiks[jenis][awal.fi-1][awal.se-1];
return ret;
}
//0 itu melintang, 1 itu menurun
isiprefikslain(int jenis){
if(jenis==0)
{
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][0]=0;
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i][j-1]+((petas[0][i][j]==1&&petas[0][i-1][j]==1)?1:0);
}
}
}
else
{
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][0][j]=0;
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i-1][j]+((petas[0][i][j-1]==1&&petas[0][i][j]==1)?1:0);
}
}
}
}
/*isiprefikslain(){
isiprefikslain(0);
isiprefikslain(1);
}*/
int main()
{
fastscan(baris),fastscan(kolom),fastscan(q);
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
char input=gc();
while(!(48<=input&&input<=49)) input=gc();
petas[0][i][j]=input-48;
}
}
isipetas();
buatprefiks(1);
buatprefiks(0);
//buatprefiks();
//isiprefikslain();
isiprefikslain(0);
isiprefikslain(1);
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[1][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<prefikslain[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
for(int i=1;i<=q;i++)
{
pii awal,akhir;
fastscan(awal.fi),fastscan(awal.se);
fastscan(akhir.fi),fastscan(akhir.se);
int a=total(0,awal,akhir),b=total(1,awal,akhir);
//a itu nodes, b itu edge
//cout<<"awalnya "<<a<<" "<<b<<endl;
b-=prefikslain[0][awal.fi][akhir.se]-prefikslain[0][awal.fi][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[0][akhir.fi+1][akhir.se]-prefikslain[0][akhir.fi+1][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][awal.se]-prefikslain[1][awal.fi-1][awal.se];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][akhir.se+1]-prefikslain[1][awal.fi-1][akhir.se+1];
//cout<<"akhirnya "<<a<<" "<<b<<endl;
b=b>>1;
//cout<<"akhirnya "<<a<<" "<<b<<endl;
printf("%d\n",a-b);
}
} | a.cc:55:1: error: ISO C++ forbids declaration of 'isiprefikslain' with no type [-fpermissive]
55 | isiprefikslain(int jenis){
| ^~~~~~~~~~~~~~
a.cc: In function 'int isiprefikslain(int)':
a.cc:78:1: warning: no return statement in function returning non-void [-Wreturn-type]
78 | }
| ^
|
s038698251 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gc getchar
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
const int tb[]={0,1,0,-1};
const int tk[]={1,0,-1,0};
int petas[2][2005][2005]={},baris,kolom,q,prefiks[2][2005][2005]={},prefikslain[2][2005][2005]={};
template <typename T> void fastscan(T &angka){
angka=0;
char input=gc();
while(!(48<=input&&input<=57)) input=gc();
while(48<=input&&input<=57) angka=(angka<<3)+(angka<<1)+input-48,input=gc();
}
bool masuk(int bar,int kol){
return (1<=bar&&bar<=baris&&1<=kol&&kol<=kolom);
}
void isipetas(){
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
if(petas[0][i][j]==0)
continue;
for(int k=0;k<4;k++)
{
//cout<<"dari "<<i<<" "<<j<<" ke "<<i+tb[k]<<" "<<j+tk[k]<<endl;
if(!masuk(i+tb[k],j+tk[k]))
continue;
petas[1][i][j]+=petas[0][i+tb[k]][j+tk[k]];
}
}
}
}
void buatprefiks(int jenis){
for(int i=1;i<=baris;i++)
for(int j=1;j<=kolom;j++)
prefiks[jenis][i][j]=prefiks[jenis][i-1][j]+prefiks[jenis][i][j-1]-prefiks[jenis][i-1][j-1]+petas[jenis][i][j];
}
void buatprefiks(){
buatprefiks(1);
buatprefiks(0);
}
int total(int jenis,pii awal,pii akhir){
int ret=prefiks[jenis][akhir.fi][akhir.se]-prefiks[jenis][awal.fi-1][akhir.se]-prefiks[jenis][akhir.fi][awal.se-1]+prefiks[jenis][awal.fi-1][awal.se-1];
return ret;
}
//0 itu melintang, 1 itu menurun
isiprefikslain(int jenis){
if(jenis==0)
{
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][0]=0;
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i][j-1]+((petas[0][i][j]==1&&petas[0][i-1][j]==1)?1:0);
}
}
}
else
{
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][0][j]=0;
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i-1][j]+((petas[0][i][j-1]==1&&petas[0][i][j]==1)?1:0);
}
}
}
}
/*isiprefikslain(){
isiprefikslain(0);
isiprefikslain(1);
}*/
int main()
{
fastscan(baris),fastscan(kolom),fastscan(q);
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
char input=gc();
while(!(48<=input&&input<=49)) input=gc();
petas[0][i][j]=input-48;
}
}
isipetas();
buatprefiks();
//isiprefikslain();
isiprefikslain(0);
isiprefikslain(1);
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[1][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<prefikslain[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
for(int i=1;i<=q;i++)
{
pii awal,akhir;
fastscan(awal.fi),fastscan(awal.se);
fastscan(akhir.fi),fastscan(akhir.se);
int a=total(0,awal,akhir),b=total(1,awal,akhir);
//a itu nodes, b itu edge
//cout<<"awalnya "<<a<<" "<<b<<endl;
b-=prefikslain[0][awal.fi][akhir.se]-prefikslain[0][awal.fi][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[0][akhir.fi+1][akhir.se]-prefikslain[0][akhir.fi+1][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][awal.se]-prefikslain[1][awal.fi-1][awal.se];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][akhir.se+1]-prefikslain[1][awal.fi-1][akhir.se+1];
//cout<<"akhirnya "<<a<<" "<<b<<endl;
b=b>>1;
//cout<<"akhirnya "<<a<<" "<<b<<endl;
printf("%d\n",a-b);
}
} | a.cc:55:1: error: ISO C++ forbids declaration of 'isiprefikslain' with no type [-fpermissive]
55 | isiprefikslain(int jenis){
| ^~~~~~~~~~~~~~
a.cc: In function 'int isiprefikslain(int)':
a.cc:78:1: warning: no return statement in function returning non-void [-Wreturn-type]
78 | }
| ^
|
s773670863 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gc getchar
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
const int tb[]={0,1,0,-1};
const int tk[]={1,0,-1,0};
int petas[2][2005][2005]={},baris,kolom,q,prefiks[2][2005][2005]={},prefikslain[2][2005][2005]={};
template <typename T> void fastscan(T &angka){
angka=0;
char input=gc();
while(!(48<=input&&input<=57)) input=gc();
while(48<=input&&input<=57) angka=(angka<<3)+(angka<<1)+input-48,input=gc();
}
bool masuk(int bar,int kol){
return (1<=bar&&bar<=baris&&1<=kol&&kol<=kolom);
}
void isipetas(){
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
if(petas[0][i][j]==0)
continue;
for(int k=0;k<4;k++)
{
//cout<<"dari "<<i<<" "<<j<<" ke "<<i+tb[k]<<" "<<j+tk[k]<<endl;
if(!masuk(i+tb[k],j+tk[k]))
continue;
petas[1][i][j]+=petas[0][i+tb[k]][j+tk[k]];
}
}
}
}
void buatprefiks(int jenis){
for(int i=1;i<=baris;i++)
for(int j=1;j<=kolom;j++)
prefiks[jenis][i][j]=prefiks[jenis][i-1][j]+prefiks[jenis][i][j-1]-prefiks[jenis][i-1][j-1]+petas[jenis][i][j];
}
void buatprefiks(){
buatprefiks(1);
buatprefiks(0);
}
int total(int jenis,pii awal,pii akhir){
int ret=prefiks[jenis][akhir.fi][akhir.se]-prefiks[jenis][awal.fi-1][akhir.se]-prefiks[jenis][akhir.fi][awal.se-1]+prefiks[jenis][awal.fi-1][awal.se-1];
return ret;
}
//0 itu melintang, 1 itu menurun
isiprefikslain(int jenis){
if(jenis==0)
{
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][0]=0;
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i][j-1]+((petas[0][i][j]==1&&petas[0][i-1][j]==1)?1:0);
}
}
}
else
{
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][0][j]=0;
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i-1][j]+((petas[0][i][j-1]==1&&petas[0][i][j]==1)?1:0);
}
}
}
}
isiprefikslain(){
isiprefikslain(0);
isiprefikslain(1);
}
int main()
{
fastscan(baris),fastscan(kolom),fastscan(q);
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
char input=gc();
while(!(48<=input&&input<=49)) input=gc();
petas[0][i][j]=input-48;
}
}
isipetas();
buatprefiks();
isiprefikslain();
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[1][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<prefikslain[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
for(int i=1;i<=q;i++)
{
pii awal,akhir;
fastscan(awal.fi),fastscan(awal.se);
fastscan(akhir.fi),fastscan(akhir.se);
int a=total(0,awal,akhir),b=total(1,awal,akhir);
//a itu nodes, b itu edge
//cout<<"awalnya "<<a<<" "<<b<<endl;
b-=prefikslain[0][awal.fi][akhir.se]-prefikslain[0][awal.fi][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[0][akhir.fi+1][akhir.se]-prefikslain[0][akhir.fi+1][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][awal.se]-prefikslain[1][awal.fi-1][awal.se];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][akhir.se+1]-prefikslain[1][awal.fi-1][akhir.se+1];
//cout<<"akhirnya "<<a<<" "<<b<<endl;
b=b>>1;
//cout<<"akhirnya "<<a<<" "<<b<<endl;
printf("%d\n",a-b);
}
} | a.cc:55:1: error: ISO C++ forbids declaration of 'isiprefikslain' with no type [-fpermissive]
55 | isiprefikslain(int jenis){
| ^~~~~~~~~~~~~~
a.cc: In function 'int isiprefikslain(int)':
a.cc:78:1: warning: no return statement in function returning non-void [-Wreturn-type]
78 | }
| ^
a.cc: At global scope:
a.cc:79:1: error: ISO C++ forbids declaration of 'isiprefikslain' with no type [-fpermissive]
79 | isiprefikslain(){
| ^~~~~~~~~~~~~~
a.cc: In function 'int isiprefikslain()':
a.cc:82:1: warning: no return statement in function returning non-void [-Wreturn-type]
82 | }
| ^
|
s736353247 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gc getchar
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
const int tb[]={0,1,0,-1};
const int tk[]={1,0,-1,0};
int petas[2][2005][2005]={},baris,kolom,q,prefiks[2][2005][2005]={},prefikslain[2][2005][2005]={};
template <typename T> void fastscan(T &angka){
angka=0;
char input=gc();
while(!(48<=input&&input<=57)) input=gc();
while(48<=input&&input<=57) angka=(angka<<3)+(angka<<1)+input-48,input=gc();
}
bool masuk(int bar,int kol){
return (1<=bar&&bar<=baris&&1<=kol&&kol<=kolom);
}
void isipetas(){
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
if(petas[0][i][j]==0)
continue;
for(int k=0;k<4;k++)
{
//cout<<"dari "<<i<<" "<<j<<" ke "<<i+tb[k]<<" "<<j+tk[k]<<endl;
if(!masuk(i+tb[k],j+tk[k]))
continue;
petas[1][i][j]+=petas[0][i+tb[k]][j+tk[k]];
}
}
}
}
void buatprefiks(int jenis){
for(int i=1;i<=baris;i++)
for(int j=1;j<=kolom;j++)
prefiks[jenis][i][j]=prefiks[jenis][i-1][j]+prefiks[jenis][i][j-1]-prefiks[jenis][i-1][j-1]+petas[jenis][i][j];
}
void buatprefiks(){
buatprefiks(1);
buatprefiks(0);
}
int total(int jenis,pii awal,pii akhir){
int ret=prefiks[jenis][akhir.fi][akhir.se]-prefiks[jenis][awal.fi-1][akhir.se]-prefiks[jenis][akhir.fi][awal.se-1]+prefiks[jenis][awal.fi-1][awal.se-1];
return ret;
}
//0 itu melintang, 1 itu menurun
isiprefikslain(int jenis){
if(jenis==0)
{
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][0]=0;
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i][j-1]+((petas[0][i][j]==1&&petas[0][i-1][j]==1)?1:0);
}
}
}
else
{
for(int j=1;j<=kolom;j++)
{
prefikslain[jenis][0][j]=0;
for(int i=1;i<=baris;i++)
{
prefikslain[jenis][i][j]=prefikslain[jenis][i-1][j]+(petas[0][i][j-1]==1&&petas[0][i][j]==1)?1:0;
}
}
}
}
isiprefikslain(){
isiprefikslain(0);
isiprefikslain(1);
}
int main()
{
fastscan(baris),fastscan(kolom),fastscan(q);
for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
{
char input=gc();
while(!(48<=input&&input<=49)) input=gc();
petas[0][i][j]=input-48;
}
}
isipetas();
buatprefiks();
isiprefikslain();
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<petas[1][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
/*for(int i=1;i<=baris;i++)
{
for(int j=1;j<=kolom;j++)
cout<<prefikslain[0][i][j]<<" ";
cout<<endl;
}
cout<<endl;*/
for(int i=1;i<=q;i++)
{
pii awal,akhir;
fastscan(awal.fi),fastscan(awal.se);
fastscan(akhir.fi),fastscan(akhir.se);
int a=total(0,awal,akhir),b=total(1,awal,akhir);
//a itu nodes, b itu edge
//cout<<"awalnya "<<a<<" "<<b<<endl;
b-=prefikslain[0][awal.fi][akhir.se]-prefikslain[0][awal.fi][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[0][akhir.fi+1][akhir.se]-prefikslain[0][akhir.fi+1][awal.se-1];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][awal.se]-prefikslain[1][awal.fi-1][awal.se];
//cout<<b<<endl;
b-=prefikslain[1][akhir.fi][akhir.se+1]-prefikslain[1][awal.fi-1][akhir.se+1];
//cout<<"akhirnya "<<a<<" "<<b<<endl;
b=b>>1;
//cout<<"akhirnya "<<a<<" "<<b<<endl;
printf("%d\n",a-b);
}
} | a.cc:55:1: error: ISO C++ forbids declaration of 'isiprefikslain' with no type [-fpermissive]
55 | isiprefikslain(int jenis){
| ^~~~~~~~~~~~~~
a.cc: In function 'int isiprefikslain(int)':
a.cc:78:1: warning: no return statement in function returning non-void [-Wreturn-type]
78 | }
| ^
a.cc: At global scope:
a.cc:79:1: error: ISO C++ forbids declaration of 'isiprefikslain' with no type [-fpermissive]
79 | isiprefikslain(){
| ^~~~~~~~~~~~~~
a.cc: In function 'int isiprefikslain()':
a.cc:82:1: warning: no return statement in function returning non-void [-Wreturn-type]
82 | }
| ^
|
s197442570 | p03707 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
using namespace std;
int check(int x, int y, const vector< vector<int> > &v)
{
if (x < 0 || y < 0) return 0;
else return v[x][y];
}
int main()
{
int N, M, Q;
if (scanf("%d%d%d", &N, &M, &Q) < 3) return 0;
vector<string> S(2000);
for (int i = 0; i < N; i++)
{
char tmp[2001];
if (scanf("%s", tmp) < 1) return 0;
S[i] = tmp;
}
vector< vector<int> > BH(N, vector<int>(M));
for (int i = 0; i < N; i++)
{
int bk = 0;
for (int j = 0; j < M; j++)
{
int s = S[i][j] - '0';
BH[i][j] += bk + s;
bk = BH[i][j];
if (0 <= i - 1 && 0 <= j - 1) BH[i][j - 1] += BH[i - 1][j - 1];
}
if (0 <= i - 1) BH[i][M - 1] += BH[i - 1][M - 1];
}
vector< vector<int> > H(N, vector<int>(M));
for (int i = 0; i < N; i++)
{
int bk = 0;
int pre = 0;
for (int j = 0; j < M; j++)
{
int s = S[i][j] - '0';
H[i][j] += pre & s ? bk + 1 : bk;
pre = s;
bk = H[i][j];
}
}
vector< vector<int> > V(N, vector<int>(M));
for (int i = 0; i < M; i++)
{
int bk = 0;
int pre = 0;
for (int j = 0; j < N; j++)
{
int s = S[j][i] - '0';
V[j][i] += pre & s ? bk + 1 : bk;
pre = s;
bk = V[j][i];
}
}
for (int i = 0; i < Q; i++)
{
int x1, y1, x2, y2;
if (scanf("%d%d%d%d", &x1, &y1, &x2, &y2) < 4) return 0;
int b =
BH[x2 - 1][y2 - 1] - check(x2 - 1, y1 - 2, BH)
- check(x1 - 2, y2 - 1, BH) + check(x1 - 2, y1 - 2, BH);
int h = 0;
for (int i = x1 - 1; i < x2; i++)
{
h += H[i][y2 - 1] - H[i][y1 - 1];
}
int v = 0;
for (int i = y1 - 1; i < y2; i++)
{
v += V[x2 - 1][i] - V[x1 - 1][i];
}
printf("%d\n", b - h - v);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:12: error: 'string' was not declared in this scope
18 | vector<string> S(2000);
| ^~~~~~
a.cc:4:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
3 | #include <vector>
+++ |+#include <string>
4 |
a.cc:18:18: error: template argument 1 is invalid
18 | vector<string> S(2000);
| ^
a.cc:18:18: error: template argument 2 is invalid
a.cc:24:10: error: invalid types 'int[int]' for array subscript
24 | S[i] = tmp;
| ^
a.cc:34:22: error: invalid types 'int[int]' for array subscript
34 | int s = S[i][j] - '0';
| ^
a.cc:51:22: error: invalid types 'int[int]' for array subscript
51 | int s = S[i][j] - '0';
| ^
a.cc:66:22: error: invalid types 'int[int]' for array subscript
66 | int s = S[j][i] - '0';
| ^
|
s372701262 | p03707 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(int i = (l) ; i < (r); i++)
#define incII(i, l, r) for(int i = (l) ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r) ; i >= (l); i--)
#define inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) < (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)
template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
// ---- ----
int n, m, q, x1[200000], y1[200000], x2[200000], y2[200000];
string s[2000];
int c[2001][2001];
int v[2001][2001];
int h[2001][2001];
int main() {
cin >> n >> m >> q;
inc(i, n) { cin >> s[i]; }
inc(i, q) { scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]); }
inc1(i, n) {
inc1(j, m) {
c[i][j] = s[i - 1][j - 1] - '0';
v[i][j] = (j < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 1][j - 2] == '1');
h[i][j] = (i < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 2][j - 1] == '1');
}
}
inc1(i, n) {
inc1(j, m) {
c[i][j] += c[i - 1][j];
v[i][j] += v[i - 1][j];
h[i][j] += h[i - 1][j];
}
}
inc1(i, n) {
inc1(j, m) {
c[i][j] += c[i][j - 1];
v[i][j] += v[i][j - 1];
h[i][j] += h[i][j - 1];
}
}
inc(i, q) {
x1[i]--;
y1[i]--;
#define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
int C = R(c, x1[i] , y1[i] , x2[i], y2[i]);
int V = R(v, x1[i] , y1[i] + 1, x2[i], y2[i]);
int H = R(h, x1[i] + 1, y1[i] , x2[i], y2[i]);
printf("%d\n", C - V - H);
}
return 0;
}
| a.cc:42:35: error: 'int y1 [200000]' redeclared as different kind of entity
42 | int n, m, q, x1[200000], y1[200000], x2[200000], y2[200000];
| ^
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
257 | __MATHCALL (y1,, (_Mdouble_));
| ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:52:52: warning: pointer to a function used in arithmetic [-Wpointer-arith]
52 | inc(i, q) { scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]); }
| ^
a.cc:78:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
78 | y1[i]--;
| ^
a.cc:78:21: warning: ISO C++ forbids decrementing a pointer of type 'double (*)(double) noexcept' [-Wpointer-arith]
78 | y1[i]--;
| ~~~~^
a.cc:78:21: error: lvalue required as decrement operand
78 | y1[i]--;
| ^
a.cc:81:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
81 | int C = R(c, x1[i] , y1[i] , x2[i], y2[i]);
| ^
a.cc:80:77: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:80:76: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^
a.cc:81:25: note: in expansion of macro 'R'
81 | int C = R(c, x1[i] , y1[i] , x2[i], y2[i]);
| ^
a.cc:81:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
81 | int C = R(c, x1[i] , y1[i] , x2[i], y2[i]);
| ^
a.cc:80:89: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:80:88: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^
a.cc:81:25: note: in expansion of macro 'R'
81 | int C = R(c, x1[i] , y1[i] , x2[i], y2[i]);
| ^
a.cc:82:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | int V = R(v, x1[i] , y1[i] + 1, x2[i], y2[i]);
| ^
a.cc:80:77: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:82:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | int V = R(v, x1[i] , y1[i] + 1, x2[i], y2[i]);
| ~~~~~~^~~
a.cc:80:77: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:80:76: error: invalid types 'int [2001][double (*)(double) noexcept]' for array subscript
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^
a.cc:82:25: note: in expansion of macro 'R'
82 | int V = R(v, x1[i] , y1[i] + 1, x2[i], y2[i]);
| ^
a.cc:82:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | int V = R(v, x1[i] , y1[i] + 1, x2[i], y2[i]);
| ^
a.cc:80:89: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:82:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
82 | int V = R(v, x1[i] , y1[i] + 1, x2[i], y2[i]);
| ~~~~~~^~~
a.cc:80:89: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:80:88: error: invalid types 'int [2001][double (*)(double) noexcept]' for array subscript
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^
a.cc:82:25: note: in expansion of macro 'R'
82 | int V = R(v, x1[i] , y1[i] + 1, x2[i], y2[i]);
| ^
a.cc:83:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | int H = R(h, x1[i] + 1, y1[i] , x2[i], y2[i]);
| ^
a.cc:80:77: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:80:76: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^
a.cc:83:25: note: in expansion of macro 'R'
83 | int H = R(h, x1[i] + 1, y1[i] , x2[i], y2[i]);
| ^
a.cc:83:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
83 | int H = R(h, x1[i] + 1, y1[i] , x2[i], y2[i]);
| ^
a.cc:80:89: note: in definition of macro 'R'
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^~
a.cc:80:88: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
80 | #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
| ^
a.cc:83:25: note: in expansion of macro 'R'
83 | int H = R(h, x1[i] + 1, y1[i] , x2[i], y2[i]);
| ^
|
s709864072 | p03707 | C++ | #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
//#define ZTDebug
//#define ZTVerbose
//#define ZTRandomTest
#ifdef ZTDebug
#define In scanf_s
#else
#define In scanf
#endif // ZTDebug
#define Ind(d) In("%d", &d)
#define Ind2(a, b) In("%d%d", &a, &b)
#define InD(d) int d; In("%d", &d);
#define InD2(a, b) int a, b; In("%d%d", &a, &b);
#define InDN(n, v) for (auto _i = 0; _i < n; ++_i) In("%d", &v[_i]);
#define OutDNLine(n, v) for (auto _i = 0; _i < n; ++_i) printf("%d%c", *(v + _i), _i + 1 == n ? '\n' : ' ');
typedef double db;
typedef long long LL;
typedef pair<int, int> pii;
const int Max = 2010;
int blues[Max][Max];
int up[Max][Max];
int lt[Max][Max];
char s[Max][Max];
int isBlue(int i, int j, int b) { return s[i][j] == '1' ? b : 0; }
void setS(int b[][Max], int i, int j, int d) {
b[i][j] = d + b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
}
int getSq(int b[][Max], int i1, int j1, int i2, int j2) {
return b[i2][j2] - b[i2][j1 - 1] - b[i1 - 1][j2] + b[i1 - 1][j2 - 1];
}
int main() {
#ifdef ZTDebug
while (true) {
#endif // ZTDebug
#ifdef ZTRandomTest
int n = 128; for (auto i = 0; i < n; ++i) os[i] = rand() % 26 + 'a'; os[n] = '\0';
#else
InD2(n, m);
InD(q);
for (auto i = 1; i <= 1; ++i) In("%s", s[i] + 1);
for (auto i = 1; i <= n; ++i)
for (auto j = 1; j <= n; ++j) {
auto b = isBlue(i, j, 1);
setS(blues, i, j, b);
setS(up, i, j, isBlue(i - 1, j, b));
setS(lt, i, j, isBlue(i, j - 1, b));
}
for (auto i = 1; i <= q; ++i) {
InD2(x1, y1);
InD2(x2, y2);
auto cn = getSq(blues, x1, y1, x2, y2);
auto ce = getSq(up, x1 + 1, y1, x2, y2) + getSq(lt, x1, y1 + 1, x2, y2);
cout << cn - ce << endl;
}
}
#endif // ZTDebug
return 0;
}
| a.cc:71:5: error: expected unqualified-id before 'return'
71 | return 0;
| ^~~~~~
a.cc:72:1: error: expected declaration before '}' token
72 | }
| ^
|
s319621232 | p03707 | C++ | #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define ZTDebug
//#define ZTVerbose
//#define ZTRandomTest
#ifdef ZTDebug
#define In scanf_s
#else
#define In scanf
#endif // ZTDebug
#define Ind(d) In("%d", &d)
#define Ind2(a, b) In("%d%d", &a, &b)
#define InD(d) int d; In("%d", &d);
#define InD2(a, b) int a, b; In("%d%d", &a, &b);
#define InDN(n, v) for (auto _i = 0; _i < n; ++_i) In("%d", &v[_i]);
#define OutDNLine(n, v) for (auto _i = 0; _i < n; ++_i) printf("%d%c", *(v + _i), _i + 1 == n ? '\n' : ' ');
typedef double db;
typedef long long LL;
typedef pair<int, int> pii;
const int Max = 2010;
int blues[Max][Max];
int up[Max][Max];
int lt[Max][Max];
char s[Max][Max];
int isBlue(int i, int j, int b) { return s[i][j] == '1' ? b : 0; }
void setS(int b[][Max], int i, int j, int d) {
b[i][j] = d + b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
}
int getSq(int b[][Max], int i1, int j1, int i2, int j2) {
return b[i2][j2] - b[i2][j1 - 1] - b[i1 - 1][j2] + b[i1 - 1][j2 - 1];
}
int main() {
#ifdef ZTDebug
while (true) {
#endif // ZTDebug
#ifdef ZTRandomTest
int n = 128; for (auto i = 0; i < n; ++i) os[i] = rand() % 26 + 'a'; os[n] = '\0';
#else
InD2(n, m);
InD(q);
for (auto i = 1; i <= 1; ++i) In("%s", s[i] + 1);
for (auto i = 1; i <= n; ++i)
for (auto j = 1; j <= n; ++j) {
auto b = isBlue(i, j, 1);
setS(blues, i, j, b);
setS(up, i, j, isBlue(i - 1, j, b));
setS(lt, i, j, isBlue(i, j - 1, b));
}
for (auto i = 1; i <= q; ++i) {
InD2(x1, y1);
InD2(x2, y2);
auto cn = getSq(blues, x1, y1, x2, y2);
auto ce = getSq(up, x1 + 1, y1, x2, y2) + getSq(lt, x1, y1 + 1, x2, y2);
cout << cn - ce << endl;
}
}
#endif // ZTDebug
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:12: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
15 | #define In scanf_s
| ^~~~~~~
a.cc:23:30: note: in expansion of macro 'In'
23 | #define InD2(a, b) int a, b; In("%d%d", &a, &b);
| ^~
a.cc:52:9: note: in expansion of macro 'InD2'
52 | InD2(n, m);
| ^~~~
|
s087776838 | p03707 | C++ | /******************************************
* AUTHOR: CHIRAG AGARWAL *
* INSTITUITION: BITS PILANI, PILANI *
******************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
const int MAX=2003;
int arr[MAX][MAX];
int cnt[MAX][MAX][15];
int pre[MAX][MAX][15];
string s[MAX];
int eval(int x1,int y1,int x2,int y2,int k)
{
return pre[x2][y2][k]+pre[x1-1][y1-1][k]-pre[x1-1][y2][k]-pre[x2][y1-1][k];
}
int main()
{
int n,m,q;
scanf("%d %d %d",&n,&m,&q);
for(int i=1;i<=n;i++)
{
cin>>s[i];
for(int j=0;j<m;j++)
{
if(s[i][j]=='0')
{
arr[i][j+1]=0;
}
else
{
arr[i][j+1]=1;
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(arr[i][j]==1)
{
int x=0;
if(arr[i-1][j]==1)
{
x|=1;
}
if(arr[i][j-1]==1)
{
x|=2;
}
if(arr[i+1][j]==1)
{
x|=4;
}
if(arr[i][j+1]==1)
{
x|=8;
}
cnt[i][j][x]++;
// printf("%d %d %d\n",i,j,x);
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
for(int k=0;k<16;k++)
{
cnt[i][j][k]+=cnt[i][j-1][k];
}
}
}
/*for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
printf("%d ",cnt[i][j][0]);
}
printf("\n");
}*/
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
for(int k=0;k<16;k++)
{
pre[i][j][k]=pre[i-1][j][k]+cnt[i][j][k];
}
}
}
for(int i=1;i<=q;i++)
{
int x1,y1,x2,y2;
int ans=0;
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
ans+=eval(x1,y1,x2,y2,0);
ans+=eval(x1,y1,x2,y1,2);
ans+=eval(x1,y2,x2,y2,8);
ans+=eval(x1,y1,x1,y2,1);
ans+=eval(x2,y1,x2,y2,4);
ans+=eval(x1,y1,x1,y1,3);
ans+=eval(x1,y2,x1,y2,9);
ans+=eval(x2,y1,x2,y1,6);
ans+=eval(x2,y2,x2,y2,12);
int p=0;
p+=eval(x1,y2,x1,y2,1);
p+=eval(x1,y2,x1,y2,5);
p+=eval(x1,y2,x1,y2,7);
p+=eval(x1,y2,x1,y2,10);
p+=eval(x1,y2,x1,y2,11);
p+=eval(x1,y2,x1,y2,13);
p+=eval(x1,y2,x1,y2,14)
p+=eval(x1,y2,x1,y2,15);
if(p)
{
ans++;
}
printf("%d\n",ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:121:40: error: expected ';' before 'p'
121 | p+=eval(x1,y2,x1,y2,14)
| ^
| ;
122 | p+=eval(x1,y2,x1,y2,15);
| ~
|
s749908908 | p03707 | C++ | 3 4 4
1101
0110
1101
1 1 3 4
1 1 3 1
2 2 3 4
1 2 2 4 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3 4 4
| ^
|
s211671958 | p03707 | C++ | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif
using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
#define FST first
#define SND second
#define MAX_N (2000) // 10^3
#define MAX_Q (200000) // 10^5
// #define MAX_N (1000000000) // 10^9
// #define MAX_N (1000000000000000000) // 10^18
#define BASE (1000000000 + 7) // 10^9 + 7
#define INFI (1000000000 + 7) // 10^9 + 7
#define INFL (1000000000000000000 + 7) // 10^18 + 7
int N, M, Q;
string S[MAX_N];
int MP[MAX_N][MAX_N];
int DR[4] = {1, 0, -1, 0};
int DC[4] = {0, 1, 0, -1};
int ID = 0;
bool is_inside(int r, int c, int r1, int c1, int r2, int c2) {
return r1 <= r && r <= r2 && c1 <= c && c <= c2;
}
int mapping(int r1, int c1, int r2, int c2) {
int id0 = ID;
for (int i = r1; i <= r2; i++) {
for (int j = c1; j <= c2; j++) {
if (S[i][j] == '0' || MP[i][j] > 0) continue;
queue<Pi> q;
q.push(Pi(i, j));
MP[i][j] = id;
while (!q.empty()) {
Pi p = q.front(); q.pop();
int r = p.FST, c = p.SND;
for (int d = 0; d < 4; d++) {
int nr = r + DR[d], nc = c + DC[d];
if (is_inside(nr, nc, r1, c1, r2, c2) && S[nr][nc] == '1' && MP[nr][nc] < ID) {
q.push(Pi(nr, nc));
MP[nr][nc] = ID;
}
}
}
ID++;
}
}
return ID - id0;
}
ll solve(int r1, int c1, int r2, int c2) {
return mapping(r1, c1, r2, c2);
}
int main() {
cin >> N >> M >> Q;
for (int i = 0; i < N; i++) cin >> S[i];
for (int i = 0; i < N; i++)
for (int j = 0; j < M; j++) MP[i][j] = -1;
// for (int i = 0; i < N; i++) {
// for (int j = 0; j < M; j++) cout << MP[i][j];
// cout << endl;
// }
for (int i = 0; i < Q; i++) {
int r1, c1, r2, c2;
cin >> r1 >> c1 >> r2 >> c2;
cout << solve(r1 - 1, c1 - 1, r2 - 1, c2 - 1) << endl;
}
return 0;
}
| a.cc: In function 'int mapping(int, int, int, int)':
a.cc:67:18: error: 'id' was not declared in this scope; did you mean 'i'?
67 | MP[i][j] = id;
| ^~
| i
|
s644562399 | p03707 | C++ | #include<cstdio>
#include<cstring>
#define N 2005
using namespace std;
char s[233];
int n,m,q;
int c[N][N];
int hl[N][N],zl[N][N];
int pre[N][N],pred[N][N];
int xx[4]={-1,0,1,0},yy[4]={0,-1,0,1};
void prework(){
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
pre[i][j]=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+c[i][j];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(c[i][j]==0) continue;
for(int k=0;k<4;k++){
int nr=i+xx[k],nc=j+yy[k];
if(1<=nr&&nr<=n&&1<=nc&&nc<=m&&c[nr][nc]==1){
pred[i][j]++;
if(k==2) hl[i][j]++;
else if(k==3) zl[i][j]++;
}
}
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
pred[i][j]+=pred[i-1][j]+pred[i][j-1]-pred[i-1][j-1],
hl[i][j]+=hl[i][j-1],zl[i][j]+=zl[i-1][j];
}
int query(int cl,int cr,int rt,int rb){
int totc=0,totd=0;
totc=pre[rb][cr]-pre[rb][cl-1]-pre[rt-1][cr]+pre[rt-1][cl-1];
totd=pred[rb][cr]-pred[rb][cl-1]-pred[rt-1][cr]+pred[rt-1][cl-1];
totd-=hl[rt-1][cr]-hl[rt-1][cl-1];
totd-=hl[rb][cr]-hl[rb][cl-1];
totd-=zl[rb][cl-1]-zl[rt-1][cl-1];
totd-=zl[rb][cr]-zl[rt-1][cr];
return totc-totd/2;
}
int main(){
scanf("%d%d%d",&n,&m,&q);
gets(s);
for(int i=1;i<=n;i++,gets(s))
for(int j=1;j<=m;j++)
c[i][j]=getchar()-'0';
prework();
for(int i=1;i<=q;i++){
int cl,cr,rt,rb;
scanf("%d%d%d%d",&rt,&cl,&rb,&cr);
printf("%d\n",query(cl,cr,rt,rb));
}
return 0;
} | a.cc: In function 'int main()':
a.cc:45:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
45 | gets(s);
| ^~~~
| getw
|
s305155128 | p03707 | C++ | #include<bits/stdc++.h>
#define N 2005
using namespace std;
char s[233];
int n,m,q;
int c[N][N];
int hl[N][N],zl[N][N];
int pre[N][N],pred[N][N];
int xx[4]={-1,0,1,0},yy[4]={0,-1,0,1};
void prework(){
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
pre[i][j]=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+c[i][j];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(c[i][j]==0) continue;
for(int k=0;k<4;k++){
int nr=i+xx[k],nc=j+yy[k];
if(1<=nr&&nr<=n&&1<=nc&&nc<=m&&c[nr][nc]==1){
pred[i][j]++;
if(k==2) hl[i][j]++;
else if(k==3) zl[i][j]++;
}
}
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
pred[i][j]+=pred[i-1][j]+pred[i][j-1]-pred[i-1][j-1],
hl[i][j]+=hl[i][j-1],zl[i][j]+=zl[i-1][j];
}
int query(int cl,int cr,int rt,int rb){
int totc=0,totd=0;
totc=pre[rb][cr]-pre[rb][cl-1]-pre[rt-1][cr]+pre[rt-1][cl-1];
totd=pred[rb][cr]-pred[rb][cl-1]-pred[rt-1][cr]+pred[rt-1][cl-1];
totd-=hl[rt-1][cr]-hl[rt-1][cl-1];
totd-=hl[rb][cr]-hl[rb][cl-1];
totd-=zl[rb][cl-1]-zl[rt-1][cl-1];
totd-=zl[rb][cr]-zl[rt-1][cr];
return totc-totd/2;
}
int main(){
scanf("%d%d%d",&n,&m,&q);
gets(s);
for(int i=1;i<=n;i++,gets(s))
for(int j=1;j<=m;j++)
c[i][j]=getchar()-'0';
prework();
for(int i=1;i<=q;i++){
int cl,cr,rt,rb;
scanf("%d%d%d%d",&rt,&cl,&rb,&cr);
printf("%d\n",query(cl,cr,rt,rb));
}
return 0;
} | a.cc: In function 'int main()':
a.cc:44:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
44 | gets(s);
| ^~~~
| getw
|
s633329839 | p03708 | C++ | //Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>
using namespace std;
const long long B = 61;
long long a, b;
long long p;
long long ans;
int main()
{
cin >> a >> b;
if (a == b)
{
cout << 1 << endl;
exit(0);
}
for (long long i = B - 1; i >= 0; i--)
{
if ((b & (1ll << i)) && !(a & (1ll << i)))
{
p = i;
for (long long k = p - 1; k >= 0; k--)
{
if (b & (1ll << k))
{
b |= ((1ll << (k + 1)) - 1);
break;
}
}
break;
}
}
long long l = a + (1ll << p);
long long r = a | ((1ll << (p + 1)) - 1);
ans += max(0, b - a + 1);
ans += max(0, r - l + 1);
ans -= max(0, b - l + 1);
cout << ans << '\n';
}
| a.cc: In function 'int main()':
a.cc:59:15: error: no matching function for call to 'max(int, long long int)'
59 | ans += max(0, b - a + 1);
| ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:59:15: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
59 | ans += max(0, b - a + 1);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:59:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
59 | ans += max(0, b - a + 1);
| ~~~^~~~~~~~~~~~~~
a.cc:60:15: error: no matching function for call to 'max(int, long long int)'
60 | ans += max(0, r - l + 1);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:60:15: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
60 | ans += max(0, r - l + 1);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:60:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
60 | ans += max(0, r - l + 1);
| ~~~^~~~~~~~~~~~~~
a.cc:61:15: error: no matching function for call to 'max(int, long long int)'
61 | ans -= max(0, b - l + 1);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:61:15: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
61 | ans -= max(0, b - l + 1);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:61:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
61 | ans -= max(0, b - l + 1);
| ~~~^~~~~~~~~~~~~~
|
s257772969 | p03708 | C++ | //Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>
using namespace std;
const int B = 61;
int a, b;
int p;
int ans;
int main()
{
cin >> a >> b;
if (a == b)
{
cout << 1 << endl;
return;
}
for (int i = B - 1; i >= 0; i--)
{
if ((b & (1ll << i)) && !(a & (1ll << i)))
{
p = i;
for (int k = p - 1; k >= 0; k--)
{
if (b & (1ll << k))
{
b |= ((1ll << (k + 1)) - 1);
break;
}
}
break;
}
}
int l = a + (1ll << p);
int r = a | ((1ll << (p + 1)) - 1);
ans += max(0ll, b - a + 1);
ans += max(0ll, r - l + 1);
ans -= max(0ll, b - l + 1);
cout << ans << '\n';
}
| a.cc: In function 'int main()':
a.cc:39:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
39 | return;
| ^~~~~~
a.cc:59:15: error: no matching function for call to 'max(long long int, int)'
59 | ans += max(0ll, b - a + 1);
| ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:59:15: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
59 | ans += max(0ll, b - a + 1);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:59:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
59 | ans += max(0ll, b - a + 1);
| ~~~^~~~~~~~~~~~~~~~
a.cc:60:15: error: no matching function for call to 'max(long long int, int)'
60 | ans += max(0ll, r - l + 1);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:60:15: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
60 | ans += max(0ll, r - l + 1);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:60:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
60 | ans += max(0ll, r - l + 1);
| ~~~^~~~~~~~~~~~~~~~
a.cc:61:15: error: no matching function for call to 'max(long long int, int)'
61 | ans -= max(0ll, b - l + 1);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:61:15: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
61 | ans -= max(0ll, b - l + 1);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:61:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
61 | ans -= max(0ll, b - l + 1);
| ~~~^~~~~~~~~~~~~~~~
|
s404461870 | p03708 | C | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define il inline
il int read()
{
int re=0,k=1;char ch=getchar();
while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();}
while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
return re*k;
}
il void write(int x)
{
if(x<0)return putchar('-'),write(-x),void();
if(x<=9)return putchar(x+48),void();
return write(x/10),write(x%10),void();
}
int t,n,l,r,ans;
const int M=1e9+7;
signed main()
{
// freopen("c.in","r",stdin);
// freopen("c.out","w",stdout);
t=1;
while(t--)
{
n=2;l=read();r=read();
if(l==r)
{
puts("1");continue;
}
if(n==1ll)
{
write((r-l+1ll)%M);puts("");continue;
}
int rr,ll,rrr;
int lim=62ll;
while(lim>=0ll)
{
if(((l>>lim)&1ll)!=((r>>lim)&1ll))
{
ll=l&((1ll<<(lim+1ll))-1ll);
rr=(1ll<<(lim))+ll;
int tt=lim-1ll;
while(tt>=0ll&&!((r>>tt)&1ll))tt--;
rrr=(1ll<<lim)+(1ll<<(tt+1ll))-1ll;
break;
}
lim--;
}
// cerr<<lim<<" "<<(l>>3ll)<<" "<<(r>>3ll)<<endl;
//cerr<<ll<<" "<<rrr<<" "<<rr<<" "<<(1ll<<(lim+1ll))<<endl;
if(rrr>=rr)
{
ans=(1ll<<(lim+1ll))-ll;
}
else
{
ans=(1ll<<(lim+1ll))-rr+rrr-ll+1ll;
}
write(ans%M);
puts("");
}
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s700862186 | p03708 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pi;
ll A, B;
ll solve(ll L, ll R){
if(L == R){
return 1;
}
for(int i = 60;i >= 0;i--){
ll C = (1LL << i);
if(R & C){
if(L & C){
L ^= C;
R ^= C;
continue;
}else{
ll tmp = C - L;
ll v1 = R - C;
int bit = 64 - __builtin_clzll(v1);
ll val = (1LL << bit) - 1;
tmp += min(C, val + 1 + C - L);
return tmp;
}
}
}
return 0;
}
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> A >> B;
int bit = 0;
for(bit = 60;bit >= 0;bit--){
ll C = (1LL << bit);
if((A & C) != (B & C)){
break;
}
}
A &= (1LL << bit + 1) - 1;
B &= (1LL << bit + 1) - 1;
ll c = bit - 1;
while(c >= 0 and !(B >> c & 1))
c--;
c = 1LL << c + 1;
ll mid = 1LL << bit;
cout << mid - A + c + mid * 2 - max(mid + c, a | mid) << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:56:50: error: 'a' was not declared in this scope
56 | cout << mid - A + c + mid * 2 - max(mid + c, a | mid) << endl;
| ^
|
s656408804 | p03708 | C++ | #include<bits/stdc++.h>
using namespace std;
inline int read(){
register int x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
inline void write(int x){
if(x<0)x=-x,putchar('-');
if(x>9)write(x/10);
putchar(x%10+'0');
}
#define rg register
const int maxn=110;
long long a,b,x,y,l,r,ans,ll,rr;
int aa[maxn],bb[maxn],lena,lenb,len,k;
int main(){
read(a),read(b);x=a,y=b;
while(a)aa[++lena]=a&1,a>>=1;
while(b)bb[++lenb]=b&1,b>>=1;
for(rg int i=max(lena,lenb);i;i--){
if(aa[i]!=bb[i]){
len=i;break;
}
x-=1ll*aa[i]<<(i-1);
y-=1ll*bb[i]<<(i-1);
}
for(rg int i=len-1;i;i--)
if(bb[i]){
k=i;break;
}
l=x;r=(1ll<<(len-1))+(1ll<<k)-1;
ll=(1ll<<(len-1))+x;rr=(1ll<<len)-1;
if(ll>r)ans=r-l+1+rr-ll+1;
else ans=rr-l+1;
printf("%lld\n",ans);
} | a.cc: In function 'int read()':
a.cc:4:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
4 | register int x=0,f=1;register char ch=getchar();
| ^
a.cc:4:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
4 | register int x=0,f=1;register char ch=getchar();
| ^
a.cc:4:44: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
4 | register int x=0,f=1;register char ch=getchar();
| ^~
a.cc: In function 'int main()':
a.cc:19:9: error: no matching function for call to 'read(long long int&)'
19 | read(a),read(b);x=a,y=b;
| ~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /usr/include/c++/14/csignal:42,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
from a.cc:1:
/usr/include/unistd.h:371:16: note: candidate: 'ssize_t read(int, void*, size_t)'
371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
| ^~~~
/usr/include/unistd.h:371:16: note: candidate expects 3 arguments, 1 provided
a.cc:3:12: note: candidate: 'int read()'
3 | inline int read(){
| ^~~~
a.cc:3:12: note: candidate expects 0 arguments, 1 provided
a.cc:19:17: error: no matching function for call to 'read(long long int&)'
19 | read(a),read(b);x=a,y=b;
| ~~~~^~~
/usr/include/unistd.h:371:16: note: candidate: 'ssize_t read(int, void*, size_t)'
371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
| ^~~~
/usr/include/unistd.h:371:16: note: candidate expects 3 arguments, 1 provided
a.cc:3:12: note: candidate: 'int read()'
3 | inline int read(){
| ^~~~
a.cc:3:12: note: candidate expects 0 arguments, 1 provided
a.cc:22:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
22 | for(rg int i=max(lena,lenb);i;i--){
| ^
a.cc:29:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
29 | for(rg int i=len-1;i;i--)
| ^
|
s356522152 | p03708 | C++ | #include <iostream>
using namespace std;
long long a, b;
int main() {
scanf("%ll%ll", &a, &b);
printf(a+1);
return 0;
} | a.cc: In function 'int main()':
a.cc:8:17: error: invalid conversion from 'long long int' to 'const char*' [-fpermissive]
8 | printf(a+1);
| ~^~
| |
| long long int
In file included from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdio.h:363:43: note: initializing argument 1 of 'int printf(const char*, ...)'
363 | extern int printf (const char *__restrict __format, ...);
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
|
s145355690 | p03708 | C++ | #include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
#define int long long
#define inf 1000000007
#define pa pair<int,int>
#define ll long long
#define pal pair<double,double>
#define ppap pair<pa,int>
#define PI 3.14159265358979323846
#define paa pair<int,char>
#define mp make_pair
#define pb push_back
#define EPS (1e-8)
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,-1,1,1,-1};
using namespace std;
class pa3{
public:
int x;
int y,z;
pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
bool operator < (const pa3 &p) const{
if(x!=p.x) return x<p.x;
if(y!=p.y) return y<p.y;
return z<p.z;
//return x != p.x ? x<p.x: y<p.y;
}
bool operator > (const pa3 &p) const{
if(x!=p.x) return x>p.x;
if(y!=p.y) return y>p.y;
return z>p.z;
//return x != p.x ? x<p.x: y<p.y;
}
bool operator == (const pa3 &p) const{
return x==p.x && y==p.y && z==p.z;
}
bool operator != (const pa3 &p) const{
return !( x==p.x && y==p.y && z==p.z);
}
};
class pa4{
public:
int x;
int y,z,w;
pa4(int x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {}
bool operator < (const pa4 &p) const{
if(x!=p.x) return x<p.x;
if(y!=p.y) return y<p.y;
if(z!=p.z)return z<p.z;
return w<p.w;
//return x != p.x ? x<p.x: y<p.y;
}
bool operator > (const pa4 &p) const{
if(x!=p.x) return x>p.x;
if(y!=p.y) return y>p.y;
if(z!=p.z)return z>p.z;
return w>p.w;
//return x != p.x ? x<p.x: y<p.y;
}
bool operator == (const pa4 &p) const{
return x==p.x && y==p.y && z==p.z &&w==p.w;
}
};
class pa2{
public:
int x,y;
pa2(int x=0,int y=0):x(x),y(y) {}
pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);}
pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);}
bool operator < (const pa2 &p) const{
return y != p.y ? y<p.y: x<p.x;
}
bool operator > (const pa2 &p) const{
return x != p.x ? x<p.x: y<p.y;
}
bool operator == (const pa2 &p) const{
return abs(x-p.x)==0 && abs(y-p.y)==0;
}
bool operator != (const pa2 &p) const{
return !(abs(x-p.x)==0 && abs(y-p.y)==0);
}
};
string itos( int i ) {
ostringstream s ;
s << i ;
return s.str() ;
}
int gcd(int v,int b){
if(v>b) return gcd(b,v);
if(v==b) return b;
if(b%v==0) return v;
return gcd(v,b%v);
}
int mod;
int extgcd(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int d = extgcd(b, a%b, y, x);
y -= a/b * x;
return d;
}
pa operator+(const pa & l,const pa & r) {
return {l.first+r.first,l.second+r.second};
}
pa operator-(const pa & l,const pa & r) {
return {l.first-r.first,l.second-r.second};
}
int pr[1000010];
int inv[1000010];
int beki(int wa,int rr,int warukazu){
if(rr==0) return 1%warukazu;
if(rr==1) return wa%warukazu;
wa%=warukazu;
if(rr%2==1) return ((ll)beki(wa,rr-1,warukazu)*(ll)wa)%warukazu;
ll zx=beki(wa,rr/2,warukazu);
return (zx*zx)%warukazu;
}
int comb(int nn,int rr){
if(rr<0 || rr>nn || nn<0) return 0;
int r=pr[nn]*inv[rr];
r%=mod;
r*=inv[nn-rr];
r%=mod;
return r;
}
void gya(int ert){
pr[0]=1;
for(int i=1;i<=ert;i++){
pr[i]=(pr[i-1]*i)%mod;
}
inv[ert]=beki(pr[ert],mod-2,mod);
for(int i=ert-1;i>=0;i--){
inv[i]=inv[i+1]*(i+1)%mod;
}
}
// cin.tie(0);
// ios::sync_with_stdio(false);
//priority_queue<pa3,vector<pa3>,greater<pa3>> pq;
//sort(ve.begin(),ve.end(),greater<int>());
// mt19937(clock_per_sec);
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ;
//----------------kokomade tenpure------------
int l[3][2];
int e(pa z){
return max(0ll,z.second-z.first);
}
pa intr(pa z1,pa z2){
pa z;
z.first = max(z1.first,z2.first);
z.second = min(z1.second,z2.second);
return z;
}
int solve(){
pa z1=mp(l[0][0],l[2][1]+1);
pa z2=mp(l[1][0],l[1][1]+1);
return ans=e(z1)+e(z2)-e(intr(z1,z2));
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
cin>>a>>b;
if(a==b){
cout<<1<<endl;
return 0;
}
int it;
for(int i=61;i>=0;i--){
if((a&(1ll<<i))==0 && (b&(1ll<<i))>0){
it=i;
break;
}
}
a&=(1ll<<(it+1))-1;
b&=(1ll<<(it+1))-1;
//cout<<a<<" "<<b<<endl;
l[0][0]=a;
l[0][1]=(1ll<<it)-1;
l[1][0]=a+(1ll<<it);
l[1][1]=(1ll<<(it+1))-1;
l[2][0]=(1ll<<it);
bool bo=false;
int p=b;
for(int i=it-1;i>=0;i--){
if(bo)p |= (1ll<<i);
else{
if(p&(1ll<<i))bo=1;
}
}
l[2][1]=p;
// for(int i=0;i<3;i++){
// cout<<l[i][0]<<" "<<l[i][1]<<endl;
// }
cout<<solve()<<endl;
return 0;
}
| a.cc: In function 'long long int solve()':
a.cc:188:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
188 | return ans=e(z1)+e(z2)-e(intr(z1,z2));
| ^~~
| abs
|
s002973429 | p03708 | C++ | #include <stdio.h>
#include <math.h>
#include <algorithm>
long long a, b;
int main()
{
scanf("%lld%lld", &a, &b);
if (a == b)return !puts("1");
int _ = 60;
while (~(-- _))
if ((a & (1ll << _)) ^ (b & (1ll << _)))
{
a &= (1ll << (_ + 1)) - 1, b &= (1ll << (_ + 1)) - 1;
long long __ = 1ll << (int)(log2(b & ((1 << _) - 1)));
__ = !__? 1ll: __ << 1);
return !printf("%lld\n", (1ll << (_ + 1)) - a + std :: min(0ll, __ - a));
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:35: error: expected ';' before ')' token
15 | __ = !__? 1ll: __ << 1);
| ^
| ;
|
s891147601 | p03708 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
public class Solution implements Runnable
{
static final long MAX = 464897L;
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public InputReader(InputStream stream)
{
this.stream = stream;
}
public int read()
{
if (numChars==-1)
throw new InputMismatchException();
if (curChar >= numChars)
{
curChar = 0;
try
{
numChars = stream.read(buf);
}
catch (IOException e)
{
throw new InputMismatchException();
}
if(numChars <= 0)
return -1;
}
return buf[curChar++];
}
public String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
public int nextInt()
{
int c = read();
while(isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-')
{
sgn = -1;
c = read();
}
int res = 0;
do
{
if(c<'0'||c>'9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
while (!isSpaceChar(c));
return res * sgn;
}
public long nextLong()
{
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-')
{
sgn = -1;
c = read();
}
long res = 0;
do
{
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
while (!isSpaceChar(c));
return res * sgn;
}
public double nextDouble()
{
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-')
{
sgn = -1;
c = read();
}
double res = 0;
while (!isSpaceChar(c) && c != '.')
{
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
if (c == '.')
{
c = read();
double m = 1;
while (!isSpaceChar(c))
{
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
m /= 10;
res += (c - '0') * m;
c = read();
}
}
return res * sgn;
}
public String readString()
{
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do
{
res.appendCodePoint(c);
c = read();
}
while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c)
{
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public String next()
{
return readString();
}
public interface SpaceCharFilter
{
public boolean isSpaceChar(int ch);
}
}
public static void Main(String args[]) throws Exception
{
new Thread(null, new Solution(),"Solution",1<<26).start();
}
static long gcd(long a, long b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
static long lcm(long a,long b) {
return (a/gcd(a,b) * b);
}
long MOD = 1000000007;
ArrayList<Integer> adj[];
long[] arr;
long[] cost;
public void run()
{
InputReader sc = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
long a = sc.nextLong();
long b = sc.nextLong();
int ind = -1;
for(int i = 61;i >= 0;i--) {
if(((a >> i) & 1) != ((b >> i) & 1)) {
ind = i;
break;
}
}
if(ind == -1) {
w.println("1");
}else {
long r = power(2,ind,1000000000000000000L);
long temp = r * 2 - 1;
a = a & temp;
b = b & temp;
int rem = -1;
for(int i = 0;i < ind;i++) {
if(((b >> i) & 1) == 1) {
rem = i;
}
}
int rem2 = -1;
for(int i = 0;i < ind;i++) {
if(((a >> i) & 1) == 1) {
rem2 = i;
}
}
if(rem2 <= rem) {
w.println(2*r-a);
}else {
temp = power(2,rem+1,1000000000000000000L) - 1;
w.println(temp + 2*(r-a) + 1);
}
}
w.close();
}
ArrayList<ArrayList<Integer>> common;
ArrayList<Integer> ar;
boolean[] visited;
Stack<Integer> st;
void dfs(int a){
visited[a] = true;
Iterator<Integer> it= adj[a].iterator();
while(it.hasNext()){
int n = it.next();
if(!visited[n]){
dfs(n);
}
}
st.add(a);
}
static long power(long a,long b,long mod) {
long ans = 1;
a = a % mod;
while(b != 0) {
if(b % 2 == 1) {
ans = (ans * a) % mod;
}
a = (a * a) % mod;
b = b/2;
}
return ans;
}
class Pair implements Comparable<Pair>{
int a;
int b;
int c;
int d;
//int c;
Pair(int a,int b,int c,int d){
this.b = b;
this.a = a;
this.c = c;
this.d = d;
}
public boolean equals(Object o) {
Pair p = (Pair)o;
return this.a == p.a && this.b == this.b;
}
public int hashCode(){
return Long.hashCode(a)*27 + Long.hashCode(b)*31;
}
public int compareTo(Pair p) {
return Long.compare(this.c,p.c);
}
}
}
| Main.java:20: error: class Solution is public, should be declared in a file named Solution.java
public class Solution implements Runnable
^
1 error
|
s277496757 | p03708 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
public class Solution implements Runnable
{
static final long MAX = 464897L;
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public InputReader(InputStream stream)
{
this.stream = stream;
}
public int read()
{
if (numChars==-1)
throw new InputMismatchException();
if (curChar >= numChars)
{
curChar = 0;
try
{
numChars = stream.read(buf);
}
catch (IOException e)
{
throw new InputMismatchException();
}
if(numChars <= 0)
return -1;
}
return buf[curChar++];
}
public String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
public int nextInt()
{
int c = read();
while(isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-')
{
sgn = -1;
c = read();
}
int res = 0;
do
{
if(c<'0'||c>'9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
while (!isSpaceChar(c));
return res * sgn;
}
public long nextLong()
{
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-')
{
sgn = -1;
c = read();
}
long res = 0;
do
{
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
while (!isSpaceChar(c));
return res * sgn;
}
public double nextDouble()
{
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-')
{
sgn = -1;
c = read();
}
double res = 0;
while (!isSpaceChar(c) && c != '.')
{
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
if (c == '.')
{
c = read();
double m = 1;
while (!isSpaceChar(c))
{
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
m /= 10;
res += (c - '0') * m;
c = read();
}
}
return res * sgn;
}
public String readString()
{
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do
{
res.appendCodePoint(c);
c = read();
}
while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c)
{
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public String next()
{
return readString();
}
public interface SpaceCharFilter
{
public boolean isSpaceChar(int ch);
}
}
public static void main(String args[]) throws Exception
{
new Thread(null, new Solution(),"Solution",1<<26).start();
}
static long gcd(long a, long b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
static long lcm(long a,long b) {
return (a/gcd(a,b) * b);
}
long MOD = 1000000007;
ArrayList<Integer> adj[];
long[] arr;
long[] cost;
public void run()
{
InputReader sc = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
long a = sc.nextLong();
long b = sc.nextLong();
int ind = -1;
for(int i = 61;i >= 0;i--) {
if(((a >> i) & 1) != ((b >> i) & 1)) {
ind = i;
break;
}
}
if(ind == -1) {
w.println("1");
}else {
long r = power(2,ind,1000000000000000000L);
long temp = r * 2 - 1;
a = a & temp;
b = b & temp;
int rem = -1;
for(int i = 0;i < ind;i++) {
if(((b >> i) & 1) == 1) {
rem = i;
}
}
int rem2 = -1;
for(int i = 0;i < ind;i++) {
if(((a >> i) & 1) == 1) {
rem2 = i;
}
}
if(rem2 <= rem) {
w.println(2*r-a);
}else {
temp = power(2,rem+1,1000000000000000000L) - 1;
w.println(temp + 2*(r-a) + 1);
}
}
w.close();
}
ArrayList<ArrayList<Integer>> common;
ArrayList<Integer> ar;
boolean[] visited;
Stack<Integer> st;
void dfs(int a){
visited[a] = true;
Iterator<Integer> it= adj[a].iterator();
while(it.hasNext()){
int n = it.next();
if(!visited[n]){
dfs(n);
}
}
st.add(a);
}
static long power(long a,long b,long mod) {
long ans = 1;
a = a % mod;
while(b != 0) {
if(b % 2 == 1) {
ans = (ans * a) % mod;
}
a = (a * a) % mod;
b = b/2;
}
return ans;
}
class Pair implements Comparable<Pair>{
int a;
int b;
int c;
int d;
//int c;
Pair(int a,int b,int c,int d){
this.b = b;
this.a = a;
this.c = c;
this.d = d;
}
public boolean equals(Object o) {
Pair p = (Pair)o;
return this.a == p.a && this.b == this.b;
}
public int hashCode(){
return Long.hashCode(a)*27 + Long.hashCode(b)*31;
}
public int compareTo(Pair p) {
return Long.compare(this.c,p.c);
}
}
}
| Main.java:20: error: class Solution is public, should be declared in a file named Solution.java
public class Solution implements Runnable
^
1 error
|
s994436626 | p03708 | C++ |
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-all-loops")
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int LL;
namespace io
{
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
template <class I>
inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
template <class I>
inline void print (I x){
if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0', x /= 10;while (qr) putc (qu[qr--]);}
struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;
int N;
LL L, R, Ans;
struct node
{
LL l, r;
void give(LL _l, LL _r)
{
l = _l, r = _r;
}
};
int tot;
node v[3];
void dfs(int p, int cnt, LL l, LL r)
{
if (p == tot)
{
if (cnt)
if (cnt & 1)
{
if (l <= r)
Ans += r - l + 1LL;
}
else
{
if (l <= r)
Ans -= r - l + 1LL;
}
return ;
}
dfs(p + 1, cnt, l, r);
dfs(p + 1, cnt + 1, max(l, v[p].l), min(r, v[p].r));
}
int main()
{
gi(L), gi(R);
if (N == 1 || L == R)
Ans = R - L + 1LL;
else
{
for (k = 59LL;k >= 0LL;--k)
if ((L & (1LL << k)) ^ (R & (1LL << k)))
break;
else
{
if (L & (1LL << k))
L -= (1LL << k);
if (R & (1LL << k))
R -= (1LL << k);
}
tot = 0;
v[tot++].give(L, R);
for (LL p = 59LL;p >= 0LL;--p)
if ((1LL << k) + (1LL << p) <= R)
{
v[tot++].give(1LL << k, (1LL << k) + (1LL << (p + 1LL)) - 1LL);
break;
}
v[tot++].give(L + (1LL << k), (1LL << (k + 1LL)) - 1LL);
Ans = 0LL, dfs(0, 0, 0LL, 1LL << 60LL);
}
print(Ans), putc('\n');
return 0;
}
/*
考虑把L和R的二进制位从高到低写下来,去掉最长公共前缀,特判掉L = R的情况,那么L的最高位 = 0、R的最高位 = 1,设最高位是k,有L < 2^k <= R
分如下几段考虑:
(1)[L, R]一定在答案中
(2)找到最大p使得2^k + 2^p <= R,容易发现对于所有0 <= i <= p都有L < 2^k + 2^i <= R,故[2^k, 2^k + 2^(p + 1))在答案中
(3)考虑[L, 2^k)中的数,显然让它们or上> 2^k的数是没有任何意义的。故[L + 2^k, 2^(k + 1))在答案中
把这三段求并即可
*/ | a.cc: In function 'int main()':
a.cc:73:22: error: 'k' was not declared in this scope
73 | for (k = 59LL;k >= 0LL;--k)
| ^
a.cc:86:37: error: 'k' was not declared in this scope
86 | if ((1LL << k) + (1LL << p) <= R)
| ^
a.cc:91:43: error: 'k' was not declared in this scope
91 | v[tot++].give(L + (1LL << k), (1LL << (k + 1LL)) - 1LL);
| ^
|
s019461899 | p03708 | C++ |
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-all-loops")
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int LL;
namespace io
{
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
template <class I>
inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
template <class I>
inline void print (I x){
if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0', x /= 10;while (qr) putc (qu[qr--]);}
struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;
int N;
LL L, R, Ans;
struct node
{
LL l, r;
void give(LL _l, LL _r)
{
l = _l, r = _r;
}
};
int tot;
node v[3];
void dfs(int p, int cnt, LL l, LL r)
{
if (p == tot)
{
if (cnt)
if (cnt & 1)
{
if (l <= r)
Ans += r - l + 1LL;
}
else
{
if (l <= r)
Ans -= r - l + 1LL;
}
return ;
}
dfs(p + 1, cnt, l, r);
dfs(p + 1, cnt + 1, max(l, v[p].l), min(r, v[p].r));
}
int main()
{
gi(L), gi(R);
if (N == 1 || L == R)
Ans = (R - L + 1LL) % MOD;
else
{
for (k = 59LL;k >= 0LL;--k)
if ((L & (1LL << k)) ^ (R & (1LL << k)))
break;
else
{
if (L & (1LL << k))
L -= (1LL << k);
if (R & (1LL << k))
R -= (1LL << k);
}
tot = 0;
v[tot++].give(L, R);
for (LL p = 59LL;p >= 0LL;--p)
if ((1LL << k) + (1LL << p) <= R)
{
v[tot++].give(1LL << k, (1LL << k) + (1LL << (p + 1LL)) - 1LL);
break;
}
v[tot++].give(L + (1LL << k), (1LL << (k + 1LL)) - 1LL);
Ans = 0LL, dfs(0, 0, 0LL, 1LL << 60LL);
}
print(Ans), putc('\n');
return 0;
}
/*
考虑把L和R的二进制位从高到低写下来,去掉最长公共前缀,特判掉L = R的情况,那么L的最高位 = 0、R的最高位 = 1,设最高位是k,有L < 2^k <= R
分如下几段考虑:
(1)[L, R]一定在答案中
(2)找到最大p使得2^k + 2^p <= R,容易发现对于所有0 <= i <= p都有L < 2^k + 2^i <= R,故[2^k, 2^k + 2^(p + 1))在答案中
(3)考虑[L, 2^k)中的数,显然让它们or上> 2^k的数是没有任何意义的。故[L + 2^k, 2^(k + 1))在答案中
把这三段求并即可
*/ | a.cc: In function 'int main()':
a.cc:70:39: error: 'MOD' was not declared in this scope
70 | Ans = (R - L + 1LL) % MOD;
| ^~~
a.cc:73:22: error: 'k' was not declared in this scope
73 | for (k = 59LL;k >= 0LL;--k)
| ^
a.cc:86:37: error: 'k' was not declared in this scope
86 | if ((1LL << k) + (1LL << p) <= R)
| ^
a.cc:91:43: error: 'k' was not declared in this scope
91 | v[tot++].give(L + (1LL << k), (1LL << (k + 1LL)) - 1LL);
| ^
|
s564158965 | p03708 | C++ |
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-all-loops")
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int LL;
namespace io
{
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
template <class I>
inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
template <class I>
inline void print (I x){
if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0', x /= 10;while (qr) putc (qu[qr--]);}
struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;
int N;
LL Ans;
struct node
{
LL l, r;
void give(LL _l, LL _r)
{
l = _l, r = _r;
}
};
int tot;
node v[3];
void dfs(int p, int cnt, LL l, LL r)
{
if (p == tot)
{
if (cnt)
if (cnt & 1)
{
if (l <= r)
Ans += r - l + 1LL;
}
else
{
if (l <= r)
Ans -= r - l + 1LL;
}
return ;
}
dfs(p + 1, cnt, l, r);
dfs(p + 1, cnt + 1, max(l, v[p].l), min(r, v[p].r));
}
int main()
{
gi(L), gi(R);
if (N == 1 || L == R)
Ans = (R - L + 1LL) % MOD;
else
{
for (k = 59LL;k >= 0LL;--k)
if ((L & (1LL << k)) ^ (R & (1LL << k)))
break;
else
{
if (L & (1LL << k))
L -= (1LL << k);
if (R & (1LL << k))
R -= (1LL << k);
}
tot = 0;
v[tot++].give(L, R);
for (LL p = 59LL;p >= 0LL;--p)
if ((1LL << k) + (1LL << p) <= R)
{
v[tot++].give(1LL << k, (1LL << k) + (1LL << (p + 1LL)) - 1LL);
break;
}
v[tot++].give(L + (1LL << k), (1LL << (k + 1LL)) - 1LL);
Ans = 0LL, dfs(0, 0, 0LL, 1LL << 60LL);
}
print(Ans), putc('\n');
return 0;
}
/*
考虑把L和R的二进制位从高到低写下来,去掉最长公共前缀,特判掉L = R的情况,那么L的最高位 = 0、R的最高位 = 1,设最高位是k,有L < 2^k <= R
分如下几段考虑:
(1)[L, R]一定在答案中
(2)找到最大p使得2^k + 2^p <= R,容易发现对于所有0 <= i <= p都有L < 2^k + 2^i <= R,故[2^k, 2^k + 2^(p + 1))在答案中
(3)考虑[L, 2^k)中的数,显然让它们or上> 2^k的数是没有任何意义的。故[L + 2^k, 2^(k + 1))在答案中
把这三段求并即可
*/ | a.cc: In function 'int main()':
a.cc:68:12: error: 'L' was not declared in this scope
68 | gi(L), gi(R);
| ^
a.cc:68:19: error: 'R' was not declared in this scope
68 | gi(L), gi(R);
| ^
a.cc:70:39: error: 'MOD' was not declared in this scope
70 | Ans = (R - L + 1LL) % MOD;
| ^~~
a.cc:73:22: error: 'k' was not declared in this scope
73 | for (k = 59LL;k >= 0LL;--k)
| ^
a.cc:86:37: error: 'k' was not declared in this scope
86 | if ((1LL << k) + (1LL << p) <= R)
| ^
a.cc:91:43: error: 'k' was not declared in this scope
91 | v[tot++].give(L + (1LL << k), (1LL << (k + 1LL)) - 1LL);
| ^
|
s541531898 | p03708 | C++ | /**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
typedef long long ll;
long long readInt() {
bool minus1 = false;
long long result = 0;
char ch;
ch = getchar();
while (true) {
if (ch == '-') break;
if (ch >= '0' && ch <= '9') break;
ch = getchar();
}
if (ch == '-') minus1 = true; else result = ch-'0';
while (true) {
ch = getchar();
if (ch < '0' || ch > '9') break;
result = result*10 + (ch - '0');
}
if (minus1)
return -result;
else
return result;
}
int G(int x, ll l) {
return (x >> l) & 1;
}
main() {
#ifdef IZI_KATKA
assert(freopen("input", "r", stdin));
assert(freopen("output", "w", stdout));
#endif
ll L = readInt(), R = readInt();
if (L == R) {
return cout << 1, 0;
}
ll z = 0;
for (int i = 60; i >= 0; i--) {
if (G(L, i) != G(R, i)) {
z = i;
break;
}
}
L %= (1ll << z+1);
R %= (1ll << z+1);
ll kek = R ^ (1ll << z);
ll y = 0;
for (int i = 0; i <= 60; i++) {
if ((1ll << i) - 1 >= kek) {
y = i;
break;
}
}
ll K = (1ll << y) - 1;
if (K < L) {
cout << 2ll * ((1ll << z) - L) + (1ll << y);
} else {
cout << (1ll <<z+1) - L;
}
return 0;
} | a.cc:35:13: error: '__int64' does not name a type; did you mean '__int64_t'?
35 | #define int __int64
| ^~~~~~~
a.cc:66:1: note: in expansion of macro 'int'
66 | int G(int x, ll l) {
| ^~~
a.cc:70:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
70 | main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:35:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
35 | #define int __int64
| ^~~~~~~
a.cc:80:10: note: in expansion of macro 'int'
80 | for (int i = 60; i >= 0; i--) {
| ^~~
a.cc:80:22: error: 'i' was not declared in this scope
80 | for (int i = 60; i >= 0; i--) {
| ^
a.cc:81:21: error: 'G' was not declared in this scope
81 | if (G(L, i) != G(R, i)) {
| ^
a.cc:35:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
35 | #define int __int64
| ^~~~~~~
a.cc:90:14: note: in expansion of macro 'int'
90 | for (int i = 0; i <= 60; i++) {
| ^~~
a.cc:90:25: error: 'i' was not declared in this scope
90 | for (int i = 0; i <= 60; i++) {
| ^
|
s709467219 | p03708 | C++ | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b;
int main() {
// freopen("in.txt","r",stdin);
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>a>>b;
while (true) {
if (a==0 && b==0) {
cout<<1<<endl;
return 0;
}
int a2 = __lg(a);
int b2 = __lg(b);
//cout<<a2<<" "<<b2<<endl;
if (a2!=b2) break;
a = a-(1ll<<a2);
b = b-(1ll<<b2);
}
//cout<<a<<" " <<b<<endl;
int b2 = __lg(b);
ll l1 = a, l2 = (1ll<<b2) - 1;
ll tmp = b - (1ll<<b2);
//cout<<tmp<<endl;
if (tmp) {
int tmp2 = __lg(tmp);
ll l3 = (1ll<<(tmp2+1)) - 1;
}
//cout<<l1<<" "<<l2<<" "<<l3<<endl;
if (l1 >= l3) cout<<(l2-l1+1) + (l2-l1+1) + l3 + 1<<endl;
else cout<<l2-l1+1+l2+1<<endl;
}
| a.cc: In function 'int main()':
a.cc:34:15: error: 'l3' was not declared in this scope; did you mean 'l2'?
34 | if (l1 >= l3) cout<<(l2-l1+1) + (l2-l1+1) + l3 + 1<<endl;
| ^~
| l2
|
s292955873 | p03708 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,ans=0,now=1,man=1;
while(now<=a){
now*=2;
}
if(now>b){
cout<<now/2-1<<endl;
}else{
ans+=now-a;
ans+=now*2-(now+a);
while(nn*2+now<=b){
nn*=2;
}
if(nn+now>b){
ans+=b-now+1;
}else{
ans+=nn*2;
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:13:11: error: 'nn' was not declared in this scope; did you mean 'yn'?
13 | while(nn*2+now<=b){
| ^~
| yn
a.cc:16:8: error: 'nn' was not declared in this scope; did you mean 'yn'?
16 | if(nn+now>b){
| ^~
| yn
|
s249270888 | p03708 | C++ | #include <stdint.h>
#include <stdio.h>
uint64_t f(uint64_t A, uint64_t B, uint64_t bit) {
uint64_t Blen = 1;
for (uint64_t x = 1; x < bit; x *= 2, ++Blen);
uint64_t bb = bit / 2;
for (; bb && !(B & bb); bb /= 2);
uint64_t bblen = 1;
for (uint64_t x = 1; x < bb; x *= 2, ++bblen);
if (bblen + 1 == Blen) {
return bit;
}
uint64_t Alo = std::max(A, uint64_t(1) << bblen);
return (bb == 0 ? 1 : 2*bb) + bit - Alo;
}
uint64_t solve(uint64_t A, uint64_t B) {
uint64_t bit = 1;
for (; 2 * bit <= B; bit *= 2);
uint64_t count = 0;
for (; bit; B = bit - 1, bit /= 2) {
if (A == B) {
return count + 1;
}
A &= (bit << 1) - 1;
B &= (bit << 1) - 1;
if ((A ^ B) & bit) {
count += f(A, B, bit);
}
}
return count;
}
int main() {
for (long long unsigned A, B; scanf("%llu%llu", &A, &B) == 2;) {
printf("%llu\n", (long long unsigned)solve(A, B));
}
} | a.cc: In function 'uint64_t f(uint64_t, uint64_t, uint64_t)':
a.cc:16:25: error: 'max' is not a member of 'std'
16 | uint64_t Alo = std::max(A, uint64_t(1) << bblen);
| ^~~
|
s191846161 | p03708 | C++ | #include<bits/stdc++.h>
#define L long long
using namespace std;
L l,r;
inline L calc(int i,L l,L r,bool t)
{
if(l==-1 && r==-1)
return 0;
if(t && r==-1)
return 0;
if(i==-1)
return 1;
if(r==-1)
{
if(l==-1)
return 0;
if(l==0)
return 1;
//int k;
//for(k=i;!(l&(1ll<<k));k--);
r//eturn (1ll<<k+1);
return 0;
}
if(!r)
return (1ll<<i+1);
L k=0;
k+=calc(i-1,min(l,(1ll<<i)-1),r<(1ll<<i)?r:-1,t);
if(r<=(1ll<<i))
k+=calc(i-1,min(l,(1ll<<i)-1),0,0);
else if(l>=(1ll<<i))
k+=calc(i-1,min(l,(1ll<<i)-1),r-(1ll<<i),t);
else
k+=calc(i-1,min(l,(1ll<<i)-1),r-(1ll<<i),1);
return k;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int i;
scanf("%lld%lld",&l,&r);
for(i=60;(l&(1ll<<i))==(r&(1ll<<i));i--)
if(l&(1ll<<i))
l-=1ll<<i,r-=1ll<<i;
printf("%lld\n",calc(i-1,r-(1ll<<i),l,0)+calc(i-1,-1,l,0));
return 0;
}
| a.cc: In function 'long long int calc(int, long long int, long long int, bool)':
a.cc:21:13: error: expected ';' before 'return'
21 | r//eturn (1ll<<k+1);
| ^
| ;
22 | return 0;
| ~~~~~~
|
s562087017 | p03708 | C++ | #include <iostream>
#define int long long
using namespace std;
int keta(int n){
int ret = 0;
while(n){
ret++;
n /= 2;
}
return ret;
}
int calc(int a,int b){
if(!a && !b) return 1;
if(keta(a) == keta(b)) return calc(a - (1ll << (keta(a) - 1)),b - (1ll << (keta(a) - 1)));
else return min(calc(1ll << (keta(b) - 1),b) + 1ll << (keta(b) - 1) - a),1ll << (keta(b) - 1)) + 1ll << (keta(b) - 1) - a;
}
signed main(){
int a,b;
cin >> a >> b;
cout << calc(a,b) << endl;
return 0;
} | a.cc: In function 'long long int calc(long long int, long long int)':
a.cc:17:24: error: no matching function for call to 'min(long long int)'
17 | else return min(calc(1ll << (keta(b) - 1),b) + 1ll << (keta(b) - 1) - a),1ll << (keta(b) - 1)) + 1ll << (keta(b) - 1) - a;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 1 provided
a.cc:17:102: error: expected ';' before ')' token
17 | else return min(calc(1ll << (keta(b) - 1),b) + 1ll << (keta(b) - 1) - a),1ll << (keta(b) - 1)) + 1ll << (keta(b) - 1) - a;
| ^
| ;
a.cc:17:102: error: expected primary-expression before ')' token
|
s472875303 | p03708 | C++ | #include <bits/stdc++.h>
using namespace std;
long long a, b;
int main() {
cin >> a >> b;
if(a == b) cout << 1, exit(0);
int r = 60;
while((a >> r & 1) == (b >> r & 1)) --r;
a &= (1ll << r+1)-1, b &= (1ll << r+1)-1;
int k = r-1;
while(k >= 0 && !(b >> k & 1)) --k;
ans = (1ll << r+1) - a;
if(1ll << k+1 < a) ans -= a - (1ll << k+1);
cout << ans;
}
| a.cc: In function 'int main()':
a.cc:13:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
13 | ans = (1ll << r+1) - a;
| ^~~
| abs
|
s666113584 | p03708 | C++ | #include<bits/stdc++.h>
using namespace std;
long long a,b,t,w,ans;
inline long long dis(const long long&l,const long long&r)
{
if(l>r)
return 0ll;
else
return r-l+1;
}
int main(void)
{
scanf("%lld%lld",&a,&b);
if(a==b)
return 0*puts("1");
for(int i=63;~i;i--)
if((b&(1<<i))&&!(a&(1<<i)))
{
t=(1<<i);
a&=t-1;
b&=(t<<1)-1;
for(w=i-1;~w;w--)
if(b&(1<<w))
{
w=t+(1<<W+1)-1
break;
}
break;
}
ans=dis(a,b)+dis(t+a+1,t<<1)-dis(t+a,w);
cout<<ans;
} | a.cc: In function 'int main()':
a.cc:25:49: error: 'W' was not declared in this scope
25 | w=t+(1<<W+1)-1
| ^
|
s268777314 | p03708 | C++ | #include <bits/stdc++.h>
#define forn(i, s, f) for (int i = (s); i <= (f); ++i)
#define for1(i, s, f) for (int i = (s); i >= (f); --i)
#define pb push_back
using namespace std;
typedef long long ll;
ll a, b, r, k = -1, ans;
#define int long long
int bit(ll x, int i)
{
return ((x >> i) & 1);
}
main()
{
cin >> a >> b;
if (a == b)
{
cout << 1;
return 0;
}
forn (i, 1, 61)
{
if (bit(a, i) != bit(b, i))
r = i;
}
forn (i, r + 1, 61)
{
a = (bit(a, i) ? (a ^ (1ll << i)) : a),
b = (bit(b, i) ? (b ^ (1ll << i)) : b);
}
ans = (1ll << r) - a;
forn (i, 0, 61)
{
if ((1ll << r) + (1ll << i) <= b)
k = i;
else
break;
}
pair < int, int > X, Y;
X = {(1ll << r), (1ll << r) + (1ll << (k + 1ll)) - 1ll};
Y = {(1ll << r) + a, 2ll * (1ll << r) - 1};
if (X.second < Y.first) ans += (X.second - X.first + 1x) + (Y.second - Y.first + 1);
else ans += max(X.second, Y.second) - X.first + 1;
cout << ans;
}
| a.cc:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
20 | main()
| ^~~~
a.cc: In function 'int main()':
a.cc:49:58: error: unable to find numeric literal operator 'operator""x'
49 | if (X.second < Y.first) ans += (X.second - X.first + 1x) + (Y.second - Y.first + 1);
| ^~
|
s160930806 | p03708 | Java | import java.util.*;
public class HelloWorld{
public static void main(String []args){
Scanner in = new Scanner(System.in);
System.out.println(Long.highestOneBit(3));
}
}
| Main.java:3: error: class HelloWorld is public, should be declared in a file named HelloWorld.java
public class HelloWorld{
^
1 error
|
s030503966 | p03708 | C++ | #include "bits/stdc++.h"
using namespace std;
long long a , b;
long long k;
long long intersect(long long a , long long b , long long l , long long r){
return max(0LL , min(r , b) - max(l , a) + 1LL);
}
long long getor(long long l , long long r){
long long res = 0;
for(int i = 0 ; i < 60 ; ++i){
if((l | (1LL << i)) <= r){
res |= 1LL << i;
}
}
while(l <= r){
ans |= l;
l <<= 1;
}
return res;
}
int main(){
cin >> a >> b;
if(a == b){
cout << 1 << endl;
}
for(int i = 60 ; i >= 0 ; --i){
if(((a >> i) & 1) != ((b >> i) & 1)){
k = 1LL << i;
break;
}
a &= ~(1LL << i);
b &= ~(1LL << i);
}
long long ans = 0;
ans += k - a;
long long r = getor(k , b);
ans += (r - k + 1);
ans += k - a;
ans -= intersect(k + a , k + k - 1 , k , r);
cout << ans << endl;
} | a.cc: In function 'long long int getor(long long int, long long int)':
a.cc:16:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
16 | ans |= l;
| ^~~
| abs
|
s005771693 | p03708 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
ll A, B;
vi get(ll x)
{
vi res;
while (x > 0) {
res.pb(x & 1);
x /= 2;
}
return res;
}
vector<pair<ll, ll>> cand;
int main() {
cin >> A >> B;
if (A == B) {
puts("1");
return 0;
}
vi va = get(A);
vi vb = get(B);
while (va.size() < vb.size()) {
va.pb(0);
}
ll com = 0;
int lp = -1;
int sz = va.size();
for (int i = sz - 1; i >= 0; --i) {
if (va[i] != vb[i]) {
lp = i;
break;
}
com += ((ll)va[i]LL << i);
}
sz = lp + 1;
cand.eb(A - com, (1LL << lp) - 1);
cand.eb(A - com + (1LL << lp), (1LL << (lp + 1)) - 1);
int pz = -1;
for (int i = sz - 2; i >= 0; --i) {
if (vb[i]) {
pz = i;
break;
}
}
ll lo = (1LL << lp);
ll hi = (1LL << lp);
if (pz != -1) {
hi += (1LL << (pz + 1)) - 1;
}
cand.eb(lo, hi);
sort(ALL(cand));
ll ret = 0;
ll la = -1, hd = -1;
rep(i, cand.size()) {
if (la == -1) {
hd = cand[i].fi, la = cand[i].se;
} else {
if (la >= cand[i].fi) {
la = max(cand[i].se, la);
} else {
ret += la - hd + 1;
hd = cand[i].fi, la = cand[i].se;
}
}
}
ret += la - hd + 1;
cout << ret << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:55:34: error: expected ')' before 'LL'
55 | com += ((ll)va[i]LL << i);
| ~ ^~
| )
|
s935910408 | p03708 | C++ | #include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <cmath>
using namespace std;
int main()
{
long long A,B,i,firstA,firstB,r,k;
cin >> A >> B;
bitset<60> bitA(A);
bitset<60> bitB(B);
cout << bitA << endl;
cout << bitB << endl;
r = -1;
k= -1;
for (i=59;i>=0;i--){
if (bitA.test(i)!= bitB.test(i)){
r = i;
break;
}else{
bitA.reset(i);
bitB.reset(i);
}
}
A = bitA.to_ullong();
B = bitB.to_ullong();
if (r== -1){
cout << 1 << endl;
}else{
for (i=r-1;i>=0;i--){
if (bitB.test(i)){
k = i;
break;
}
}
if (pow(2,k+1) >= A){
cout << dec <<(long long)((1LL<<r+1) - A) << endl;
}else{
cout << dec << (2 * (long long)((1LL<<r) - A) + (1LL<<(k+1))) <<endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:12:5: error: 'bitset' was not declared in this scope
12 | bitset<60> bitA(A);
| ^~~~~~
a.cc:6:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
5 | #include <cmath>
+++ |+#include <bitset>
6 | using namespace std;
a.cc:12:16: error: 'bitA' was not declared in this scope
12 | bitset<60> bitA(A);
| ^~~~
a.cc:13:16: error: 'bitB' was not declared in this scope
13 | bitset<60> bitB(B);
| ^~~~
|
s203265978 | p03708 | C++ | 1. #include <bits/stdc++.h>
2. #define forn(i, n) for(int i = 0; i < (int)(n); i++)
3. typedef long long ll;
4. typedef unsigned long long ull;
5. typedef long double ld;
6. using namespace std;
7.
8. ll get(ll x) {
9. for(int i = 60; i >= 0; i--) {
10. if((1LL << i) & x)
11. return i;
12. }
13. }
14.
15. int main() {
16. //ios_base::sync_with_stdio(false);
17. //freopen("input.txt", "r", stdin);
18. //freopen("output.txt", "w", stdout);
19.
20. ll a, b;
21. cin >> a >> b;
22. if(a == b) {
23. cout << "1\n";
24. return 0;
25. }
26. ll pos1 = get(a);
27. ll pos2 = get(b);
28. ull ans = 0;
29. while(pos1 == pos2) {
30. a ^= (1LL << pos1);
31. b ^= (1LL << pos2);
32. pos1 = get(a);
33. pos2 = get(b);
34. }
35. ans += (1LL << pos2) - a + 1;
36. ans += ((1LL << (pos1 + 1)) - 1) - a + 1;
37. b ^= (1LL << pos2);
38. ans += max(0LL, min(a - 1, (1LL << (get(b) + 1)) - 1));
39. for(int i = max(get(b) + 1, pos1 + 1); i < pos2; i++) {
40. ans += (1LL << i);
41. }
42. cout << ans << "\n";
43. return 0;
44. }
| a.cc:1:4: error: stray '#' in program
1 | 1. #include <bits/stdc++.h>
| ^
a.cc:2:4: error: stray '#' in program
2 | 2. #define forn(i, n) for(int i = 0; i < (int)(n); i++)
| ^
a.cc:7:4: error: extended character is not valid in an identifier
7 | 7.
| ^
a.cc:14:5: error: extended character is not valid in an identifier
14 | 14.
| ^
a.cc:19:5: error: extended character is not valid in an identifier
19 | 19.
| ^
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1. #include <bits/stdc++.h>
| ^~
a.cc:2:38: error: 'i' does not name a type
2 | 2. #define forn(i, n) for(int i = 0; i < (int)(n); i++)
| ^
a.cc:2:52: error: 'i' does not name a type
2 | 2. #define forn(i, n) for(int i = 0; i < (int)(n); i++)
| ^
a.cc:4:1: error: expected unqualified-id before numeric constant
4 | 4. typedef unsigned long long ull;
| ^~
a.cc:5:1: error: expected unqualified-id before numeric constant
5 | 5. typedef long double ld;
| ^~
a.cc:6:1: error: expected unqualified-id before numeric constant
6 | 6. using namespace std;
| ^~
a.cc:7:1: error: expected unqualified-id before numeric constant
7 | 7.
| ^~
a.cc:14:1: error: expected unqualified-id before numeric constant
14 | 14.
| ^~~
|
s632856841 | p03708 | C++ | #import<iostream>
#define a(x) 1LL<<64-__builtin_clzll(x)
long long A,B,C,i;main(){std::cin>>A>>B;if(A^B){C=(a(A^B))-1;A&=C;B&=C;i=++C>>1;B=(B-i)?(a(B-i))-1:0;C=C-A-(A>B)*(A-1-B);std::cout<<C;}elseputs("1");} | a.cc:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
1 | #import<iostream>
| ^~~~~~
a.cc:3:19: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | long long A,B,C,i;main(){std::cin>>A>>B;if(A^B){C=(a(A^B))-1;A&=C;B&=C;i=++C>>1;B=(B-i)?(a(B-i))-1:0;C=C-A-(A>B)*(A-1-B);std::cout<<C;}elseputs("1");}
| ^~~~
a.cc: In function 'int main()':
a.cc:3:136: error: 'elseputs' was not declared in this scope
3 | long long A,B,C,i;main(){std::cin>>A>>B;if(A^B){C=(a(A^B))-1;A&=C;B&=C;i=++C>>1;B=(B-i)?(a(B-i))-1:0;C=C-A-(A>B)*(A-1-B);std::cout<<C;}elseputs("1");}
| ^~~~~~~~
|
s938793097 | p03708 | C++ | sssssssssssss | a.cc:1:1: error: 'sssssssssssss' does not name a type
1 | sssssssssssss
| ^~~~~~~~~~~~~
|
s448015950 | p03708 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
using namespace std;
void solve(unsigned long long a, unsigned long long b) {
unsigned long long tmp = b;
int counter = 0;
int counter2 = 0;
while (tmp == 0) {
if (tmp/2 == 1) {
counter2 += 1;
}
tmp /= 2;
counter += 1;
}
unsigned long long maxa = poe(2, counter);
unsigned long long x = maxa - a;
x += b - a + 1;
std::cout << x << std::endl;
}
int main() {
struct timeval start,end;
long long span;
unsigned long long a b;
gettimeofday(&start,NULL);
std::cin >> a >> b;
solve(a, b);
gettimeofday(&end,NULL);
span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
return 0;
}
| a.cc: In function 'void solve(long long unsigned int, long long unsigned int)':
a.cc:23:31: error: 'poe' was not declared in this scope; did you mean 'pow'?
23 | unsigned long long maxa = poe(2, counter);
| ^~~
| pow
a.cc: In function 'int main()':
a.cc:32:26: error: expected initializer before 'b'
32 | unsigned long long a b;
| ^
a.cc:36:17: error: 'a' was not declared in this scope
36 | std::cin >> a >> b;
| ^
a.cc:36:22: error: 'b' was not declared in this scope
36 | std::cin >> a >> b;
| ^
|
s918607953 | p03708 | Java | import java.util.*;
public class sample {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = Integer.parseInt(sc.next());
int b = Integer.parseInt(sc.next());
int res;
if(b >= a){
res = b -a;
res = res + res /2;
system.out.print(res);
}
}
} | Main.java:2: error: class sample is public, should be declared in a file named sample.java
public class sample {
^
Main.java:14: error: package system does not exist
system.out.print(res);
^
2 errors
|
s642585059 | p03708 | Java | import java.util.*;
public class sample {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = Integer.parseInt(sc.next());
int b = Integer.parseInt(sc.next());
int res
if(b >= a){
res = b -a;
res = res + res /2;
system.out.print(res);
}
}
} | Main.java:9: error: ';' expected
int res
^
1 error
|
s804592078 | p03708 | Java | import java.util.*;
public class sample {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = Integer.parseInt(sc.next());
int b = Integer.parseInt(sc.next());
int res
if(b >= a){
res = b -a;
res = res + res /2;
system.out.print(res);
}
}
} | Main.java:9: error: ';' expected
int res
^
1 error
|
s647244078 | p03709 | C++ | //W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define re register int
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pa pair<int,int>
#define fr first
#define sd second
#define Z(x) (x>=mod?x-mod:x)
#define lowbit(x) (x&(-x))
#define N 1000010
#define ls (x<<1)
#define rs (x<<1|1)
#define mid ((l+r)>>1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
char ch=getchar();
ll s=0,w=1;
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
return s*w;
}
pa p[N],g[N];
int n;int st[N],top,f[N],s[N];
vector<int>v[N];
const int mod=1e9+7;
int minn[N<<2],maxn[N<<2];
void build(int l,int r,int x)
{
if(l==r){minn[x]=maxn[x]=p[l].sd;return ;}
build(l,mid,ls);build(mid+1,r,rs);
minn[x]=min(minn[ls],minn[rs]);
maxn[x]=max(maxn[ls],maxn[rs]);
}
int askl(int l,int r,int x,int val)
{
if(maxn[x]<val)return inf;
if(l==r){return l;}int t=askl(l,mid,ls,val);
if(t!=inf)return t;
else return askl(mid+1,r,rs,val);
}
int askr(int l,int r,int x,int pos,int val)
{
if(minn[x]>val)return -inf;
if(l==r){return l;}int t=askr(mid+1,r,rs,val);
if(t!=-inf)return t;
else return askr(l,mid,ls,val);
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n=read();
FOR(i,1,n)p[i].sd=read(),p[i].fr=read();
sort(p+1,p+n+1);build(1,n,1);
FOR(i,1,n)g[i].sd=min(askl(1,n,1,p[i].sd),i),g[i].fr=max(askr(1,n,1,p[i].sd),i);
//FOR(i,1,n)cout<<g[i].sd<<" "<<g[i].fr<<endl;
FOR(i,1,n)v[g[i].fr].pb(g[i].sd);
f[0]=1;
FOR(i,0,n)s[i]=1;
FOR(i,1,n)
{
s[i]=Z(s[i-1]+f[i]);
for(int x:v[i])
{
f[i]=Z(f[i]+Z(s[i]+mod-(x>1?s[x-2]:0)));
s[i]=Z(s[i-1]+f[i]);
}
//cout<<"WTF:"<<i<<" "<<f[i]<<endl;
}
printf("%d\n",f[n]);
return 0;
}
//code once,check twice | a.cc: In function 'int askr(int, int, int, int, int)':
a.cc:53:38: error: too few arguments to function 'int askr(int, int, int, int, int)'
53 | if(l==r){return l;}int t=askr(mid+1,r,rs,val);
| ~~~~^~~~~~~~~~~~~~~~
a.cc:50:5: note: declared here
50 | int askr(int l,int r,int x,int pos,int val)
| ^~~~
a.cc:55:25: error: too few arguments to function 'int askr(int, int, int, int, int)'
55 | else return askr(l,mid,ls,val);
| ~~~~^~~~~~~~~~~~~~
a.cc:50:5: note: declared here
50 | int askr(int l,int r,int x,int pos,int val)
| ^~~~
a.cc: In function 'int main()':
a.cc:62:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
62 | FOR(i,1,n)p[i].sd=read(),p[i].fr=read();
| ^
a.cc:6:27: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
| ^
a.cc:64:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
64 | FOR(i,1,n)g[i].sd=min(askl(1,n,1,p[i].sd),i),g[i].fr=max(askr(1,n,1,p[i].sd),i);
| ^
a.cc:6:27: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
| ^
a.cc:64:66: error: too few arguments to function 'int askr(int, int, int, int, int)'
64 | FOR(i,1,n)g[i].sd=min(askl(1,n,1,p[i].sd),i),g[i].fr=max(askr(1,n,1,p[i].sd),i);
| ~~~~^~~~~~~~~~~~~~~
a.cc:50:5: note: declared here
50 | int askr(int l,int r,int x,int pos,int val)
| ^~~~
a.cc:66:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
66 | FOR(i,1,n)v[g[i].fr].pb(g[i].sd);
| ^
a.cc:6:27: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
| ^
a.cc:68:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
68 | FOR(i,0,n)s[i]=1;
| ^
a.cc:6:27: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
| ^
a.cc:69:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
69 | FOR(i,1,n)
| ^
a.cc:6:27: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
| ^
|
s583309884 | p03709 | C++ | #include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
return f*x;
}
const int N = 2e5+5, P = 1e9+7;
int n;
pair<int, int> p[N];
int f[N], s[N], t[N], _[N], ans;
vector<int> h[N];
int main()
{
n = read();
for(int i = 1; i <= n; ++i)
{
int x = read(), v = read();
p[i] = make_pair(x, v), _[i] = v;
}
sort(_+1, _+1+n), sort(p+1, p+1+n);
for(int i = 1; i <= n; ++i) p[i].second = lower_bound(_+1, _+1+n, p[i].second)-_;
for(int i = n, f = p[n].second; i; --i) f = min(f, p[i].second), t[i] = f;
for(int i = 1, f = 0; i <= n; ++i) f = max(f, p[i].second), h[f].push_back(t[i]);
f[0] = s[0] = 1;
for(int i = 1; i <= n; ++i)
{
s[i] = s[i-1];
for(int k = 0; k < h[i].size(); ++k)
{
int j = h[i][k];
s[i] = ((s[i]+((s[i]-s[j-1]+P)%P+f[j-1]))%P)%P;
}
}
printf("%d\n", (s[n]-s[n-1]+P)%P);
return 0;
}- | a.cc:42:2: error: expected unqualified-id before '-' token
42 | }-
| ^
|
s786857179 | p03709 | C++ | #include<bits/stdc++.h>
using namespace std;
#define MOD (1000000007)
const int N=5e5+10;
int h[N], l[N], r[N];
vector<int> L[N];
int x[N], v[N], a[N];
bool cmp(const int &a, const int &b) { return v[a]<v[b]; }
int f[N], S[N];
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int n, m;
cin>>n;
for(int i=1; i<=n; i++) cin>>x[i]>>v[i], a[i]=i;
sort(a+1, a+1+n, cmp);
int stk[N], p[N], t=0;
for(int i=1; i<=n; i++) {
if(!t || stk[t]<x[a[i]]) stk[++t]=x[a[i]], p[t]=i;
int l=1, r=t, mid;
while(l<r) {
mid=(l+r)>>1;
if(stk[mid]<x[a[i]]) l=mid+1;
else r=mid;
}
l[i]=p[r];
}
t=0;
for(int i=n; i>=1; i--) {
if(!t || stk[t]>x[a[i]]) stk[++t]=x[a[i]], p[t]=i;
int l=1, r=t, mid;
while(l<r) {
mid=(l+r)>>1;
if(stk[mid]>x[a[i]]) l=mid+1;
else r=mid;
}
r[i]=p[r];
}
for(int i=1; i<=n; i++) L[r[i]].push_back(l[i]);
f[0]=S[0]=1;
for(int i=1; i<=n; i++) {
S[i]=S[i-1];
sort(L[i].begin(), L[i].end());
for(int j:L[i]) {
f[i]=(1ll*f[i]+S[i]-(j-2>=0?S[j-2]:0)+MOD)%MOD;
S[i]=(f[i]+S[i-1])%MOD;
}
}
cout<<f[n]<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:28:10: error: invalid types 'int[int]' for array subscript
28 | l[i]=p[r];
| ^
a.cc:39:10: error: invalid types 'int[int]' for array subscript
39 | r[i]=p[r];
| ^
|
s923024414 | p03709 | C++ | #include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#define pr pair<int,int>
using namespace std;
const int mod = 1e9+7;
const int maxn = 200010;
int n = 0;
pr p[maxn];
int X[maxn], V[maxn];
int fa[maxn];
int getroot(int u) {
return fa[u] == u ? u : (fa[u]=getroot(fa[u]));
}
void Union(int u, int v) {
int ru = getroot(u), rv = getroot(v);
if (ru != rv) fa[ru] = rv;
}
int Min(int i, int j) {
if (!i) return j;
return V[i] < V[j] ? i : j;
}
int Max(int i, int j) {
if (!i) return j;
return V[i] > V[j] ? i : j;
}
void solve(int l, int r) {
if (l == r) return;
int m = (l + r) >> 1;
solve(l, m);
solve(m+1, r);
int mx_L = 0, mn_R = 0;
for (int i = l; i <= m; i++) mx_L = max(mx_L, V[i]);
for (int i = m+1; i <= r; i++) mn_R = min(mn_R, v[i]);
for (int i = l; i <= m; i++) if (V[i] > V[mn_R]) Union(i, mn_R);
for (int i = m+1; i <= r; i++) if (V[i] < V[mx_L]) Union(i, mx_L);
}
int qpow(int x, int y) {
int ret = 1;
while (y) {
if (y&1) {
ret = 1LL*ret*x%mod;
}
x = 1LL*x*x%mod;
y >>= 1;
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
fa[i] = i;
}
for (int i = 1; i <= n; i++) {
scanf("%d%d", &X[i], &V[i]);
p[i] = pr(X[i], V[i]);
}
sort(p+1, p+n+1);
for (int i = 1; i <= n; i++) V[i] = p[i].second;
solve(1, n);
sort(fa+1, fa+n+1);
int c = 0;
int ans = 1;
for (int i = 1; i <= n+1; i++) {
if (fa[i] != fa[i-1]) {
ans = 1LL*ans*(qpow(2, c)+mod-1)%mod;
c = 1;
} else c ++;
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'void solve(int, int)':
a.cc:43:53: error: 'v' was not declared in this scope
43 | for (int i = m+1; i <= r; i++) mn_R = min(mn_R, v[i]);
| ^
a.cc: In function 'int qpow(int, int)':
a.cc:57:1: warning: no return statement in function returning non-void [-Wreturn-type]
57 | }
| ^
|
s084243163 | p03709 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 200050
#define mod 1000000007
ll f[N],s[N];
int n,V[N],L[N],R[N];
struct A {
int x,v;
bool operator < (const A &p) const {return x<p.x;}
}a[N];
int main() {
scanf("%d",&n);
int i,k=1;
for(i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].v),V[i]=a[i].v;
sort(V+1,V+n+1);
for(i=1;i<=n;i++) a[i].v=lower_bound(V+1,V+n+1,a[i].v)-V;
sort(a+1,a+n+1);
for(R[0]=0,i=1;i<=n;i++) R[i]=max(R[i-1],a[i].v);
for(L[n+1]=n+1,i=n;i;i--) L[i]=min(L[i+1],a[i].v);
for(f[0]=s[0]=1,i=1;i<=n;i++) {
int l=L[i],r=R[i];
for(;k<=r;k++) s[k]=s[k-1];
if(l>1) f[r]=(f[r]+s[r]-s[l-2]+mod)%mod;
else f[r]=(f[r]+s[r])%mod;
s[r]=(s[r-1]+f[r])%mod;
}
printf("%lld\n",(f[n]%mod+mod)%mod);
}
| a.cc:8:1: error: 'll' does not name a type
8 | ll f[N],s[N];
| ^~
a.cc: In function 'int main()':
a.cc:23:13: error: 'f' was not declared in this scope
23 | for(f[0]=s[0]=1,i=1;i<=n;i++) {
| ^
a.cc:23:18: error: 's' was not declared in this scope
23 | for(f[0]=s[0]=1,i=1;i<=n;i++) {
| ^
a.cc:30:26: error: 'f' was not declared in this scope
30 | printf("%lld\n",(f[n]%mod+mod)%mod);
| ^
|
s254848085 | p03709 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 200050
#define mod 1000000007
int n,f[N],V[N],L[N],R[N],s[N];
struct A {
int x,v;
bool operator < (const A &p) constt {x<p.x;}
}a[N];
int main() {
scanf("%d",&n);
int i,k=1; s[0]=1;
for(i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].v),V[i]=a[i].v;
sort(V+1,V+n+1);
for(i=1;i<=n;i++) a[i].v=lower_bound(V+1,V+n+1,a[i].v)-V;
sort(a+1,a+n+1,cmp1);
for(R[0]=0,i=1;i<=n;i++) R[i]=max(R[i-1],a[i].v);
for(L[n+1]=n+1,i=n;i;i--) L[i]=min(L[i+1],a[i].v);
for(i=1;i<=n;i++) {
int l=L[i],r=R[i];
for(;k<=r;k++) s[k]=s[k-1];
if(l>1) f[r]=(f[r]+s[r]-s[l-2]+mod)%mod;
else f[r]=(f[r]+s[r])%mod;
s[r]=(s[r-1]+f[r])%mod;
}
printf("%d\n",f[n]);
}
| a.cc:11:36: error: expected ';' at end of member declaration
11 | bool operator < (const A &p) constt {x<p.x;}
| ^
| ;
a.cc:11:38: error: 'constt' does not name a type; did you mean 'const'?
11 | bool operator < (const A &p) constt {x<p.x;}
| ^~~~~~
| const
a.cc: In function 'int main()':
a.cc:19:24: error: 'cmp1' was not declared in this scope
19 | sort(a+1,a+n+1,cmp1);
| ^~~~
|
s720183515 | p03709 | C++ | #include <bits/stdc++.h>
const int N=2e5+10,Mod=1e9+7;
struct Node{
int k,x,l,r;
bool operator < ( const Node &A ) const { return (r<A.r) || ( r==A.r && l<A.l); }
}p[N];
bool cmpk( const Node &A , const Node &B ) { return A.k<B.k; }
bool cmpx( const Node &A , const Node &B ) { return A.x<B.x; }
int n,f[N],sum[N];
void Init() {
scanf("%d",&n);
for (int i=1;i<=n;++i) scanf("%d%d",&p[i].x,&p[i].k);
}
void Solve() {
std::sort(p+1,p+n+1,cmpk); for (int i=1;i<=n;++i) p[i].k=i;
std::sort(p+1,p+n+1,cmpx); for (int i=1;i<=n;++i) p[i].x=i;
int mx=-Inf;
for (int i=1;i<=n;++i) {
mx=std::max(mx,p[i].k);
p[i].r=mx;
}
int mn=Inf;
for (int i=n;i>=1;--i) {
mn=std::min(mn,p[i].k);
p[i].l=mn;
}
std::sort(p+1,p+n+1);
f[0]=1; sum[0]=1; int t=1;
for (int i=1;i<=n;++i) {
while (p[t].r==i && t<=n) {
f[i]=(1ll*f[i]+f[i]+sum[i-1]-sum[p[t].l-1]+f[p[t].l-1])%Mod;
++t;
}
sum[i]=(sum[i-1]+f[i])%Mod;
}
printf("%d\n",f[n]);
}
int main() {
Init();
Solve();
return 0;
} | a.cc: In function 'void Solve()':
a.cc:23:17: error: 'Inf' was not declared in this scope; did you mean 'ynf'?
23 | int mx=-Inf;
| ^~~
| ynf
|
s479289230 | p03709 | C++ | #include<bits/stdc++.h>
#define int long long
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
typedef long long ll;
//by piano
template<typename tp> inline void read(tp &x) {
x = 0;char c = getchar();bool f = 0;
for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
if(f) x = -x;
}
const int N = 1e6 + 2333, inf = 1e16 + 233, mo = 1e9 + 7;
struct P {
int x, v;
}p[N];
int n, v[N], a[N], M, L[N], R[N], b[N];
inline bool cmp_x(P a, P b) {return a.x < b.x;}
inline int Qmin(int s, int t, int ans = inf) {
for(s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
if(~s & 1) ans = min(ans, a[s ^ 1]);
if(t & 1) ans = min(ans, a[t ^ 1]);
}return ans;
}
inline int Qmax(int s, int t, int ans = 0) {
for(s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
if(~s & 1) ans = max(ans, b[s ^ 1]);
if(t & 1) ans = max(ans, b[t ^ 1]);
}return ans;
}
vector<int> vec[N];
int tr[N];
inline void U(int &x, int y) {for(x += y; tr[x] >= mo; tr[x] -= mo);}
inline void A(int u, int v) {for(; u <= n; u += u & -u) U(tr[u], v);}
inline int Q(int u, int ans = 0) {for(; u >= 1; u -= u & -u) U(ans, tr[u]); return ans;}
main() {
read(n);
for(int i = 1; i <= n; i ++)
read(p[i].x), read(p[i].v);
sort(p + 1, p + n + 1, cmp_x);
for(int i = 1; i <= n; i ++)
v[i] = p[i].v;
sort(v + 1, v + n + 1);
for(int i = 1; i <= n; i ++)
p[i].v = lower_bound(v + 1, v + n + 1, p[i].v) - v;
for(M = 1; M <= n + 1; M ++);
memset(a, 38, sizeof(a));
for(int i = 1; i <= n; i ++)
a[i + M] = b[i + M] = p[i].v;
for(int i = M; i; i --) {
a[i] = min(a[i << 1], a[i << 1 | 1]);
b[i] = max(b[i << 1], b[i << 1 | 1]);
}
for(int i = 1; i <= n; i ++) {
L[i] = Qmin(i, n), R[i] = Qmax(1, i);
vec[R[i]].push_back(L[i]);
// cout << L[i] << " " << R[i] << " " << p[i].x << " " << p[i].v << "\n";
}
A(1, 1);
for(int i = 1; i <= n; i ++) {
for(vector<int> ::iterator it = vec[i].begin(); it != vec[i].end(); ++ it)
A(i, (Q(i) - Q(*it - 1) + mo) % mo);
}
cout << Q(n) - Q(n - 1);1
}
| a.cc:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
36 | main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:64:26: error: expected ';' before '}' token
64 | cout << Q(n) - Q(n - 1);1
| ^
| ;
65 | }
| ~
|
s326382840 | p03709 | C++ | #include <cstdio>
#include <queue>
#include <iostream>
#include <algorithm>
#define INT long long
#define oo 987654321
#define MOD 1000000007
using namespace std;
INT n, base, T[1<<19], ans, p[200020] = {1};
struct V{ INT x, v; } a[200020];
bool cmp(V a, V b)
{
return a.x < b.x;
}
bool cmp2(V a, V b)
{
return a.v < b.v;
}
INT getSum(int l, int r)
{
INT sum = 0;
while( l <= r )
{
if( l%2 == 1 ) sum+=T[l], l++;
if( r%2 == 0 ) sum+=T[r], r--;
l>>=1, r>>=1;
}
return sum;
}
int main()
{
ios::sync_with_stdio(false);
cin>>n;
for(int i = 1 ; i <= n ; i++ ) p[i] = p[i-1]*2, p[i]%=MOD;
for( base = 1 ; base < n ; base<<=1);
for(int i = 0 ; i < n ; i++ ) cin>>a[i].x>>a[i].v;
sort(a, a+n, cmp2);
for(int i = 0 ; i < n ; i++ ) a[i].v = i;
sort(a, a+n, cmp);
for(int i = 0 ; i < n ; i++ )
{
ans += (INT)pow(2, getSum(base+a[i].v, base*2-1));
ans %= MOD;
T[base+a[i].v] = 1;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:21: error: 'pow' was not declared in this scope
43 | ans += (INT)pow(2, getSum(base+a[i].v, base*2-1));
| ^~~
|
s165308426 | p03710 | C++ | #include <cstdio>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long ll;
using namespace std;
typedef std::pair<ll, ll> mp;
#define fi first
#define se second
#define MOD 1000000007
inline ll read()
{
ll x = 0, f = 1; char ch = getchar();
while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
return x * f;
}
const int maxk = 100, mod = 1000000007;
ll fib[maxk], res; int mx;
std::vector<mp> excellent[maxk];
int main() {
int k = 1;
fib[0] = fib[1] = 1;
ll lim = 1000000000000000000;
while(fib[k] + fib[k - 1] <= lim) {
++ k;
fib[k] = fib[k - 1] + fib[k - 2];
}
exellent[1].push_back(mp(1, 2));
for (int i = 2; i <= k; i++)
{
for (pair<ll, ll> p : exellent[i-1])
exellent[i].push_back(mp(p.se, p.fi + p.se));
exellent[i].push_back(mp(fib[i+1], fib[i+1] + fib[i-1]));
}
int T = read();
while (T--)
{
ll x = read(), y = read(); mx = 1, res = 0;
if (x > y) swap(x, y);
while (mx+2 <= k && fib[mx+1] <= x && fib[mx+2] <= y) mx++;
for (pair<ll, ll> p : excellent[mx])
{
if (p.fi <= x && p.se <= y)
(res += (y - p.se) / p.fi + 1) %= MOD;
if (p.se <= x)
(res += (x - p.se) / p.fi + 1) %= MOD;
}
if (mx == 1) res += x;
printf("%d %lld\n", mx, res);
}
} | a.cc: In function 'int main()':
a.cc:34:2: error: 'exellent' was not declared in this scope; did you mean 'excellent'?
34 | exellent[1].push_back(mp(1, 2));
| ^~~~~~~~
| excellent
|
s546801799 | p03710 | C++ | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define lint long long
using namespace std;
int readint() {
char c = getchar_unlocked();
int ans = 0;
while ('0' <= c && c <= '9') {
ans = ans * 10 + c - '0';
c = getchar_unlocked();
}
return ans;
}
lint readlint() {
char c = getchar_unlocked();
lint ans = 0;
while ('0' <= c && c <= '9') {
ans = ans * 10 + c - '0';
c = getchar_unlocked();
}
return ans;
}
char ch[1024];
void writeint(int& x) {
int ptr = 0;
while (x) {
ch[ptr++] = (x % 10) + '0';
x /= 10;
}
while (ptr) {
putchar_unlocked(ch[--ptr]);
}
putchar_unlocked(' ');
}
int q;
constexpr int mod=1000000007;
lint x,y,a,n,m;
constexpr lint f[]={0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,10610209857723,17167680177565,27777890035288,44945570212853,72723460248141,117669030460994,190392490709135,308061521170129,498454011879264,806515533049393,1304969544928657,2111485077978050,3416454622906707,5527939700884757,8944394323791464,14472334024676221,23416728348467685,37889062373143906,61305790721611591,99194853094755497,160500643816367088,259695496911122585,420196140727489673,679891637638612258,1100087778366101931};
int main(){
q=readint();
rep(i,q){
x=readlint();y=readlint();
if(x>y)swap(x,y);
if(y<=2){
writeint(1);writeint(y==1?1:x==1?2:4);
continue;
}
rep(j,99){
if(x<f[j]||y<f[j+1]){
a=(x==1?2:1);
rep(k,j-2){
n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];
if(n<=x&&m<=y)a+=(y-m)/n+1;
}
if(f[j]<=x){
a++;
rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);
}
writeint(j-2);writeint(a%mod);
break;
}
}
}
} | a.cc: In function 'int main()':
a.cc:45:34: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
45 | writeint(1);writeint(y==1?1:x==1?2:4);
| ^
a.cc:24:20: note: initializing argument 1 of 'void writeint(int&)'
24 | void writeint(int& x) {
| ~~~~~^
a.cc:45:50: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
45 | writeint(1);writeint(y==1?1:x==1?2:4);
| ~~~~^~~~~~~~~~~
a.cc:24:20: note: initializing argument 1 of 'void writeint(int&)'
24 | void writeint(int& x) {
| ~~~~~^
a.cc:59:43: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
59 | writeint(j-2);writeint(a%mod);
| ~^~
a.cc:24:20: note: initializing argument 1 of 'void writeint(int&)'
24 | void writeint(int& x) {
| ~~~~~^
a.cc:59:57: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
59 | writeint(j-2);writeint(a%mod);
| ~^~~~
a.cc:24:20: note: initializing argument 1 of 'void writeint(int&)'
24 | void writeint(int& x) {
| ~~~~~^
|
s479735251 | p03710 | C++ | #pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define SZ(x) ((ll)(x).size())
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
const int MOD = 1e9 + 7;
using P = pair<ll,ll>;
V<> fib(90, 1);
VV<P> worst(85);
void preparation(){
for(int i = 2; i < 90; i++) fib[i] = fib[i-1] + fib[i-2];
worst[0].pb({1, 2});
REP(i, 84){
REP(j, SZ(worst[i])){
P p = worst[i][j];
ll a = p.first, b = p.second, c = a + b;
worst[i + 1].pb({b, c});
if(!j) worst[i + 1].pb({c, b + 2 * a});
}
}
}
ll x, y;
void solve(){
scanf("%lld%lld", &x, &y);
if(x > y) swap(x, y);
if(y <= 2){
printf("1 %lld\n", x*y);
return;
}
ll a = 0;
while(fib[a + 1] <= x and fib[a + 2] <= y) a++;
if(a == 1){
printf("%d %lld\n", 1, (x%MOD*y)%MOD);
return;
}
ll res = 0;
for(auto &p : worst[a - 1]){
if(p.first > x or p.second > y) continue;
res++;
res = (res + (y - p.second) / p.first) % MOD;
if(p.second > x or p.first > y) continue;
res++;
}
printf("%lld %lld\n", a, res%MOD);
}
int q;
int main(){
ios;
preparation();
scanf("%d", &q);
while(q--) solve();
} | a.cc: In function 'int main()':
a.cc:60:5: error: declaration does not declare anything [-fpermissive]
60 | ios;
| ^~~
|
s860947738 | p03710 | C++ | 10
1 1
2 2
5 1000000000000000000
7 3
1 334334334334334334
23847657 23458792534
111111111 111111111
7 7
4 19
9 10 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10
| ^~
|
s478984349 | p03710 | C++ | #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define mk make_pair<ll, ll>
#define M (1ll << 60)
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef double db;
const int N = 300;
const int mod = 1000000007;
int Q, k, s[N];
ll X, Y, ans, f[N];
pair<ll, ll> p[N][N];
void prework() {
f[0] = 1, f[1] = 1, f[2] = 2, f[3] = 3;
p[1][1] = mk(1, 2);
p[1][2] = mk(1, 3);
s[1] = 2;
k = 1;
while (f[k + 1] <= M) {
k ++;
f[k + 2] = f[k] + f[k + 1];
Rep(i, 1, s[k - 1]) {
ll x = p[k - 1][i].fr, y = p[k - 1][i].sd;
for (x += y; x <= f[k + 2]; x += y) {
p[k][++ s[k]] = mk(y, x);
}
}
}
}
void calc(ll x, ll y) {
if (x <= X && y <= Y && x * 2 > y) (ans += (Y - y) / x + 1) %= mod;
}
int main()
{
prework();
scanf ("%d", &Q);
while(Q --) {
scanf ("%lld%lld", &X, &Y);
if (X > Y) swap(X, Y);
int i = k;
while (i && p[i][1].fr > X || p[i][1].sd > Y) i --;
if (!i) i ++;
if (i == 1) {
printf("%d %lld\n", i, X % mod * Y % mod);
continue ;
}
ans = 0;
Rep(j, 1, s[i]) {
ll x = p[i][j].fr, y = p[i][j].sd;
calc(x, y);
calc(y, x);
}
printf("%d %lld\n", i, ans);
}
return 0;
} | a.cc: In function 'void prework()':
a.cc:40:52: error: cannot bind rvalue reference of type 'long long int&&' to lvalue of type 'll' {aka 'long long int'}
40 | p[k][++ s[k]] = mk(y, x);
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = long long int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = long long int; typename decay<_Tp>::type = long long int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s693805866 | p03710 | C++ | #include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define x first
#define y second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;
const LL MAX = 1e18 + 10;
const int N = 100 + 5;
int n;
LL f[N];
vector<PII> P[N];
void init(){
freopen("F.in", "r", stdin);
freopen("F.out", "w", stdout);
f[0] = f[1] = 1;
n = 1;
while(f[n] < MAX) ++n, f[n] = f[n - 1] + f[n - 2];
f[n + 1] = f[n] + f[n - 1];
--n;
P[0].pb(mp(0, 1));
P[1].pb(mp(1, 2)), P[1].pb(mp(1, 3));
For(i, 1, n - 1){
for(PII s : P[i]){
LL u = s.x, v = s.y;
//printf("(%lld, %lld) ", u, v);
if(u == v) continue;
if(u > v) swap(u, v);
u += v;
while(u <= f[i + 3]) P[i + 1].pb(mp(u, v)), u += v;
}
//puts("");
}
For(i, 1, n){
sort(P[i].begin(), P[i].end());
P[i].resize(unique(P[i].begin(), P[i].end()) - P[i].begin());
}
}
const int Mod = 1e9 + 7;
int main(){
init();
int q;
scanf("%d", &q);
while(q--){
LL x, y;
scanf("%lld%lld", &x, &y);
if(x > y) swap(x, y);
int ans = 0;
while(f[ans + 1] <= x && f[ans + 2] <= y) ++ans;
if(ans <= 1){
printf("1 %lld\n", x % Mod * (y % Mod) % Mod);
continue;
}
LL cnt = 0;
for(PII p : P[ans]){
LL u = p.x, v = p.y;
if(u < v) swap(u, v);
if(u / v >= 2) continue;
//printf("%lld %lld\n", u, v);
if(v <= y && x >= u) (cnt += (x - u + v) / v) %= Mod;
if(v <= x && y >= u) (cnt += (y - u + v) / v) %= Mod;
}
printf("%d %lld\n", ans, cnt);
}
return 0;
} | a.cc:24:1: error: 'vector' does not name a type
24 | vector<PII> P[N];
| ^~~~~~
a.cc: In function 'void init()':
a.cc:35:9: error: 'P' was not declared in this scope
35 | P[0].pb(mp(0, 1));
| ^
a.cc: In function 'int main()':
a.cc:76:29: error: 'P' was not declared in this scope
76 | for(PII p : P[ans]){
| ^
|
s787791028 | p03710 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PA pair<ll,ll>
const int mod = 1000000007;
vector<PA >a[110];
ll f[110];
int Q;
void init()
{
a[1].push_back(PA(1,1));
f[0]=f[1]=1;
for(int i=2;i<=90;i++)
f[i]=f[i-1]+f[i-2];
for(int i=2;i<90;i++)
{
a[i].push_back(PA(f[i-1],f[i]));
a[i].push_back(PA(f[i-1],f[i+1]));
for(int j=1;j<a[i-1].size();j++)
{
PA t=a[i-1][j];
a[i].push_back(PA(t.second,t.first+t.second));
}
}
}
int main()
{
//freopen("tt.in","r",stdin);
init();
scanf("%d",&Q);
while(Q--)
{
ll x,y,ans=0;
scanf("%lld%lld",&x,&y);
if(x>y)swap(x,y);
if(x==1)
{
printf("1 %lld\n",y%mod);
continue;
}
if(x==2&&y==2)
{
puts("1 4");
continue;
}
int k=upper_bound(f+1,f+90+1,x)-f;
k=min(k,(int)upper_bound(f+1,f+90+1,y)-f-1);
for(int i=0;i<a[k-1].size();i++)
{
PA t=a[k-1][i];
if(t.second<=x)
{
ans+=(y-t.first)/t.second;
ans+=(x-t.first)/t.second;
}
}
printf("%d %lld\n",k-1,ans%mod);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:47:25: error: cast from 'long long int*' to 'int' loses precision [-fpermissive]
47 | k=min(k,(int)upper_bound(f+1,f+90+1,y)-f-1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:47:55: error: invalid operands of types 'int' and 'long long int [110]' to binary 'operator-'
47 | k=min(k,(int)upper_bound(f+1,f+90+1,y)-f-1);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
| | |
| int long long int [110]
|
s133045754 | p03710 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PA pair<ll,ll>
const int mod = 1000000007;
vector<PA >a[110];
ll f[110];
int Q;
void init()
{
a[1].push_back(PA(1,1));
f[0]=f[1]=1;
for(int i=2;i<=90;i++)
f[i]=f[i-1]+f[i-2];
for(int i=2;i<90;i++)
{
a[i].push_back(PA(f[i-1],f[i]));
a[i].push_back(PA(f[i-1],f[i+1]));
for(int j=1;j<a[i-1].size();j++)
{
PA t=a[i-1][j];
a[i].push_back(PA(t.second,t.first+t.second));
}
}
}
int main()
{
//freopen("tt.in","r",stdin);
init();
scanf("%d",&Q);
while(Q--)
{
ll x,y,ans=0;
scanf("%lld%lld",&x,&y);
if(x>y)swap(x,y);
if(x==1)
{
printf("1 %lld\n",y%mod);
continue;
}
if(x==2&&y==2)
{
puts("1 4");
continue;
}
int k=upper_bound(f+1,f+90+1,x)-f;
k=min(k,upper_bound(f+1,f+90+1,y)-f-1);
for(int i=0;i<a[k-1].size();i++)
{
PA t=a[k-1][i];
if(t.second<=x)
{
ans+=(y-t.first)/t.second;
ans+=(x-t.first)/t.second;
}
}
printf("%d %lld\n",k-1,ans%mod);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:47:22: error: no matching function for call to 'min(int&, long int)'
47 | k=min(k,upper_bound(f+1,f+90+1,y)-f-1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:47:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
47 | k=min(k,upper_bound(f+1,f+90+1,y)-f-1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:47:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
47 | k=min(k,upper_bound(f+1,f+90+1,y)-f-1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.