submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s393443599 | p03857 | C++ | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
namespace std {
bool operator<(const P& a, const P& b) {
return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}
}
int uf1[200010], uf2[200010];
int find(int x, int uf[]) {
if(uf[x] == x) return x;
else return find(uf[x], uf);
}
void unite(int a, int b, int uf[]) {
if(uf[a] == uf[b]) return;
uf[b] = find(a, uf);
}
signed main() {
int n, k, l; cin >> n >> k >> l;
iota(uf1, uf1+n, 0);
iota(uf2, uf2+n, 0);
rep(i,0,k) {
int p, q; cin >> p >> q;
p--; q--;
unite(p, q, uf1);
}
rep(i,0,l) {
int r, s; cin >> r >> s;
r--; s--;
unite(r, s, uf2);
}
map<pii, int> m;
rep(i,0,n) {
int f1 = find(i, uf1);
int f2 = find(i, uf2);
pii temp = pii(f1, f2);
if(!m.count(temp)) m[temp] = 1;
else m[temp] += 1;
}
rep(i,0,n) {
int f1 = find(i, uf1);
int f2 = find(i, uf2);
int ret = m[ pii(f1, f2) ];
if(i == 0) printf("%lld", ret);
else printf(" %lld", ret);
}
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:76:5: error: 'iota' was not declared in this scope
76 | iota(uf1, uf1+n, 0);
| ^~~~
|
s266298575 | p03857 | C++ | def inp() a=gets.chomp.split(" ").map(&:to_i)end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b = na(a.max+1); a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def saiki(d,i,now,dd,j)
return if(dd[i] == now) if(j == 0)
dd[i] = now
d[i].each do|t|
saiki(d,t,now,dd,0)
end
end
h = {}
n,k,l = inp
dk = na2(n+1,0)
da = na(n+1)
dl = na2(n+1,0)
db = na(n+1)
(n+1).times do |i|
da[i] = i
db[i] = i
end
(k).times do |i|
d = inp
dk[d[0]].push(d[1])
dk[d[1]].push(d[0])
end
(l).times do |i|
d = inp
dl[d[0]].push(d[1])
dl[d[1]].push(d[0])
end
(n+1).times do |i|
if(da[i] == i)
saiki(dk,i,i,da,1)
end
end
(n+1).times do |i|
if(db[i] == i)
saiki(dl,i,i,db,1)
end
end
h ={}
(1..n).each do |i|
h[[da[i],db[i]]] = 0 if(h[[da[i],db[i]]] == nil)
h[[da[i],db[i]]] += 1
end
(1..n-1).each do |i|
print "#{h[[da[i],db[i]]]} "
end
puts h[[da[n],db[n]]]
=begin
max = c if max < c
=end | a.cc:5:28: error: too many decimal points in number
5 | def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
| ^~~~
a.cc:48:2: error: too many decimal points in number
48 | (1..n).each do |i|
| ^~~~
a.cc:52:2: error: too many decimal points in number
52 | (1..n-1).each do |i|
| ^~~~
a.cc:1:1: error: 'def' does not name a type
1 | def inp() a=gets.chomp.split(" ").map(&:to_i)end
| ^~~
a.cc:6:32: error: 'a' does not name a type
6 | def scount(a) b = na(a.max+1); a.each{|n|b[n]+=1};return b end
| ^
a.cc:6:51: error: expected unqualified-id before 'return'
6 | def scount(a) b = na(a.max+1); a.each{|n|b[n]+=1};return b end
| ^~~~~~
a.cc:8:46: error: 'end' does not name a type
8 | def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
| ^~~
a.cc:9:62: error: 'end' does not name a type
9 | def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
| ^~~
a.cc:18:1: error: 'n' does not name a type
18 | n,k,l = inp
| ^
a.cc:48:2: error: expected unqualified-id before numeric constant
48 | (1..n).each do |i|
| ^~~~
a.cc:48:2: error: expected ')' before numeric constant
48 | (1..n).each do |i|
| ~^~~~
| )
|
s733991907 | p03857 | C++ | #include<cstdio>
#include<map>
using namespace std;
typedef pair<int,int> pp;
class UF {
public:
int par[300000]={};
UF(int n) {
for(int i=0; i<n; i++)
par[i] = i;
}
int find(int x) {
if(par[x] == x) return x;
return par[x] = find(par[x]);
}
void unite(int x, int y) {
x = find(x), y = find(y);
par[x] = y;
}
};
int main(void) {
int n,k,l;
scanf("%d%d%d",&n,&k,&l);
UF road(250000), rail(250000);
for(int i=0; i<k; i++) {
int x,y;
scanf("%d%d",&x,&y);
x--, y--;
road.unite(x,y);
}
for(int i=0; i<l; i++) {
int x,y;
scanf("%d%d",&x,&y);
x--, y--;
rail.unite(x,y);
}
map<pp,int> res;
for(int i=0; i<n; i++)
res[pp(road.find(i),rail.find(i)]++;
for(int i=0; i<n; i++) {
printf("%d%c", res[pp(road.find(i),rail.find(i))], i==n-1 ? '\n' : ' ');
}
return 0;
} | a.cc: In function 'int main()':
a.cc:43:15: error: expected primary-expression before '(' token
43 | res[pp(road.find(i),rail.find(i)]++;
| ^
a.cc:43:41: error: expected ')' before ']' token
43 | res[pp(road.find(i),rail.find(i)]++;
| ~ ^
| )
|
s646438744 | p03857 | C++ | #include<cstdio>
#include<map>
using namespace std;
typedef pair<int,int> pp;
class UF {
public:
int par[300000]={};
UF(int n) {
for(int i=0; i<n; i++)
par[i] = i;
}
int find(int x) {
if(par[x] == x) return x;
return par[x] = find(par[x]);
}
void unite(int x, int y) {
x = find(x), y = find(y);
par[x] = y;
}
};
int main(void) {
int n,k,l;
scanf("%d%d%d",&n,&k,&l);
UF road(250000), rail(250000);
for(int i=0; i<k; i++) {
int x,y;
scanf("%d%d",&x,&y);
x--, y--;
road.unite(x,y);
}
for(int i=0; i<l; i++) {
int x,y;
scanf("%d%d",&x,&y);
x--, y--;
rail.unite(x,y);
}
map<pp> res;
for(int i=0; i<n; i++)
res[pp(road.find(i),rail.find(i)]++;
for(int i=0; i<n; i++) {
printf("%d%c", res[pp(road.find(i),rail.find(i))], i==n-1 ? '\n' : ' ');
}
return 0;
} | a.cc: In function 'int main()':
a.cc:41:11: error: wrong number of template arguments (1, should be at least 2)
41 | map<pp> res;
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:2:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:43:15: error: expected primary-expression before '(' token
43 | res[pp(road.find(i),rail.find(i)]++;
| ^
a.cc:43:41: error: expected ')' before ']' token
43 | res[pp(road.find(i),rail.find(i)]++;
| ~ ^
| )
a.cc:46:27: error: no match for 'operator[]' (operand types are 'int' and 'pp' {aka 'std::pair<int, int>'})
46 | printf("%d%c", res[pp(road.find(i),rail.find(i))], i==n-1 ? '\n' : ' ');
| ^
|
s486255225 | p03857 | C++ | #include<cstdio>
#include<map>
using namespace std;
typedef pair<int,int> pp;
class UF {
public:
int par[300000]={};
UF(int n) {
for(int i=0; i<n; i++)
par[i] = i;
}
int find(int x) {
if(par[x] == x) return x;
return par[x] = find(par[x]);
}
void unite(int x, int y) {
x = find(x), y = find(y);
par[x] = y;
}
};
int main(void) {
int n,k,l;
scanf("%d%d%d",&n,&k,&l);
UF road(250000), rail(250000);
for(int i=0; i<k; i++) {
int x,y;
scanf("%d%d",&x,&y);
x--, y--;
road.unite(x,y);
}
for(int i=0; i<l; i++) {
int x,y;
scanf("%d%d",&x,&y);
x--, y--;
rail.unite(x,y);
}
map res<pp>;
for(int i=0; i<n; i++)
res[pp(road.find(i),rail.find(i)]++;
for(int i=0; i<n; i++) {
printf("%d%c", res[pp(road.find(i),rail.find(i))], i==n-1 ? '\n' : ' ');
}
return 0;
} | a.cc: In function 'int main()':
a.cc:41:12: error: expected initializer before '<' token
41 | map res<pp>;
| ^
a.cc:43:9: error: 'res' was not declared in this scope
43 | res[pp(road.find(i),rail.find(i)]++;
| ^~~
a.cc:43:15: error: expected primary-expression before '(' token
43 | res[pp(road.find(i),rail.find(i)]++;
| ^
a.cc:43:41: error: expected ')' before ']' token
43 | res[pp(road.find(i),rail.find(i)]++;
| ~ ^
| )
a.cc:46:24: error: 'res' was not declared in this scope
46 | printf("%d%c", res[pp(road.find(i),rail.find(i))], i==n-1 ? '\n' : ' ');
| ^~~
|
s320372771 | p03857 | C++ | #include <iostream>
#include <vector>
#include <map>
using namespace std;
int N,K,L;
int a[200001],b[200001],rank_a[200001],rank_b[200001];
typedef pair<int ,int > P;
void init(int x){
for(int i=0;i<x;i++){
a[i]=i;b[i]=i;
rank_a[i]=0;rank_b[i]=0;
}
}
int find(int x,int *par){
if(par[x]==x)return x;
else return find(par[x],par);
}
void unite(int x,int y,int *par,int *rank){
x=find(x,par);
y=find(y,par);
if(x==y)return ;
if(rank[x]<rank[y])par[x]=y;
else {
par[y]=x;
if(rank[x]==rank[y])rank[x]++;
}
}
bool same(int x,int y,int *par){
return find(x,par)==find(y,par);
}
int main(){
cin >> N >> K >> L;
init(N);
for(int i=0;i<K;i++){
int p,q;
cin >> p >> q;
p--;q--;
unite(p,q,a,rank_a);
}
for(int i=0;i<L;i++){
int r,s;
cin >> r >> s;
r--;s--;
unite(r,s,b,rank_b);
}
map <P,int > m;
for(int i=0;i<N;i++) m[P(find(a[i]),find(b[i]))]++;
for(int i=0;i<N;i++) cout << m[P(find(a[i]),find(b[i]))] << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:51:32: error: no matching function for call to 'find(int&)'
51 | for(int i=0;i<N;i++) m[P(find(a[i]),find(b[i]))]++;
| ~~~~^~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
15 | int find(int x,int *par){
| ^~~~
a.cc:15:5: note: candidate expects 2 arguments, 1 provided
a.cc:51:43: error: no matching function for call to 'find(int&)'
51 | for(int i=0;i<N;i++) m[P(find(a[i]),find(b[i]))]++;
| ~~~~^~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
15 | int find(int x,int *par){
| ^~~~
a.cc:15:5: note: candidate expects 2 arguments, 1 provided
a.cc:52:40: error: no matching function for call to 'find(int&)'
52 | for(int i=0;i<N;i++) cout << m[P(find(a[i]),find(b[i]))] << endl;
| ~~~~^~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
15 | int find(int x,int *par){
| ^~~~
a.cc:15:5: note: candidate expects 2 arguments, 1 provided
a.cc:52:51: error: no matching function for call to 'find(int&)'
52 | for(int i=0;i<N;i++) cout << m[P(find(a[i]),find(b[i]))] << endl;
| ~~~~^~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided
a.cc:15:5: note: candidate: 'int find(int, int*)'
15 | int find(int x,int *par){
| ^~~~
a.cc:15:5: note: candidate expects 2 arguments, 1 provided
|
s025786919 | p03857 | C++ | #include <stdio.h>
#include <vector>
class Union_Find
{
std::vector<int>per;
std::vector<int>rank;
public:
void init(int size)
{
for (int i = 0; i < size; ++i)
{
per.push_back(i);
rank.push_back(0);
}
}
int get_per(int x)
{
if (x == per[x]) { return x; }
return per[x] = get_per(per[x]);
}
bool is_same_per(int x, int y)
{
return (get_per(x) == get_per(y) ? true : false);
}
void togett(int x, int y)
{
int x_per = get_per(x), int y_per = get_per(y);
if (x_per == y_per) { return; }
if (rank[x_per] < rank[y_per])
{
per[x_per] = y_per;
}
else
{
per[y_per] = x_per;
if (rank[x_per] == rank[y_per]) { ++rank[x_per]; }
}
}
};
int N, K, L, p[112345], q[112345], r[112345], s[112345];
Union_Find railway, road;
int main()
{
scanf("%d%d%d", &N, &K, &L);
for (int i = 0; i < K; ++i) { scanf("%d%d", &p[i], &q[i]); }
for (int i = 0; i < L; ++i) { scanf("%d%d", &r[i], &s[i]); }
return 0;
} | a.cc: In member function 'void Union_Find::togett(int, int)':
a.cc:28:41: error: expected unqualified-id before 'int'
28 | int x_per = get_per(x), int y_per = get_per(y);
| ^~~
a.cc:29:30: error: 'y_per' was not declared in this scope; did you mean 'x_per'?
29 | if (x_per == y_per) { return; }
| ^~~~~
| x_per
a.cc:30:40: error: 'y_per' was not declared in this scope; did you mean 'x_per'?
30 | if (rank[x_per] < rank[y_per])
| ^~~~~
| x_per
|
s614144904 | p03857 | C++ | struct UF {
vector<int> data;
UF(int n) {
data.resize(n, -1);
}
int root(int i) {
return data[i] < 0 ? i : data[i] = root(data[i]);
}
int size(int i) {
i = root(i);
return -data[i];
}
void unite(int x, int y) {
x = root(x), y = root(y);
if (x == y) return;
if (size(x) < size(y)) swap(x, y);
data[x] += data[y];
data[y] = x;
}
bool same(int x, int y) {
return root(x) == root(y);
}
};
| a.cc:2:5: error: 'vector' does not name a type
2 | vector<int> data;
| ^~~~~~
a.cc: In constructor 'UF::UF(int)':
a.cc:4:9: error: 'data' was not declared in this scope
4 | data.resize(n, -1);
| ^~~~
a.cc: In member function 'int UF::root(int)':
a.cc:7:16: error: 'data' was not declared in this scope
7 | return data[i] < 0 ? i : data[i] = root(data[i]);
| ^~~~
a.cc: In member function 'int UF::size(int)':
a.cc:11:17: error: 'data' was not declared in this scope
11 | return -data[i];
| ^~~~
a.cc: In member function 'void UF::unite(int, int)':
a.cc:16:32: error: 'swap' was not declared in this scope
16 | if (size(x) < size(y)) swap(x, y);
| ^~~~
a.cc:17:9: error: 'data' was not declared in this scope
17 | data[x] += data[y];
| ^~~~
|
s720985197 | p03857 | C | #include <stdio.h>
#include <stdlib.h>
#define EMPTY 0
#define NOTEMPTY 1
typedef struct node{
int n;
struct node *next;
}node;
char *graph;
int empty(node *q);
int dequeue(node *q);
void enqueue(node *q, int n);
void check_connect(char *g, int *r, const int n, const int t);
int main(void){
int n, k, l;
int p, q;
int i, j;
int *ar, *br, *cnt, ans;
scanf("%d %d %d", &n, &k, &l);
for(i=0; i<k; i++){
scanf("%d %d", &p, &q);
graph[p][q] = 1;
//printf("conncted %d and %d with path.\n", p ,q);
}
for(i=0; i<l; i++){
scanf("%d %d", &p, &q);
graph[p][q] += 2;
//printf("connected %d and %d with train.\n", p, q);
}
/*for(i=1; i<=n; i++){
for(j=1; j<=n; j++){
printf("%d ", graph[i][j]);
}
printf("\n");
}*/
graph = (char *)malloc(sizeof(char)*(n+1)*(n+1));
ar = (int *)malloc(sizeof(int)*(n+1));
br = (int *)malloc(sizeof(int)*(n+1));
cnt = (int *)malloc(sizeof(int)*(n+1));
for(i=1; i<=n; i++){
ar[i] = -1;
br[i] = -1;
cnt[i] = 0;
}
check_connect(graph, br, n, 2);
for(i=0; i<=n; i++){
for(j=0; j<=n; j++){
if(graph[i][j] >= 2) graph[i][j] -=2;
}
}
check_connect(graph, ar, n, 1);
for(i=1; i<=n; i++){
for(j=1; j<=n; j++){
if((ar[i] == ar[j]) && (br[i] == br[j])) cnt[i]++;
}
}
for(i=1; i<=n; i++){
printf("%d ", cnt[i]);
}
printf("\n");
return 0;
}
int empty(node *q){
if(q->next == NULL) return EMPTY;
return NOTEMPTY;
}
node* init_queue(){
node *np;
np = (node *)malloc(sizeof(node));
np->next = NULL;
return np;
}
int dequeue(node *q){
node *np;
int n;
if(empty(q) == EMPTY) return 0;
np = q->next;
q->next = q->next->next;
n = np->n;
return n;
}
void enqueue(node *q, int n){
node *np;
np = (node*)malloc(sizeof(node));
np->n = n;
np->next = NULL;
while(q->next != NULL) q = q->next;
q->next = np;
}
void check_connect(char *g, int *r, const int n, const int t){
int cnum;
node *cnct, *set;
int i, j;
cnct = init_queue();
set = init_queue();
for(i=1; i<=n; i++){
if(r[i] != -1) continue;
enqueue(set, i);
while(empty(set) != EMPTY){
cnum=dequeue(set);
//printf("checking connection with %d.\n", cnum);
enqueue(cnct, cnum);
for(j=cnum; j<=n; j++){
if(g(cnum*n+j) >= t){
enqueue(set, j);
//printf("%d is connected.\n", j);
}
}
}
while(empty(cnct) != EMPTY){
cnum = dequeue(cnct);
r[cnum] = i;
}
}
} | main.c: In function 'main':
main.c:28:25: error: subscripted value is neither array nor pointer nor vector
28 | graph[p][q] = 1;
| ^
main.c:33:25: error: subscripted value is neither array nor pointer nor vector
33 | graph[p][q] += 2;
| ^
main.c:54:36: error: subscripted value is neither array nor pointer nor vector
54 | if(graph[i][j] >= 2) graph[i][j] -=2;
| ^
main.c:54:54: error: subscripted value is neither array nor pointer nor vector
54 | if(graph[i][j] >= 2) graph[i][j] -=2;
| ^
main.c: In function 'check_connect':
main.c:127:36: error: called object 'g' is not a function or function pointer
127 | if(g(cnum*n+j) >= t){
| ^
main.c:111:26: note: declared here
111 | void check_connect(char *g, int *r, const int n, const int t){
| ~~~~~~^
|
s213160157 | p03857 | C++ | #include<cstdio>
#include<map>
#include<cstring>
#define mp make_pair
#define Maxn 200010
using namespace std;
typedef pair<int,int> pii;
int N,K,L;
map<pii,int> sz;
int par[Maxn*2],rank[Maxn*2];
int num[Maxn];
void init(int n)
{
for(int i=1;i<=2*n;i++)
{
par[i] = i;
rank[i] = 0;
}
memset(num,0,sizeof num);
}
int find(int x)
{
if(par[x] == x)
return x;
return par[x] = find(par[x]);
}
void unite(int x,int y)
{
x = find(x);
y = find(y);
if(x == y)
return ;
if(rank[x] < rank[y])
par[x] = y;
else
{
par[y] = x;
if(rank[x] == rank[y])
rank[x]++;
}
}
bool same(int x,int y)
{
return find(x) == find(y);
}
int main()
{
while(~scanf("%d%d%d",&N,&K,&L))
{
init(N);
int a,b;
for(int i=1;i<=K;i++)
{
scanf("%d%d",&a,&b);
unite(a,b);
}
for(int i=1;i<=L;i++)
{
scanf("%d%d",&a,&b);
// if(same(a,b))
{
unite(a+N,b+N);
}
}
for(int i=1;i<=N;i++)
sz[mp(find(i),find(i+N))]++;
/* for(int i=N+1;i<=2*N;i++)
{
find(i);
num[par[i]-N]++;
}
for(int i=N+1;i<=2*N;i++)
{
if(par[i]!=i)
num[i-N] = num[par[i]-N];
}*/
for(int i=1;i<=N;i++)
{
printf("%d",sz[mp(find(i),find(i+N))]);
if(i!=N)
printf(" ");
}
printf("\n");
}
return 0;
} | a.cc: In function 'void init(int)':
a.cc:17:17: error: reference to 'rank' is ambiguous
17 | rank[i] = 0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/bits/stl_tree.h:63,
from /usr/include/c++/14/map:62,
from a.cc:2:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:10:17: note: 'int rank [400020]'
10 | int par[Maxn*2],rank[Maxn*2];
| ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:35:12: error: reference to 'rank' is ambiguous
35 | if(rank[x] < rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:10:17: note: 'int rank [400020]'
10 | int par[Maxn*2],rank[Maxn*2];
| ^~~~
a.cc:35:22: error: reference to 'rank' is ambiguous
35 | if(rank[x] < rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:10:17: note: 'int rank [400020]'
10 | int par[Maxn*2],rank[Maxn*2];
| ^~~~
a.cc:40:20: error: reference to 'rank' is ambiguous
40 | if(rank[x] == rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:10:17: note: 'int rank [400020]'
10 | int par[Maxn*2],rank[Maxn*2];
| ^~~~
a.cc:40:31: error: reference to 'rank' is ambiguous
40 | if(rank[x] == rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:10:17: note: 'int rank [400020]'
10 | int par[Maxn*2],rank[Maxn*2];
| ^~~~
a.cc:41:17: error: reference to 'rank' is ambiguous
41 | rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:10:17: note: 'int rank [400020]'
10 | int par[Maxn*2],rank[Maxn*2];
| ^~~~
|
s245654727 | p03857 | C++ | //#include "IntMod.h"
//typedef IntMod<1000000007> MInt;
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
class UnionFindTree {
int whole_size_m;
int* parent_p_m; // 根である場合は自分自身の添え字を入れる
int* rank_p_m;
int* size_p_m; // 集合のサイズ(根に大きさを書く)
bool Is_valid_index(int index);
int Root_of_rec(int index);
public:
UnionFindTree(int whole_size);
~UnionFindTree();
int Root_of(int index);
void Unite(int index_l, int index_r);
bool Are_together(int index_l, int index_r);
int Size_of_set(int index);
};
bool UnionFindTree::Is_valid_index(int index) {
return index >= 0 && index < whole_size_m;
}
int UnionFindTree::Root_of_rec(int index) {
if (parent_p_m[index] == index) {
return index;
} else {
return parent_p_m[index] = Root_of_rec(parent_p_m[index]);
}
}
UnionFindTree::UnionFindTree(int whole_size)
: whole_size_m(whole_size) {
parent_p_m = new int[whole_size_m];
rank_p_m = new int[whole_size_m];
size_p_m = new int[whole_size_m];
for (int i = 0; i < whole_size_m; ++i) {
parent_p_m[i] = i;
rank_p_m[i] = 1;
size_p_m[i] = 1;
}
}
UnionFindTree::~UnionFindTree() {
delete[] parent_p_m;
delete[] rank_p_m;
delete[] size_p_m;
}
int UnionFindTree::Root_of(int index) {
if (Is_valid_index(index) == false) return -1;
return Root_of_rec(index);
}
void UnionFindTree::Unite(int index_l, int index_r) {
if (Is_valid_index(index_l) == false || Is_valid_index(index_r) == false) return;
int root_l = Root_of(index_l);
int root_r = Root_of(index_r);
if (root_l == root_r) return;
if (rank_p_m[root_l] > rank_p_m[root_r]) {
parent_p_m[root_r] = root_l;
size_p_m[root_r] += root_l;
} else {
parent_p_m[root_l] = root_r;
size_p_m[root_l] += root_r;
if (rank_p_m[root_l] == rank_p_m[root_r]) ++rank_p_m[root_r];
}
}
bool UnionFindTree::Are_together(int index_l, int index_r) {
return rank_p_m[index_l] == rank_p_m[index_r];
}
int UnionFindTree::Size_of_set(int index) {
return size_p_m[index];
}
int N, K, L;
multimap<PP, int> M;
int main() {
cin >> N >> K >> L;
UnionFindTree Ur(N);
UnionFindTree Ut(N);
REP(i, 0, K) {
int buf1, buf2;
cin >> buf1 >> buf2;
Ur.Unite(buf1 - 1, buf2 - 1);
}
REP(i, 0, L) {
int buf1, buf2;
cin >> buf1 >> buf2;
Ut.Unite(buf1 - 1, buf2 - 1);
}
REP(i, 0, N) {
M.insert(make_pair(PP(Ur.Root_of(i), Ut.Root_of(i)), i));
}
volatile int a = M.count(PP(Ur.Root_of(i), Ut.Root_of(i)));
return 0;
} | a.cc: In function 'int main()':
a.cc:127:48: error: 'i' was not declared in this scope
127 | volatile int a = M.count(PP(Ur.Root_of(i), Ut.Root_of(i)));
| ^
|
s967377272 | p03857 | C++ | //#include "IntMod.h"
//typedef IntMod<1000000007> MInt;
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
class UnionFindTree {
int whole_size_m;
int* parent_p_m; // 根である場合は自分自身の添え字を入れる
int* rank_p_m;
int* size_p_m; // 集合のサイズ(根に大きさを書く)
bool Is_valid_index(int index);
int Root_of_rec(int index);
public:
UnionFindTree(int whole_size);
~UnionFindTree();
int Root_of(int index);
void Unite(int index_l, int index_r);
bool Are_together(int index_l, int index_r);
int Size_of_set(int index);
};
#include "Union_Find.h"
bool UnionFindTree::Is_valid_index(int index) {
return index >= 0 && index < whole_size_m;
}
int UnionFindTree::Root_of_rec(int index) {
if (parent_p_m[index] == index) {
return index;
} else {
return parent_p_m[index] = Root_of_rec(parent_p_m[index]);
}
}
UnionFindTree::UnionFindTree(int whole_size)
: whole_size_m(whole_size) {
parent_p_m = new int[whole_size_m];
rank_p_m = new int[whole_size_m];
size_p_m = new int[whole_size_m];
for (int i = 0; i < whole_size_m; ++i) {
parent_p_m[i] = i;
rank_p_m[i] = 1;
size_p_m[i] = 1;
}
}
UnionFindTree::~UnionFindTree() {
delete[] parent_p_m;
delete[] rank_p_m;
delete[] size_p_m;
}
int UnionFindTree::Root_of(int index) {
if (Is_valid_index(index) == false) return -1;
return Root_of_rec(index);
}
void UnionFindTree::Unite(int index_l, int index_r) {
if (Is_valid_index(index_l) == false || Is_valid_index(index_r) == false) return;
int root_l = Root_of(index_l);
int root_r = Root_of(index_r);
if (root_l == root_r) return;
if (rank_p_m[root_l] > rank_p_m[root_r]) {
parent_p_m[root_r] = root_l;
size_p_m[root_r] += root_l;
} else {
parent_p_m[root_l] = root_r;
size_p_m[root_l] += root_r;
if (rank_p_m[root_l] == rank_p_m[root_r]) ++rank_p_m[root_r];
}
}
bool UnionFindTree::Are_together(int index_l, int index_r) {
return rank_p_m[index_l] == rank_p_m[index_r];
}
int UnionFindTree::Size_of_set(int index) {
return size_p_m[index];
}
int N, K, L;
multimap<PP, int> M;
int main() {
cin >> N >> K >> L;
UnionFindTree Ur(N);
UnionFindTree Ut(N);
REP(i, 0, K) {
int buf1, buf2;
cin >> buf1 >> buf2;
Ur.Unite(buf1 - 1, buf2 - 1);
}
REP(i, 0, L) {
int buf1, buf2;
cin >> buf1 >> buf2;
Ut.Unite(buf1 - 1, buf2 - 1);
}
REP(i, 0, N) {
M.insert(make_pair(PP(Ur.Root_of(i), Ut.Root_of(i)), i));
}
REP(i, 0, N) {
cout << M.count(PP(Ur.Root_of(i), Ut.Root_of(i))) << (i == N - 1 ? ' ' : '\n');
}
return 0;
} | a.cc:48:10: fatal error: Union_Find.h: No such file or directory
48 | #include "Union_Find.h"
| ^~~~~~~~~~~~~~
compilation terminated.
|
s723907006 | p03857 | C++ | #include <stdio.h>
typedef struct Item {
struct Item *next;
int to;
} Item;
#define MAX_NODE (200000)
Item *train[MAX_NODE] = {0}, *road[MAX_NODE] = {0};
int parent[MAX_NODE], sizes[MAX_NODE] = {0};
int setted[MAX_NODE] = {0}, resetted[MAX_NODE] = {0};
int ans[MAX_NODE] = {0};
void add(Item* list[], int from, int to){
Item *p = (Item*)malloc(sizeof(Item));
p->next = list[from];
p->to = to;
list[from] = p;
}
void setParent(int p, int n){
Item *it;
int next;
for(it=road[n]; it!=NULL; it=it->next){
next = it->to;
if(parent[next]!=next || p==next){ continue; }
parent[next] = p;
setParent(p, next);
}
}
void setSize(int n){
Item *it;
int next;
setted[n] = 1;
sizes[parent[n]]++;
for(it=train[n]; it!=NULL; it=it->next){
next = it->to;
if(setted[next]){ continue; }
setSize(next);
}
}
void getSize(int n){
Item *it;
int next;
ans[n] = sizes[parent[n]];
for(it=train[n]; it!=NULL; it=it->next){
next = it->to;
if(ans[next]){ continue; }
getSize(next);
}
}
void resetSize(int n){
Item *it;
int next;
resetted[n] = 1;
sizes[parent[n]] = 0;
for(it=train[n]; it!=NULL; it=it->next){
next = it->to;
if(resetted[next]){ continue; }
resetSize(next);
}
}
int main(void){
int i, j;
int N, K, L, from, to;
scanf("%d%d%d", &N, &K, &L);
for(i=0;i<N;i++){
parent[i] = i;
}
for(i=0;i<K;i++){
scanf("%d%d", &from, &to); from--; to--;
add(road, from, to);
add(road, to, from);
}
for(i=0;i<N;i++){ if(parent[i]==i){ setParent(i, i); } }
for(i=0;i<L;i++){
scanf("%d%d", &from, &to); from--; to--;
add(train, from, to);
add(train, to, from);
}
for(i=0;i<N;i++){
if(ans[i]){ continue; }
setSize(i);
getSize(i);
resetSize(i);
}
printf("%d", ans[0]);
for(i=1;i<N;i++){
printf(" %d", ans[i]);
}
puts("");
return 0;
} | a.cc: In function 'void add(Item**, int, int)':
a.cc:14:26: error: 'malloc' was not declared in this scope
14 | Item *p = (Item*)malloc(sizeof(Item));
| ^~~~~~
a.cc:2:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
1 | #include <stdio.h>
+++ |+#include <cstdlib>
2 |
|
s384910693 | p03857 | C++ | #include <bits/stdc++.h>
using namespace std;
// why am I so weak
int n, k, l;
int par[2][200055];
typedef pair<int, int> P;
map<p, int> c;
int fin(int i, int j) {
if (par[i][j] == j) return j;
return par[i][j] = fin(i, par[i][j]);
}
int main() {
scanf("%d %d %d", &n, &k, &l);
for (int i = 0; i < n; i++) {
par[0][i] = par[1][i] = i;
}
while (k--) {
int x, y;
scanf("%d %d", &x, &y);
x--, y--;
par[0][fin(0, x)] = fin(0, y);
}
while (l--) {
int x, y;
scanf("%d %d", &x, &y);
x--, y--;
par[1][fin(1, x)] = fin(1, y);
}
for (int i = 0; i < n; i++) c[P(fin(0, i), fin(1, i))]++;
for (int i = 0; i < n; i++) {
if (i) printf(" ");
printf("%d", c[P(fin(0, i), fin(1, i))]);
}
puts("");
return 0;
}
| a.cc:11:5: error: 'p' was not declared in this scope
11 | map<p, int> c;
| ^
a.cc:11:11: error: template argument 1 is invalid
11 | map<p, int> c;
| ^
a.cc:11:11: error: template argument 3 is invalid
a.cc:11:11: error: template argument 4 is invalid
a.cc: In function 'int main()':
a.cc:41:38: error: no match for 'operator[]' (operand types are 'int' and 'P' {aka 'std::pair<int, int>'})
41 | for (int i = 0; i < n; i++) c[P(fin(0, i), fin(1, i))]++;
| ^
a.cc:45:31: error: no match for 'operator[]' (operand types are 'int' and 'P' {aka 'std::pair<int, int>'})
45 | printf("%d", c[P(fin(0, i), fin(1, i))]);
| ^
|
s421471721 | p03857 | C++ | copy
#include<bits/stdc++.h>
#define pi pair<int,int>
#define mp make_pair
//#define int long long
#define endl '\n'
using namespace std;
int n,k,l;
int idrd[(int)2.1e5],idral[(int)2.1e5];
void initialize()
{
for(int i = 1;i <= n;++i)
idrd[i] = i,idral[i]=i;
}
int rootroad(int x)
{
while(idrd[x] != x)
{
idrd[x] = idrd[idrd[x]];
x = idrd[x];
}
return x;
}
int rootrail(int x)
{
while(idral[x] != x)
{
idral[x] = idral[idral[x]];
x = idral[x];
}
return x;
}
void unionrd(int x, int y)
{
int p = rootroad(x);
int q = rootroad(y);
idrd[p] = idrd[q];
}
void unionrail(int x, int y)
{
int p = rootrail(x);
int q = rootrail(y);
idral[p] = idral[q];
}
set< pair<pi,int> > s;
int ans[200005];
main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>k>>l;
int x,y;
initialize();
for(int i=0;i<k;++i)
{
cin>>x>>y;
unionrd(x,y);
}
for(int i=0;i<l;++i)
{
cin>>x>>y;
unionrail(x,y);
}
for(int i=1;i<=n;++i)
{
pair<pi,int> xp= mp(mp(rootrail(i),rootroad(i)) , i);
s.insert(xp);
}
for(int i=1;i<=n;++i)
{
pi xp= mp(rootrail(i),rootroad(i));
int a1=distance(s.begin(),s.lower_bound(mp(xp,0)));
int a2=distance(s.begin(),s.upper_bound(mp(xp,312345)));
//cout<<i<<" "<<a1<<" "<<a2<<endl;
cout<<a2-a1<<" ";
}
return 0;
} | a.cc:1:1: error: 'copy' does not name a type
1 | copy
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/incl |
s144444449 | p03857 | C++ | int main()
{
int N, K, L;
cin >> N >> K >> L;
/* vector<int> pre_road(N + 1);
vector<int> pre_railway(N + 1);
for (int i = 1; i <= N; i++)
{
pre_road[i] = i;
pre_railway[i] = i;
}*/
unordered_map<int, unordered_set<int>> roads;
unordered_map<int, unordered_set<int>> railways;
for (int i = 0; i < K; i++)
{
int a, b;
cin >> a >> b;
for (auto t : roads[a])
{
roads[b].insert(t);
roads[t].insert(b);
}
for (auto t : roads[b])
{
roads[a].insert(t);
roads[t].insert(a);
}
roads[a].insert(b);
roads[b].insert(a);
}
//BuildCon(roads, N);
for (int i = 0; i < L; i++)
{
int a, b;
cin >> a >> b;
for (auto t : railways[a])
{
railways[b].insert(t);
railways[t].insert(b);
}
for (auto t : railways[b])
{
railways[a].insert(t);
railways[t].insert(a);
}
railways[a].insert(b);
railways[b].insert(a);
}
//BuildCon(railways, N);
for (int i = 1; i <= N; i++)
{
roads[i].insert(i);
railways[i].insert(i);
int count = 0;
for (auto t : roads[i])
{
if (railways[i].find(t) != railways[i].end())
count++;
}
cout << count;
if (i != N)
cout << " ";
else
cout << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:4:9: error: 'cin' was not declared in this scope
4 | cin >> N >> K >> L;
| ^~~
a.cc:12:9: error: 'unordered_map' was not declared in this scope
12 | unordered_map<int, unordered_set<int>> roads;
| ^~~~~~~~~~~~~
a.cc:12:23: error: expected primary-expression before 'int'
12 | unordered_map<int, unordered_set<int>> roads;
| ^~~
a.cc:13:23: error: expected primary-expression before 'int'
13 | unordered_map<int, unordered_set<int>> railways;
| ^~~
a.cc:18:31: error: 'roads' was not declared in this scope
18 | for (auto t : roads[a])
| ^~~~~
a.cc:23:31: error: 'roads' was not declared in this scope
23 | for (auto t : roads[b])
| ^~~~~
a.cc:28:17: error: 'roads' was not declared in this scope
28 | roads[a].insert(b);
| ^~~~~
a.cc:36:31: error: 'railways' was not declared in this scope
36 | for (auto t : railways[a])
| ^~~~~~~~
a.cc:41:31: error: 'railways' was not declared in this scope
41 | for (auto t : railways[b])
| ^~~~~~~~
a.cc:46:17: error: 'railways' was not declared in this scope
46 | railways[a].insert(b);
| ^~~~~~~~
a.cc:52:17: error: 'roads' was not declared in this scope
52 | roads[i].insert(i);
| ^~~~~
a.cc:53:17: error: 'railways' was not declared in this scope
53 | railways[i].insert(i);
| ^~~~~~~~
a.cc:60:17: error: 'cout' was not declared in this scope; did you mean 'count'?
60 | cout << count;
| ^~~~
| count
a.cc:64:33: error: 'endl' was not declared in this scope
64 | cout << endl;
| ^~~~
|
s568085922 | p03857 | C++ | #include<bits/stdc++.h>
using namespace std;
struct Union{
vector<int> r,p;
Union(int size){init(size);}
void init(int size){
r.resize(size);
p.resize(size);
for(int i=0;i<size;i++) r[i]=1,p[i]=i;
}
int find(int x){
if(x!=p[x]) p[x]=find(p[x]);
return p[x];
}
bool same(int x,int y){
return find(x)==find(y);
}
void unite(int x,int y){
x=find(x);y=find(y);
if(x==y) return;
if(r[x]<r[y]) swap(x,y);
r[x]+=r[y];
p[y]=x;
}
};
typedef pair<int,int> P;
int main(){
int n,k,l,i,j,p,q;
cin>>n>>k>>l;
Union u1(n+1),u2(n+1);
vector<P> v;
for(i=0;i<k;i++){
cin>>p>>q;
v.push_back(P(p,q));
u1.unite(p,q);
}
for(i=0;i<l;i++){
cin>>p>>q;
v.push_back(P(p,q));
u2.unite(p,q);
}
map<P> mp;
for(i=1;i<=n;i++){
mp[P(u1.find(i),u2.find(i))]++;
}
for(i=1;i<=n;i++) cout << mp[P(u1.find(i),u2.find(i))] << " \n"[i==n];
return 0;
}
| a.cc: In function 'int main()':
a.cc:42:8: error: wrong number of template arguments (1, should be at least 2)
42 | map<P> mp;
| ^
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:44:7: error: no match for 'operator[]' (operand types are 'int' and 'P' {aka 'std::pair<int, int>'})
44 | mp[P(u1.find(i),u2.find(i))]++;
| ^
a.cc:46:31: error: no match for 'operator[]' (operand types are 'int' and 'P' {aka 'std::pair<int, int>'})
46 | for(i=1;i<=n;i++) cout << mp[P(u1.find(i),u2.find(i))] << " \n"[i==n];
| ^
|
s754931436 | p03857 | C++ | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//constants
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = 1<<28;
struct edge { int to, cost; };
typedef pair<int, int> P;
vector< vector<edge> > G1;
vector< vector<edge> > G2;
vector<int> d;
void dijkstra(int s, int N, vector< vector<edge> > G) {
priority_queue<P, vector<P>, greater<P> > que;
d.resize(N, INF);
REP(i, N)
d[i] = INF;
d[s] = 0;
que.push(P(0, s));
//cout << "D" << endl;
while (!que.empty()) {
P p = que.top(); que.pop();
//cout << p.second << " " << p.first << endl;
int v = p.second;
if (d[v] < p.first) continue;
for (int i = 0; i < G[v].size(); i++) {
edge e = G[v][i];
//cout << "UPDATE * " << v << " TO " << e.to << " " << d[e.to] << " " << d[v]+e.cost << endl;
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
//cout << "DEND" << endl;
}
int main(int argc, char **argv) {
int N, K, L;
cin >> N >> K >> L;
G1.resize(N);
G2.resize(N);
REP(i, K){
int f, t;
cin >> f >> t;
edge e1 = {t-1, 1};
edge e2 = {f-1, 1};
G1[f-1].push_back(e1);
G1[t-1].push_back(e2);
}
REP(i, L){
int f, t;
cin >> f >> t;
edge e1 = {t-1, 1};
edge e2 = {f-1, 1};
G2[f-1].push_back(e1);
G2[t-1].push_back(e2);
}
//cout << "HOGE" << endl;
//REP(i, N){
// cout << i << endl;
// REP(j, G1[i].size()){
// cout << " " << G1[i][j].to << endl;
// }
//}
//cout << "HOGE" << endl;
//REP(i, N){
// cout << i << endl;
// REP(j, G2[i].size()){
// cout << " " << G2[i][j].to << endl;
// }
//}
//cout << "HOGE" << endl;
vector < vector <int> > ans1;
ans1.resize(N);
REP(i, N)
ans1[i].resize(N, INF);
REP(i, N){
dijkstra(i, N, G1);
REP(j, N)
ans1[i][j] = d[j];
cout << i << endl;
REP(j, N)
cout << " " << d[j] << endl;
}
vector < vector<int> > ans2;
ans2.resize(N);
REP(i, N)
ans2[i].resize(N, INF);
REP(i, N){
dijkstra(i, N, G2);
REP(j, N)
ans2[i][j] = d[j];
cout << i << endl;
REP(j, N)
cout << " " << d[j] << endl;
}
REP(i, N)
REP(j, N)
if (ans1[i][j] != INF && ans2[i][j] != INF)
ans[i]++;
vector<int> ans;
ans.resize(N, 0);
REP(i, N)
cout << ans[i] << " ";
cout << endl;
return 0;
}
| a.cc: In function 'int main(int, char**)':
a.cc:134:13: error: 'ans' was not declared in this scope; did you mean 'ans2'?
134 | ans[i]++;
| ^~~
| ans2
|
s130487921 | p03857 | C++ | #include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
/*** UnionFindクラス ***/
class UnionFind {
private:
//uni[i]<0ならばiが親,そうでなければfind(uni[i])が親
vector<int> uni;
//グループ数
int SIZE;
public:
UnionFind(int size) {
//初期状態では全ノード-1に設定し,よってすべてが親
this->uni.resize(size, -1);
this->SIZE = size;
}
UnionFind() {}
void resize(int size) {
this->uni.resize(size, -1);
this->SIZE = size;
}
//xの親を返す
int find(int x) {
//uni[x]<0なのでxは親
if (uni[x] < 0) return x;
//uni[x]に親ノードを入れることで連続での探索時間の短縮
return uni[x] = find(uni[x]);
}
//xとyが同じグループならばtrue
bool same(int x, int y) {
//xとyの親が同じならば同じグループに属するといえる
return find(x) == find(y);
}
//xとyがそれぞれ属するグループを併合
//併合処理を行ったならばtrueを返す
//xとyがもともと同じグループならばfalseを返す
bool unite(int x, int y) {
x = find(x); y = find(y);
if (x == y) return false;
//木の深さが小さいノードから大きいノードへ辺をはる
if (uni[x] > uni[y]) swap(x, y);
//yのグループをxに足す
uni[x] += uni[y];
//yの親をxとする
uni[y] = x;
this->SIZE--;
return true;
}
//グループ数を返す
int size() {
return this->SIZE;
}
//xが属するグループのノード数を返す
int size(int x) {
return -uni[find(x)];
}
};
const int MAX = (2 * 1e5)+5;
int N, K, L;
//VVI graph2;
VI graph2[MAX];
UnionFind uf(MAX);
VI cnt;
int cnt[MAX];
int dfs(int now, int prev) {
if (cnt[now] != -1) return cnt[now];
int res = 0;
int cc = 0;
FORE(e, graph2[now]) {
if (!uf.same(now, e)) continue;
if (e == prev) {
cc++;
continue;
}
res += dfs(e, now);
}
return cnt[now] = res + cc;
}
int main(void) {
scanf("%d%d%d", &N, &K, &L);
REP(i, K) {
int a, b;
scanf("%d%d", &a, &b);
a--;b--;
uf.unite(a, b);
}
REP(i, L) {
int a, b;
scanf("%d%d", &a, &b);
a--;b--;
graph2[a].EB(b);
graph2[b].EB(a);
}
REP(i, N) cnt[i] = -1;
REP(i, N) dfs(i, -1);
REP(i, N) {
printf("%d", cnt[i] != -1 ? cnt[i] + 1: 1);
if (i != N - 1) printf(" ");
}
printf("\n");
}
| a.cc:129:5: error: conflicting declaration 'int cnt [200005]'
129 | int cnt[MAX];
| ^~~
a.cc:128:4: note: previous declaration as 'VI cnt'
128 | VI cnt;
| ^~~
|
s204049291 | p03857 | C++ | // D_Connectivity.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<unordered_map>
#include<unordered_set>
#include<iostream>
using namespace std;
void BuildCon(unordered_map<int, unordered_set<int>>& paths, int n)
{
for (int k = 1; k <= n; k++)
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n && j != i; j++)
{
if (paths[i].find(k) != paths[i].end() && paths[k].find(j) != paths[k].end())
{
paths[i].insert(j);
paths[j].insert(i);
}
}
}
int main()
{
int N, K, L;
cin >> N >> K >> L;
unordered_map<int, unordered_set<int>> roads;
unordered_map<int, unordered_set<int>> railways;
for (int i = 0; i < K; i++)
{
int a, b;
cin >> a >> b;
roads[a].insert(b);
roads[b].insert(a);
}
BuildCon(roads, N);
for (int i = 0; i < L; i++)
{
int a, b;
cin >> a >> b;
railways[a].insert(b);
railways[b].insert(a);
}
BuildCon(railways, N);
for (int i = 1; i <= N; i++)
{
int count = 1;
for (auto t : roads[i])
{
if (railways[i].find(t) != railways[i].end())
count++;
}
cout << count;
if (i != N)
cout << " ";
else
cout << endl;
}
return 0;
}
| a.cc:4:10: fatal error: stdafx.h: No such file or directory
4 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s679133732 | p03857 | C++ | #include <bits/stdc++.h>
using namespace std;
class UF {
public:
int par[200000];
int r[200000];
UF (int N) {
for (int i = 0; i < N; i++) {
par[i] = i;
}
}
int find(int x) {
if (x == par[x]) return x;
return par[x] = find(par[x]);
}
void add(int x, int y) {
x = find(x);
y = find(y);
if (x == y) return;
if (r[x] < r[y]) par[x] = y;
else {
par[y] = x;
if (r[x] == r[y]) r[x]++;
}
}
};
int main() {
int N, K, L;
cin >> N >> K >> L;
vector<vector<int> > md(N);
vector<vector<int> > mt(N);
vector<pair<int,int> > dP(K), tP(L);
for (int i = 0; i < K; i++) {
int x, y;
cin >> x >> y;
x--, y--;
dP[i] = pair<int,int>(min(x, y), max(x, y));
}
for (int i = 0; i < L; i++) {
int x, y;
cin >> x >> y;
x--, y--;
tP[i] = pair<int,int>(min(x, y), max(x, y));
}
UF duf(N), tuf(N);
for (int i = 0; i < K; i++) {
duf.add(dP[i].first, dP[i].second);
}
for (int i = 0; i < L; i++) {
tuf.add(tP[i].first, tP[i].second);
}
UF uf(N);
for (int i = 0; i < K; i++) {
if (tuf.find(dP[i].first) == tuf.find(dP[i].second)) {
uf.add(dP[i].first, dP[i].second);
}
}
for (int i = 0; i < L; i++) {
if (duf.find(tP[i].first) == duf.find(tP[i].second)) {
uf.add(tP[i].first, tP[i].second);
}
}
vector<vector<int> > tmp(N);
for (int i = 0; i < N; i++) {
tmp[duf.find(i)].push_back(i);
}
vector<int> pcount(N);
for (int i = 0; i < N; i++) {
map<int,int> count(N);
for (int j = 0; j < tmp[i].size(); j++) {
count[tuf.find(tmp[i][j])]++;
}
for (int j = 0; j < tmp[i].size(); j++) {
pcount[tmp[i][j]] += count[tuf.find(tmp[i][j])];
}
}
for (int i = 0; i < N-1; i++) {
cout << pcount[i] << " ";
}
cout << pcount[N-1] << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:85:29: error: no matching function for call to 'std::map<int, int>::map(int&)'
85 | map<int,int> count(N);
| ^
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:302:9: note: candidate: 'template<class _InputIterator> std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator, const _Compare&, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
302 | map(_InputIterator __first, _InputIterator __last,
| ^~~
/usr/include/c++/14/bits/stl_map.h:302:9: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:285:9: note: candidate: 'template<class _InputIterator> std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
285 | map(_InputIterator __first, _InputIterator __last)
| ^~~
/usr/include/c++/14/bits/stl_map.h:285:9: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:268:9: note: candidate: 'template<class _InputIterator> std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
268 | map(_InputIterator __first, _InputIterator __last,
| ^~~
/usr/include/c++/14/bits/stl_map.h:268:9: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:262:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::initializer_list<std::pair<const _Key, _Val> >, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
262 | map(initializer_list<value_type> __l, const allocator_type& __a)
| ^~~
/usr/include/c++/14/bits/stl_map.h:262:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:256:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::map<_Key, _Tp, _Compare, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::__type_identity_t<_Alloc> = std::allocator<std::pair<const int, int> >]'
256 | map(map&& __m, const __type_identity_t<allocator_type>& __a)
| ^~~
/usr/include/c++/14/bits/stl_map.h:256:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:252:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const std::map<_Key, _Tp, _Compare, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::__type_identity_t<_Alloc> = std::allocator<std::pair<const int, int> >]'
252 | map(const map& __m, const __type_identity_t<allocator_type>& __a)
| ^~~
/usr/include/c++/14/bits/stl_map.h:252:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:248:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
248 | map(const allocator_type& __a)
| ^~~
/usr/include/c++/14/bits/stl_map.h:248:33: note: no known conversion for argument 1 from 'int' to 'const std::map<int, int>::allocator_type&' {aka 'const std::allocator<std::pair<const int, int> >&'}
248 | map(const allocator_type& __a)
| ~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:240:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::initializer_list<std::pair<const _Key, _Val> >, const _Compare&, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
240 | map(initializer_list<value_type> __l,
| ^~~
/usr/include/c++/14/bits/stl_map.h:240:40: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::pair<const int, int> >'
240 | map(initializer_list<value_type> __l,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:227:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(std::map<_Key, _Tp, _Compare, _Alloc>&&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
227 | map(map&&) = default;
| ^~~
/usr/include/c++/14/bits/stl_map.h:227:11: note: no known conversion for argument 1 from 'int' to 'std::map<int, int>&&'
227 | map(map&&) = default;
| ^~~~~
/usr/include/c++/14/bits/stl_map.h:219:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
219 | map(const map&) = default;
| ^~~
/usr/include/c++/14/bits/stl_map.h:219:11: note: no known conversion for argument 1 from 'int' to 'const std::map<int, int>&'
219 | map(const map&) = default;
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:206:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map(const _Compare&, const allocator_type&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >; allocator_type = std::allocator<std::pair<const int, int> >]'
206 | map(const _Compare& __comp,
| ^~~
/usr/include/c++/14/bits/stl_map.h:206:27: note: no known conversion for argument 1 from 'int' to 'const std::less<int>&'
206 | map(const _Compare& __comp,
| ~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_map.h:197:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::map() [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
197 | map() = default;
| ^~~
/usr/include/c++/14/bits/stl_map.h:197:7: note: candidate expects 0 arguments, 1 provided
|
s088916612 | p03857 | C++ | #include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)
int ans[200000] = {0};
int k[200000];
int l[200000];
int num[200000] = {0};
pair<int, int> pq[100000];
pair<int, int> rs[100000];
pair<int, int> ki[200000];
int main(void)
{
int N, K, L;
cin >> N >> K >> L;
Rep(i, N) k[i] = i;
Rep(i, K){
int p, q;
cin >> p >> q;
p--; q--;
pq[i] = pair<int, int>(p, q);
}
sort(pq, pq + K);
Rep(i, K){
int p, q;
p = pq[i].first;
q = pq[i].second;
if(k[p] < k[q]){
k[q] = k[p];
}else{
k[p] = k[q];
}
}
#if 0
Rep(i, N){
PrintLn(k[i]);
}
#endif
Rep(i, N) l[i] = i;
Rep(i, L){
int r, s;
cin >> r >> s;
r--; s--;
rs[i] = pair<int, int>(r, s);
}
sort(rs, rs + L);
Rep(i, L){
int r, s;
r = rs[i].first;
s = rs[i].second;
if(l[r] < l[s]){
l[s] = l[r];
}else{
l[r] = l[s];
}
}
#if 0
Rep(i, N){
PrintLn(l[i]);
}
#endif
Rep(i, N){
ki[i] = pair<int, int>(k[i], i);
}
sort(ki, ki + N);
int start = 0;
Rep(i, N){
if(i != 0 && ki[i - 1].first != ki[i].first){
For(j, start, i){
ans[j] = num[l[ki[j].second]];
}
start = i;
memset(num, 0, N * sizeof(int));
}
num[l[ki[i].second]]++;
}
For(j, start, N){
ans[j] = num[l[ki[j].second]];
}
Rep(i, N){
cout << ans[i];
if(i == N - 1){
cout << endl;
}else{
cout << " ";
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:83:25: error: 'memset' was not declared in this scope
83 | memset(num, 0, N * sizeof(int));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <algorithm>
+++ |+#include <cstring>
4 | using namespace std;
|
s283837480 | p03857 | C++ | #include<iostream>
using namespace std;
const int _K=20000+5;
class UnionFind{
int par[_K];
int siz[_K];
public:
void init(int n){
for(int i=0; i<n; i++) par[i]=i;
for(int i=0; i<n; i++) siz[i]=1;
}
int find(int x){
if(par[x]==x){
return x;
}else{
return par[x]=find(par[x]);
}
}
bool same(int x, int y){
return find(x)==find(y);
}
void uni(int x, int y){
x=find(x);
y=find(y);
if(x==y) return;
if(siz[x]<siz[y]) swap(x, y);
par[y]=x;
siz[x]+=siz[y];
}
int size(int x){
return siz[find(x)];
}
};
int main(){
int N, K, L;
cin>> N>> K>> L;
int p[K], q[K];
for(int i=0; i<K; i++){
cin>> p[i]>> q[i];
}
int r[L], s[L];
for(int i=0; i<L; i++){
cin>> r[i]>> s[i];
}
UnionFind ufoo;
ufoo.init(N);
for(int i=0; i<K; i++) ufoo.uni(p[i]-1, q[i]-1);
Union Find ubar;
ubar.init(N);
for(int i=0; i<L; i++){
if(ufoo.same(r[i]-1, s[i]-1)){
ubar.uni(r[i]-1, s[i]-1);
}
}
for(int i=0; i<N; i++){
cout<< ubar.size(i)<< endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:55:9: error: 'Union' was not declared in this scope; did you mean 'union'?
55 | Union Find ubar;
| ^~~~~
| union
a.cc:56:9: error: 'ubar' was not declared in this scope
56 | ubar.init(N);
| ^~~~
|
s338236586 | p03857 | Java | import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/
public class MainD {
private static class Task {
void solve(FastScanner in, PrintWriter out) throws Exception {
int N = in.nextInt();
int K = in.nextInt();
int L = in.nextInt();
UnionFind train = new UnionFind(N);
UnionFind road = new UnionFind(N);
int[][] edgeT = new int[K][2];
for (int i = 0; i < K; i++) {
edgeT[i][0] = in.nextInt() - 1;
edgeT[i][1] = in.nextInt() - 1;
train.unite(edgeT[i][0], edgeT[i][1]);
}
int[][] edgeR = new int[L][2];
for (int i = 0; i < L; i++) {
edgeR[i][0] = in.nextInt() - 1;
edgeR[i][1] = in.nextInt() - 1;
road.unite(edgeR[i][0], edgeR[i][1]);
}
UnionFind uf = new UnionFind(N);
TreeMap<Integer, ArrayList<Integer>> tree = new TreeMap<>();
for (int i = 0; i < N; i++) {
ArrayList<Integer> list = tree.get(road.find(i));
if (list == null) tree.put(uf.find(i), list = new ArrayList<Integer>());
list.add(i);
}
for (Map.Entry<Integer, ArrayList<Integer>> entry : tree.entrySet()) {
int parent = entry.getKey();
for (int v : entry.getValue()) {
if (train.isSame(parent, v)) uf.unite(parent, v);
}
}
for (int i = 0; i < N; i++) {
if (i > 0) out.print(" ");
int x = uf.partialSizeOf(i);
if (x <= 0) throw new Exception();
out.print(x);
}
out.println();
}
class UnionFind {
// par[i]:データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
private int[] par;
// sizes[i]:根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
private int[] sizes;
// 木の数
private int size;
UnionFind(int n) {
par = new int[n];
sizes = new int[n];
size = n;
Arrays.fill(sizes, 1);
// 最初は全てのデータiがグループiに存在するものとして初期化
for (int i = 0; i < n; i++) par[i] = i;
}
/**
* データxが属する木の根を得る
*
* @param x
* @return
*/
int find(int x) {
if (x == par[x]) return x;
return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
}
/**
* 2つのデータx, yが属する木をマージする。
* マージが必要なら true を返す
*
* @param x
* @param y
* @return
*/
boolean unite(int x, int y) {
// データの根ノードを得る
x = find(x);
y = find(y);
// 既に同じ木に属しているならマージしない
if (x == y) return false;
// xの木がyの木より大きくなるようにする
if (sizes[x] < sizes[y]) {
int tx = x;
x = y;
y = tx;
}
// xがyの親になるように連結する
par[y] = x;
sizes[x] += sizes[y];
sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい
size--;
return true;
}
/**
* 2つのデータx, yが属する木が同じならtrueを返す
*
* @param x
* @param y
* @return
*/
boolean isSame(int x, int y) {
return find(x) == find(y);
}
/**
* データxが含まれる木の大きさを返す
*
* @param x
* @return
*/
int partialSizeOf(int x) {
return sizes[find(x)];
}
/**
* 木の数を返す
*
* @return
*/
int size() {
return size;
}
}
}
/**
* ここから下はテンプレートです。
*/
public static void main(String[] args) throws Exception {
OutputStream outputStream = System.out;
FastScanner in = new FastScanner();
PrintWriter out = new PrintWriter(outputStream);
Task solver = new Task();
solver.solve(in, out);
out.close();
}
private static class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int bufferLength = 0;
private boolean hasNextByte() {
if (ptr < bufferLength) {
return true;
} else {
ptr = 0;
try {
bufferLength = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (bufferLength <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte()) return buffer[ptr++];
else return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
}
boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
double nextDouble() {
return Double.parseDouble(next());
}
double[] nextDoubleArray(int n) {
double[] array = new double[n];
for (int i = 0; i < n; i++) {
array[i] = nextDouble();
}
return array;
}
double[][] nextDoubleMap(int n, int m) {
double[][] map = new double[n][];
for (int i = 0; i < n; i++) {
map[i] = nextDoubleArray(m);
}
return map;
}
public int nextInt() {
return (int) nextLong();
}
public int[] nextIntArray(int n) {
int[] array = new int[n];
for (int i = 0; i < n; i++) array[i] = nextInt();
return array;
}
public long[] nextLongArray(int n) {
long[] array = new long[n];
for (int i = 0; i < n; i++) array[i] = nextLong();
return array;
}
public String[] nextStringArray(int n) {
String[] array = new String[n];
for (int i = 0; i < n; i++) array[i] = next();
return array;
}
public char[][] nextCharMap(int n) {
char[][] array = new char[n][];
for (int i = 0; i < n; i++) array[i] = next().toCharArray();
return array;
}
public int[][] nextIntMap(int n, int m) {
int[][] map = new int[n][];
for (int i = 0; i < n; i++) {
map[i] = nextIntArray(m);
}
return map;
}
}
} | Main.java:30: error: class MainD is public, should be declared in a file named MainD.java
public class MainD {
^
1 error
|
s656157080 | p03857 | C++ | #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define ALL(c) c.begin(), c.end()
#define SCANF(x) scanf("%lld", &x)
#define MOD 1000000007
#define MAX_N 1000000
#define INF 1410065408
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};
/*
逆順ソート sort(ALL(vec), greater<ll>());
ペア定義 P pair = make_pair(100, 200);
集合find set.find(item);
小さい順に取り出したい優先度付きキュー
priority_queue<int, vector<int>, greater<int> > que;
配列の最大要素 *std::max_element(ALL(vec))
*/
int par[2][MAX_N]; //親
int ran[2][MAX_N]; //深さ
//初期化
void init(int n){
FOR1(n){
par[0][i] = i;
par[1][i] = i;
ran[0][i] = 0;
ran[1][i] = 0;
}
}
//根を求める
int find(int x, int t){
if(par[t][x] == x){
return x;
}else{
return par[t][x] = find(par[t][x], t);
}
}
//xとyの属する集合の併合
void unite(int x, int y, int t){
x = find(x, t);
y = find(y, t);
if(x == y) return;
if(ran[t][x] < ran[t][y]){
par[t][x] = y;
}else{
par[t][y] = x;
if(ran[t][x] == ran[t][y]) ran[t][x]++;
}
}
//同じ集合に属するか否か
bool same(int x, int y, int t){
return find(x, t) == find(y, t);
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, k, l;
scanf("%d %d %d", &n, &k, &l);
init(n);
FOR1(k+l){
int p, q;
scanf("%d %d", &p, &q);
if(i < k){
unite(p-1, q-1, 0);
}else if(same(p-1, q-1, 0)){
unite(p-1, q-1, 1);
}
}
map<int, int> mp;
FOR1(n){
mp[par[1][i]]++;
}
FOR1(n-1){
printf("%d ", mp[par[1][i]]);
}
printf("%d", mp[par[1][n-1]);
} | a.cc: In function 'int main()':
a.cc:104:36: error: expected ']' before ')' token
104 | printf("%d", mp[par[1][n-1]);
| ^
| ]
|
s880054304 | p03857 | C++ | #include<bits/stdc++.h>
using namespace std;
template<typename T>
class UF
{
public:
UF() {
size = 0;
}
//値を挿入する
void push( T a ) {
M[a] = size;
V.push_back( size );
rank.push_back( 0 );
C.push_back( 1 );
size++;
}
//同じグループにする
void unite( T a, T b ) {
long long int x = find( M[a] );
long long int y = find( M[b] );
if( x == y )return;
if( rank[x] < rank[y] ) {
V[x] = y;
C[y] += C[x];
} else {
V[y] = x;
C[x] += C[y];
if( rank[x] == rank[y] )rank[x]++;
}
}
void merge( T a, T b ) {
unite( a, b );
}
//同じグループにいるかどうか判定する
bool same( T a, T b ) {
return find( M[a] ) == find( M[b] );
}
//今何グループあるか数を返す
long long int group() {
set<long long int >S;
for( long long int i = 0; i < V.size(); i++ ) {
S.insert( find( V[i] ) );
}
return S.size();
}
//グループに属している数を返す
long long int count( T a ) {
return C[find( M[a] )];
}
private:
vector<long long int>
C, V, rank;
map < T, long long int>M;
long long int size;
//祖先までたどる
long long int find( long long int x ) {
if( V[x] == x )return x;
else return V[x] = find( V[x] );
}
};
int main() {
UF<long long int>uf1, uf2;
long long int N, K, L;
cin >> N >> K >> L;
for( long long int i = 0; i < N; i++ ) {
uf1.push( i );
uf2.push( i )
}
for( long long int i = 0; i < K; i++ ) {
long long int p, q;
cin >> p >> q;
p--; q--;
uf1.merge( p, q );
}
for( long long int i = 0; i < L; i++ ) {
long long int r, s;
cin >> r >> s;
r--; s--;
if( uf1.same( r, s ) ) {
uf2.merge( r, s );
}
}
for( long long int i = 0; i < N; i++ ) {
cout << uf2.count( i );
if( i == N - 1 ) {
cout << endl;
} else {
cout << " ";
}
}
}
| a.cc: In function 'int main()':
a.cc:81:30: error: expected ';' before '}' token
81 | uf2.push( i )
| ^
| ;
82 | }
| ~
|
s001532859 | p03858 | C++ | #include <cassert>
#include <unordered_map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int L1(int a, int b, int c, int d) {
return abs(a - c) + abs(b - d);
}
int main() {
int N, a, b; cin >> N >> a >> b;
int x[N], y[N];
struct Point {
int x, y;
int idx;
bool operator<(const Point& other) const {
return x < other.x;
};
Point(int x, int y, int i) : x(x), y(y), idx(i) {};
};
unordered_map<int, set<Point> > unvisited[2];
unordered_map<int, vector<Point> > all[2];
auto get_point = [&](int i) { return Point(x[i], y[i], i); };
for (int i = 0; i < N; i++) {
cin >> x[i] >> y[i];
Point p = get_point(i);
unvisited[0][x[i] + y[i]].insert(p);
unvisited[1][x[i] - y[i]].insert(p);
all[0][x[i] + y[i]].push_back(p);
all[1][x[i] - y[i]].push_back(p);
}
for (auto &x : all) for (auto& [k, v] : x) sort(v.begin(), v.end());
const int d = L1(x[a-1], y[a-1], x[b-1], y[b-1]);
queue<int> q;
auto visit = [&](int i) {
Point p = get_point(i);
unvisited[0][x[i] + y[i]].erase(p);
unvisited[1][x[i] - y[i]].erase(p);
};
q.push(a-1);
visit(a-1);
long long ans = 0;
auto get_count = [](vector<Point> &v, int lb, int ub) {
auto l = partition_point(v.begin(), v.end(), [lb](Point q) { return q.x < lb; }),
r = partition_point(v.begin(), v.end(), [ub](Point q) { return q.x <= ub; });
return abs(distance(l, r));
};
while (!q.empty()) {
int i = q.front();
q.pop();
Point p = Point(x[i], y[i], i);
// cerr << x[i] << " " << y[i] << endl;
if (auto it = all[0].find(x[i] + y[i] + d); it != all[0].end())
ans += get_count(it->second, p.x+1, p.x+d);
if (auto it = all[1].find(x[i] - y[i] - d); it != all[1].end())
ans += get_count(it->second, p.x-d+1, p.x);
if (auto it = all[0].find(x[i] + y[i] - d); it != all[0].end())
ans += get_count(it->second, p.x-d, p.x-1);
if (auto it = all[1].find(x[i] - y[i] + d); it != all[1].end())
ans += get_count(it->second, p.x, p.x+d-1);
// cerr << ans << endl;
set<int> visited;
auto record_visit = [&](set<Point> &s, int lb, int ub) {
for (auto it = s.lower_bound(Point(lb, 0, 0)); it != s.end() && it->x <= ub; it++)
visited.insert(it->idx);
};
if (auto it = unvisited[0].find(x[i] + y[i] + d); it != unvisited[0].end())
record_visit(it->second, p.x+1, p.x+d);
if (auto it = unvisited[1].find(x[i] - y[i] - d); it != unvisited[1].end())
record_visit(it->second, p.x-d+1, p.x);
if (auto it = unvisited[0].find(x[i] + y[i] - d); it != unvisited[0].end())
record_visit(it->second, p.x-d, p.x-1);
if (auto it = unvisited[1].find(x[i] - y[i] + d); it != unvisited[1].end())
record_visit(it->second, p.x, p.x+d-1);
for (int j : visited) { visit(j); q.push(j); }
// for (int j : visited) cerr << x[i] << " "<< y[i] << " -> " << x[j] << " " << y[j] << endl;
}
cout << ans / 2 << endl;
//check
// q.push(a-1);
// vector<bool> used(N, false);
// used[a-1] = true;
// long long expect = 0;
// while (!q.empty()) {
// int i = q.front();
// q.pop();
// for (int j = 0; j < N; j++) {
// if (L1(x[i], y[i], x[j], y[j]) == d) {
// expect++;
// if (!used[j]) {
// used[j] = true;
// q.push(j);
// }
// }
// }
// }
// assert(ans == expect);
}
| a.cc: In function 'int L1(int, int, int, int)':
a.cc:9:12: error: 'abs' was not declared in this scope
9 | return abs(a - c) + abs(b - d);
| ^~~
a.cc: In function 'int main()':
a.cc:13:18: error: 'cin' was not declared in this scope
13 | int N, a, b; cin >> N >> a >> b;
| ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
4 | #include <set>
+++ |+#include <iostream>
5 | #include <vector>
a.cc:34:48: error: 'sort' was not declared in this scope; did you mean 'short'?
34 | for (auto &x : all) for (auto& [k, v] : x) sort(v.begin(), v.end());
| ^~~~
| short
a.cc: In lambda function:
a.cc:46:18: error: 'partition_point' was not declared in this scope
46 | auto l = partition_point(v.begin(), v.end(), [lb](Point q) { return q.x < lb; }),
| ^~~~~~~~~~~~~~~
a.cc:47:84: error: expected ',' or ';' before ')' token
47 | r = partition_point(v.begin(), v.end(), [ub](Point q) { return q.x <= ub; });
| ^
a.cc:48:32: error: 'r' was not declared in this scope
48 | return abs(distance(l, r));
| ^
a.cc:48:16: error: 'abs' was not declared in this scope; did you mean 'ans'?
48 | return abs(distance(l, r));
| ^~~
| ans
a.cc: In function 'int main()':
a.cc:85:5: error: 'cout' was not declared in this scope
85 | cout << ans / 2 << endl;
| ^~~~
a.cc:85:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:85:24: error: 'endl' was not declared in this scope
85 | cout << ans / 2 << endl;
| ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
4 | #include <set>
+++ |+#include <ostream>
5 | #include <vector>
|
s578968387 | p03858 | C++ | 8 1 2
1 5
4 3
8 2
4 7
8 8
3 3
6 6
4 8
| a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 8 1 2
| ^
|
s065833708 | p03858 | C++ | #include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#define LL long long
const int maxn = 1e5 + 5;
using namespace std;
inline int read(){
int x = 0; char ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) x = (x * 10) + (ch & 15), ch = getchar();
return x;
}
vector <pair<int, int> > X[maxn], Y[maxn];
set <pair<int, int> > sx[maxn], sy[maxn];
int n, s1, s2, d;
int x[maxn], y[maxn], lx[maxn], ly[maxn], ox[maxn], oy[maxn];
LL ans = 0;
queue <int> q;
bool vis[maxn];
void addx(int l, int f){
set <pair<int, int> >::iterator it = lower_bound(sx[l].begin(), sx[l].end(), make_pair(oy[f] - d, 0));
ans += 1ll * (upper_bound(X[l].begin(), X[l].end(), make_pair(oy[f] + d, n)) - lower_bound(X[l].begin(), X[l].end(), make_pair(oy[f] - d, 0)));
if ((upper_bound(X[l].begin(), X[l].end(), make_pair(oy[f] + d, n)) - 1)->first == oy[f] + d) --ans;
if ((lower_bound(X[l].begin(), X[l].end(), make_pair(oy[f] - d, 0))) -> first == oy[f] - d) --ans;
if (it == sx[l].end()) return;
while (oy[it->second] <= oy[f] + d && it != sx[l].end()){
if (!vis[it->second]) q.push(it->second), vis[it->second] = 1;
set <pair<int, int> >::iterator temp = it; ++temp;
sx[l].erase(it); it = temp;
}
}
void addy(int c, int f){
set <pair<int, int> >::iterator it = lower_bound(sy[c].begin(), sy[c].end(), make_pair(ox[f] - d, 0));
ans += 1ll * (upper_bound(Y[c].begin(), Y[c].end(), make_pair(ox[f] + d, n)) - lower_bound(Y[c].begin(), Y[c].end(), make_pair(ox[f] - d, 0)));
if (it == sy[c].end()) return;
while (ox[it->second] <= ox[f] + d && it != sy[c].end()){
if (!vis[it->second]) q.push(it->second), vis[it->second] = 1;
set <pair<int, int> >::iterator temp = it; ++temp;
sy[c].erase(it); it = temp;
}
}
void bfs(){
q.push(s1); vis[s1] = 1;
while (!q.empty()){
int cur = q.front(); q.pop();
int l1 = lower_bound(lx + 1, lx + n + 1, ox[cur] - d) - lx;
int l2 = lower_bound(lx + 1, lx + n + 1, ox[cur] + d) - lx;
int c1 = lower_bound(ly + 1, ly + n + 1, oy[cur] - d) - ly;
int c2 = lower_bound(ly + 1, ly + n + 1, oy[cur] + d) - ly;
bool f1 = (lx[l1] == ox[cur] - d), f2 = (lx[l2] == ox[cur] + d);
bool f3 = (ly[c1] == oy[cur] - d), f4 = (ly[c2] == oy[cur] + d);
if (f1) addx(l1, cur);
if (f2) addx(l2, cur);
if (f3) addy(c1, cur);
if (f4) addy(c2, cur);
}
}
int _abs(int x){
return x < 0 ? -x : x;
}
int main(){
scanf("%d%d%d", &n, &s1, &s2);
for (int a, b, i = 1; i <= n; i++){
a = read(), b = read();
x[i] = a - b; y[i] = a + b;
ox[i] = x[i], oy[i] = y[i];
lx[i] = x[i], ly[i] = y[i];
}
sort(lx + 1, lx + n + 1); sort(ly + 1, ly + n + 1);
for (int i = 1; i <= n; i++){
x[i] = lower_bound(lx + 1, lx + n + 1, x[i]) - lx;
y[i] = lower_bound(ly + 1, ly + n + 1, y[i]) - ly;
X[x[i]].push_back(make_pair(oy[i], i));
Y[y[i]].push_back(make_pair(ox[i], i));
sx[x[i]].insert(make_pair(oy[i], i));
sy[y[i]].insert(make_pair(ox[i], i));
}
for (int i = 1; i <= n; i++) sort(X[i].begin(), X[i].end());
for (int i = 1; i <= n; i++) sort(Y[i].begin(), Y[i].end());
d = max(_abs(ox[s1] - ox[s2]), _abs(oy[s1] - oy[s2]));
bfs();
printf("%lld\n", ans / 2ll);
return 0;
} | a.cc: In function 'int read()':
a.cc:12:17: error: 'isdigit' was not declared in this scope
12 | while (!isdigit(ch)) ch = getchar();
| ^~~~~~~
a.cc:13:16: error: 'isdigit' was not declared in this scope
13 | while (isdigit(ch)) x = (x * 10) + (ch & 15), ch = getchar();
| ^~~~~~~
|
s649187122 | p03858 | C++ | #include<bits/stdc++.h>
#define maxn 100005
#define pii pair<int,int>
#define ll long long
using namespace std;
struct point {
int x,y;
}arr[maxn];
struct node {
int pos,num;
bool operator < (const node& a) const{
return pos != a.pos ? pos < a.pos : num < a.num;
}
};
bool vis[maxn];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n,a,b;
cin >> n >> a >> b;
for(int i=1;i<=n;i++)
cin >> arr[i].x >> arr[i].y;
map<int,set<pii> > idxs[2];
for(int i=1;i<=n;i++) {
int x = arr[i].x , y = arr[i].y;
idxs[0][x-y].insert(pii{arr[i].x,i});
idxs[1][x+y].insert(pii{arr[i].x,i});
}
map<int,set<node> > ptrs[2];
for(int i=0;i<2;i++)
for(auto now : idxs[i]) {
int cnt = 0;
for(pii idx : now.second)
ptrs[i][now.first].insert(node{idx.first,cnt++});
}
int len = abs(arr[a].x - arr[b].x) + abs(arr[a].y - arr[b].y);
queue<int> wait;
for(int st : {a,b}) {
wait.push(st);
int x = arr[st].x , y = arr[st].y;
idxs[0][x-y].erase(pii{x,st});
idxs[1][x+y].erase(pii{x,st});
}
ll ans = 0;
while(!wait.empty()) {
int u = wait.front();
wait.pop();
if(vis[u]) continue;
vis[u] = true;
int x = arr[u].x , y = arr[u].y;
for(int delta_y_coe : {-1,1}) {
int ny = y + delta_y_coe * len;
for(int t : {-1,1}) {
int type = x + t * ny;
int l,r;
if(delta_y_coe == -1) {
if(t == -1)
l = x + 1 , r = x + len;
else
l = x - len + 1 , r = x;
}
else {
if(t == -1)
l = x - len , y = x - 1;
else
l = x , r = x + len - 1;
}
// calculate
auto L = ptrs[min(t+1,1)][type].lower_bound(node{l,-1e9});
auto R = ptrs[min(t+1,1)][type].upper_bound(node{r,1e9});
if(R != ptrs[min(t+1,1)][type].begin() && L != ptrs[min(t+1,1)][type].end()) {
R--;
int num = max(0,R->num - L->num + 1);
ans += num;
}
// update
auto it = idxs[min(t+1,1)][type].lower_bound(pii{l,-1e9});
while(it != idxs[min(t+1,1)][type].end() && it->first <= r) {
int v = it->second;
wait.push(v);
idxs[min(t+1,1)][type].erase(*it);
it = idxs[min(t+1,1)][type].lower_bound(pii{l,-1e9});
}
}
}
}
cout << ans/2 << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:73:84: error: narrowing conversion of '-1.0e+9' from 'double' to 'int' [-Wnarrowing]
73 | auto L = ptrs[min(t+1,1)][type].lower_bound(node{l,-1e9});
| ^~~~
a.cc:74:84: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
74 | auto R = ptrs[min(t+1,1)][type].upper_bound(node{r,1e9});
| ^~~
|
s900493032 | p03858 | C++ | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define int long long
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,a,b;
cin >> n >> a >> b;
a--;b--;
vector<int> x(n),y(n);
rep(i,n){
int c,d;
cin >> c >> d;
x[i] = c+d;
y[i] = c-d;
}
int d = max(abs(x[a]-x[b]),abs(y[a]-y[b]));
map<int,set<int> > mpx,mpy;
map<int,vector<int> > mpx2,mpy2;
map<pair<int,int>,int > num;
rep(i,n){
mpx2[x[i]].push_back(y[i]);
mpy2[y[i]].push_back(x[i]);
if(i==a)continue;
num[MP(x[i],y[i])] = i;
mpx[x[i]].insert(y[i]);
mpy[y[i]].insert(x[i]);
}
for(auto &aa:mpx2){
vector<int>&aaa = aa.second;
sort(aaa.begin(),aaa.end());
}
for(auto &aa:mpy2){
vector<int>&aaa = aa.second;
sort(aaa.begin(),aaa.end());
}
set<int> st;
st.insert(a);
queue<int> q;
q.push(a);
bool fa= 0;
bool fb = 0;
int res = 0;
while(!q.empty()){
int k = q.front();
q.pop();
int sx = x[k] + d;
set<int>&t = mpx[sx];
auto tmp = t.lower_bound(y[k]-d);
vector<int> &p = mpx2[sx];
int sss = upper_bound(p.begin(),p.end(),y[k]+d)-lower_bound(p.begin(),p.end(),y[k]-d);
res += sss;
while(tmp!=t.end()){
int yy = (*tmp);
if(yy<=y[k]+d){
int cc = num[MP(sx,yy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpy[y[cc]].erase(x[cc]);
}else{
break;
}
}
sx = x[k] - d;
t = mpx[sx];
tmp = t.lower_bound(y[k]-d);
&p = mpx2[sx];
sss = upper_bound(p.begin(),p.end(),y[k]+d)-lower_bound(p.begin(),p.end(),y[k]-d);
res += sss;
while(tmp!=t.end()){
int yy = (*tmp);
if(yy<=y[k]+d){
int cc = num[MP(sx,yy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpy[y[cc]].erase(x[cc]);
}else{
break;
}
}
int sy = y[k] + d;
t = mpy[sy];
tmp = t.lower_bound(x[k]-d);
p = mpy2[sy];
sss = lower_bound(p.begin(),p.end(),x[k]+d)-upper_bound(p.begin(),p.end(),x[k]-d);
res += sss;
while(tmp!=t.end()){
int xx = (*tmp);
if(xx<=x[k]+d){
int cc = num[MP(xx,sy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpx[x[cc]].erase(y[cc]);
}else{
break;
}
}
sy = y[k]-d;
t = mpy[sy];
tmp = t.lower_bound(x[k]-d);
p = mpy2[sy];
sss = lower_bound(p.begin(),p.end(),x[k]+d)-upper_bound(p.begin(),p.end(),x[k]-d);
res += sss;
while(tmp!=t.end()){
int xx = (*tmp);
if(xx<=x[k]+d){
int cc = num[MP(xx,sy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpx[x[cc]].erase(y[cc]);
}else{
break;
}
}
//cerr << k << " " << res << endl;
}
// for(auto x:st){
// cerr << x << " ";
// }
// cerr << endl;
cout << res/2 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:101:9: error: lvalue required as left operand of assignment
101 | &p = mpx2[sx];
| ^~
|
s029974803 | p03858 | C++ | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define int long long
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,a,b;
cin >> n >> a >> b;
a--;b--;
vector<int> x(n),y(n);
rep(i,n){
int c,d;
cin >> c >> d;
x[i] = c+d;
y[i] = c-d;
}
int d = max(abs(x[a]-x[b]),abs(y[a]-y[b]));
map<int,set<int> > mpx,mpy;
map<int,vector<int> > mpx2,mpy2;
map<pair<int,int>,int > num;
rep(i,n){
mpx2[x[i]].push_back(y[i]);
mpy2[y[i]].push_back(x[i]);
if(i==a)continue;
num[MP(x[i],y[i])] = i;
mpx[x[i]].insert(y[i]);
mpy[y[i]].insert(x[i]);
}
for(auto &aa:mpx2){
vector<int>&aaa = aa.second;
sort(aaa.begin(),aaa.end());
}
for(auto &aa:mpy2){
vector<int>&aaa = aa.second;
sort(aaa.begin(),aaa.end());
}
set<int> st;
st.insert(a);
queue<int> q;
q.push(a);
bool fa= 0;
bool fb = 0;
int res = 0;
while(!q.empty()){
int k = q.front();
q.pop();
int sx = x[k] + d;
set<int>&t = mpx[sx];
auto tmp = t.lower_bound(y[k]-d);
vector<int> &p = mpx2[sx];
int sss = upper_bound(p.begin(),p.end(),y[k]+d)-lower_bound(p.begin(),p.end(),y[k]-d);
res += sss;
while(tmp!=t.end()){
int yy = (*tmp);
if(yy<=y[k]+d){
int cc = num[MP(sx,yy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpy[y[cc]].erase(x[cc]);
}else{
break;
}
}
sx = x[k] - d;
t = mpx[sx];
tmp = t.lower_bound(y[k]-d);
vector<int> &p = mpx2[sx];
sss = upper_bound(p.begin(),p.end(),y[k]+d)-lower_bound(p.begin(),p.end(),y[k]-d);
res += sss;
while(tmp!=t.end()){
int yy = (*tmp);
if(yy<=y[k]+d){
int cc = num[MP(sx,yy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpy[y[cc]].erase(x[cc]);
}else{
break;
}
}
int sy = y[k] + d;
t = mpy[sy];
tmp = t.lower_bound(x[k]-d);
p = mpy2[sy];
sss = lower_bound(p.begin(),p.end(),x[k]+d)-upper_bound(p.begin(),p.end(),x[k]-d);
res += sss;
while(tmp!=t.end()){
int xx = (*tmp);
if(xx<=x[k]+d){
int cc = num[MP(xx,sy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpx[x[cc]].erase(y[cc]);
}else{
break;
}
}
sy = y[k]-d;
t = mpy[sy];
tmp = t.lower_bound(x[k]-d);
p = mpy2[sy];
sss = lower_bound(p.begin(),p.end(),x[k]+d)-upper_bound(p.begin(),p.end(),x[k]-d);
res += sss;
while(tmp!=t.end()){
int xx = (*tmp);
if(xx<=x[k]+d){
int cc = num[MP(xx,sy)];
if(st.count(cc)==0){
st.insert(cc);
q.push(cc);
}
tmp = t.erase(tmp);
mpx[x[cc]].erase(y[cc]);
}else{
break;
}
}
//cerr << k << " " << res << endl;
}
// for(auto x:st){
// cerr << x << " ";
// }
// cerr << endl;
cout << res/2 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:101:22: error: redeclaration of 'std::vector<long long int>& p'
101 | vector<int> &p = mpx2[sx];
| ^
a.cc:81:22: note: 'std::vector<long long int>& p' previously declared here
81 | vector<int> &p = mpx2[sx];
| ^
|
s584079285 | p03858 | C++ | #include <bits/stdc++.h>
using namespace std; typedef long long ll; const int MAXN=1e5+10; struct edge{int nxt,to;}e[MAXN*8];//一定要开8倍空间 struct data{int x,y,id;}dat[MAXN]; int n,d,a,b,x,y,head[MAXN],vis[MAXN],cnt[MAXN],tot=0; ll res=0;
void add_edge(int from,int to) { e[++tot].nxt=head[from];e[tot].to=to;head[from]=tot; e[++tot].nxt=head[to];e[tot].to=from;head[to]=tot; }
bool operator < (data a,data b) { if(a.x!=b.x) return a.x<b.x;
return a.y<b.y; }
void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
void dfs(int x) { vis[x]=true;res+=cnt[x]; for(int i=head[x];i;i=e[i].nxt) if(!vis[e[i].to]) dfs(e[i].to); }
int main() { scanf("%d%d%d",&n,&a,&b); for(int i=1;i<=n;i++) scanf("%d%d",&x,&y),dat[i]={x+y,x-y,i}; d=max(abs(dat[a].x-dat[b].x),abs(dat[a].ydat[b].y)); solve(d);
for(int i=1;i<=n;i++) swap(dat[i].x,dat[i].y); solve(d-1); dfs(a);printf("%lld",res); cout << endl; return 0; }
| a.cc:5:34: error: extended character is not valid in an identifier
5 | void add_edge(int from,int to) { e[++tot].nxt=head[from];e[tot].to=to;head[from]=tot; e[++tot].nxt=head[to];e[tot].to=from;head[to]=tot; }
| ^
a.cc:5:36: error: extended character is not valid in an identifier
5 | void add_edge(int from,int to) { e[++tot].nxt=head[from];e[tot].to=to;head[from]=tot; e[++tot].nxt=head[to];e[tot].to=from;head[to]=tot; }
| ^
a.cc:5:90: error: extended character is not valid in an identifier
5 | void add_edge(int from,int to) { e[++tot].nxt=head[from];e[tot].to=to;head[from]=tot; e[++tot].nxt=head[to];e[tot].to=from;head[to]=tot; }
| ^
a.cc:5:92: error: extended character is not valid in an identifier
5 | void add_edge(int from,int to) { e[++tot].nxt=head[from];e[tot].to=to;head[from]=tot; e[++tot].nxt=head[to];e[tot].to=from;head[to]=tot; }
| ^
a.cc:7:35: error: extended character is not valid in an identifier
7 | bool operator < (data a,data b) { if(a.x!=b.x) return a.x<b.x;
| ^
a.cc:7:37: error: extended character is not valid in an identifier
7 | bool operator < (data a,data b) { if(a.x!=b.x) return a.x<b.x;
| ^
a.cc:8:2: error: extended character is not valid in an identifier
8 | return a.y<b.y; }
| ^
a.cc:8:4: error: extended character is not valid in an identifier
8 | return a.y<b.y; }
| ^
a.cc:10:21: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:23: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:45: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:47: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:65: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:67: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:100: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:105: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:107: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:109: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:111: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); for(;lst<r-1;lst++) add_edge(dat[lst].id,dat[lst+1].id); } }
| ^
a.cc:10:202: error: extended character is not valid in an identifier
10 | void solve(int k) { sort(dat+1,dat+n+1); int cur,lst,l,r; for(cur=lst=l=r=1;cur<=n;cur++) { while((dat[l].x<dat[cur].x+d||dat[l].x==dat[cur].x+d &&dat[l].y<dat[cur].y-k)&&l<=n) l++; while((dat[r].x<dat[cur].x+d||dat[r].x==dat[cur].x+d &&dat[r].y<=dat[cur].y+k)&&r<=n) r++; if(l>n) break; cnt[dat[cur].id]+=r-l;lst=max(lst,l); if(lst>=r) continue; add_edge(dat[cur].id,dat[lst].id); |
s196725759 | p03858 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
using namespace std;
ll res=0;
vector<vector<pair<ll,ll>>> pq,qp;
vector<ll> used;
vector<pair<ll,ll>> xy;
unordered_map<ll, ll> ma,mb;
void dfs(ll node,ll k)
{
ll x=xy[node].first,y=xy[node].second;
used[node]=1;
vector<ll> aa={x+k,x-k,y+k,y-k},bb={y-k,y-k,x-k,x-k};
rep(i,2)
{
if(!ma.count(aa[i]))continue;
ll idx=ma[aa[i]];
auto s=lower_bound(all(pq[idx]),make_pair(bb[i],0)),
t=upper_bound(all(pq[idx]),make_pair(bb[i]+2*k+1,0));
res+=t-s;
while(s!=t)
{
if(used[(*s).second]){s++;continue;}
dfs((*s).second,k);
s++;
}
}
repi(i,2,4)
{
if(!mb.count(aa[i]))continue;
ll idx=mb[aa[i]];
auto s=lower_bound(all(qp[idx]),make_pair(bb[i]+1,0)),
t=upper_bound(all(qp[idx]),make_pair(bb[i]+2*k,0));
res+=t-s;
while(s!=t)
{
if(used[(*s).second]){s++;continue;}
dfs((*s).second,k);
s++;
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
ll n,a,b;
cin>>n>>a>>b;
a--;b--;
ll cnt=0;
xy.resize(n);
rep(i,n)
{
ll x,y;
cin>>x>>y;
xy[i]={x+y,x-y};
mb[x-y]=cnt;
ma[x+y]=cnt++;
}
pq.resize(cnt);
qp.resize(cnt);
rep(i,n)
{
ll id=ma[xy[i].first];
pq[id].push_back({xy[i].second,i});
id=mb[xy[i].second];
qp[id].push_back({xy[i].first,i});
}
rep(i,cnt)
{
sort(all(pq[i]));
sort(all(qp[i]));
}
used.resize(n,0);
ll k=abs((xy[a].first+xy[a].second)-(xy[b].first+xy[b].second))+abs((xy[a].first-xy[a].second)-(xy[b].first-xy[b].second));
dfs(a,k/2);
cout<<res/2<<endl;
return 0;
}
| In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Value = const std::pair<long long int, int>]':
/usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Tp = pair<long long int, int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]'
1504 | if (__comp(__middle, __val))
| ~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Tp = pair<long long int, int>]'
1539 | return std::__lower_bound(__first, __last, __val,
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
1540 | __gnu_cxx::__ops::__iter_less_val());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:23: required from here
41 | auto s=lower_bound(all(pq[idx]),make_pair(bb[i],0)),
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, int>')
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'int')
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
69 | { return *__it < __val; }
|
s754211613 | p03858 | C++ | #include<cstdio>
#include<cstring>
#include<cctype>
#include<vector>
#include<set>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;
vector<LL>W[maxn],H[maxn];
LL n,x[maxn],y[maxn],sa[maxn],sb[maxn],Q[maxn],L,R;
LL ans=0;
bool usd[maxn];
struct node
{
LL num,id;
node(LL a=0,LL b=0):num(a),id(b){}
bool operator <(const node &nxt)const
{
return num < nxt.num;
}
};
set<node>w[maxn],h[maxn];
void checkw(LL x,LL up,LL dn)
{
if(up<=dn && x == *lower_bound(sa+1,sa+1+sa[0],x))
{
x=lower_bound(sa+1,sa+1+sa[0],x)-sa;
multiset<node>::iterator it = w[x] . upper_bound(node(up-1,0)) , it2;
for(;it!=w[x].end() && (*it).num <= dn;)
{
Q[R++] = (*it).id;
usd[(*it).id]=1;
it2=it,it++;
h[y[(*it2).id]].erase(node(sb[y[(*it2).id]] , (*it2).id));
w[x].erase(it2);
}
}
}
void checkW(LL x,LL up,LL dn)
{
if(up<=dn && x == *lower_bound(sa+1,sa+1+sa[0],x))
{
x=lower_bound(sa+1,sa+1+sa[0],x)-sa;
ans+=upper_bound(W[x].begin(),W[x].end(),dn) - lower_bound(W[x].begin(),W[x].end(),up);
}
}
void checkh(LL y,LL up,LL dn)
{
if(up<=dn && y == *lower_bound(sb+1,sb+1+sb[0],y))
{
y=lower_bound(sb+1,sb+1+sb[0],y)-sb;
set<node>::iterator it = h[y] . upper_bound(node(up-1,0)) , it2;
for(;it!=h[y].end() && (*it).num <= dn;)
{
Q[R++] = (*it).id;
usd[(*it).id]=1;
it2=it,it++;
w[x[(*it2).id]].erase(node(sa[x[(*it2).id]] , (*it2).id));
h[y].erase(it2);
}
}
}
void checkH(LL y,LL up,LL dn)
{
if(up<=dn && y == *lower_bound(sb+1,sb+1+sb[0],y))
{
y=lower_bound(sb+1,sb+1+sb[0],y)-sb;
ans+=upper_bound(H[y].begin(),H[y].end(),dn) - lower_bound(H[y].begin(),H[y].end(),up);
}
}
int main()
{
LL a,b,u,v,tmp;
scanf("%lld%lld%lld",&n,&a,&b);
for(LL i=1;i<=n;i++) scanf("%lld%lld",&u,&v),x[i]=u+v,y[i]=u-v,sa[++sa[0]]=x[i],sb[++sb[0]]=y[i];
tmp = max(abs(x[a] - x[b]) , abs(y[a] - y[b]));
sort(sa+1,sa+1+sa[0]),sort(sb+1,sb+1+sb[0]);
sa[0] = unique(sa+1,sa+1+sa[0]) - sa - 1,
sb[0] = unique(sb+1,sb+1+sb[0]) - sb - 1;
for(LL i=1;i<=n;i++)
{
x[i] = lower_bound(sa+1,sa+1+sa[0],x[i]) - sa;
y[i] = lower_bound(sb+1,sb+1+sb[0],y[i]) - sb;
w[x[i]].insert(node(sb[y[i]],i));
h[y[i]].insert(node(sa[x[i]],i));
W[x[i]].push_back(sb[y[i]]);
H[y[i]].push_back(sa[x[i]]);
}
for(LL i=1;i<=sa[0];i++)
{
w[i].Insert(10000000000ll);
w[i].Insert(-10000000000ll);
W[i].push_back(-10000000000ll);
W[i].push_back(10000000000ll);
sort(W[i].begin(),W[i].end());
}
for(LL i=1;i<=sb[0];i++)
{
h[i].Insert(10000000000ll);
h[i].Insert(-10000000000ll);
H[i].push_back(-10000000000ll);
H[i].push_back(10000000000ll);
sort(H[i].begin(),H[i].end());
}
usd[a] = usd[b] = 1;
Q[R++] = a,Q[R++] = b;
w[x[a]].erase(node(sb[y[a]],a));
w[x[b]].erase(node(sb[y[b]],b));
h[y[a]].erase(node(sa[x[a]],a));
h[y[b]].erase(node(sa[x[b]],b));
for(;L<R;)
{
LL r=Q[L++];
checkw(sa[x[r]] - tmp , sb[y[r]] - tmp , sb[y[r]] + tmp);
checkw(sa[x[r]] + tmp , sb[y[r]] - tmp , sb[y[r]] + tmp);
checkh(sb[y[r]] - tmp , sa[x[r]] - tmp , sa[x[r]] + tmp);
checkh(sb[y[r]] + tmp , sa[x[r]] - tmp , sa[x[r]] + tmp);
}
for(LL i=1;i<=n;i++)
if(usd[i])
{
checkW(sa[x[i]] - tmp , sb[y[i]] - tmp + 1 , sb[y[i]] + tmp);
checkW(sa[x[i]] + tmp , sb[y[i]] - tmp + 1 , sb[y[i]] + tmp);
checkH(sb[y[i]] - tmp , sa[x[i]] - tmp , sa[x[i]] + tmp);
checkH(sb[y[i]] + tmp , sa[x[i]] - tmp + 1 , sa[x[i]] + tmp - 1);
}
printf("%lld\n",ans/2);
}
| a.cc: In function 'int main()':
a.cc:101:14: error: 'class std::set<node>' has no member named 'Insert'; did you mean 'insert'?
101 | w[i].Insert(10000000000ll);
| ^~~~~~
| insert
a.cc:102:14: error: 'class std::set<node>' has no member named 'Insert'; did you mean 'insert'?
102 | w[i].Insert(-10000000000ll);
| ^~~~~~
| insert
a.cc:109:14: error: 'class std::set<node>' has no member named 'Insert'; did you mean 'insert'?
109 | h[i].Insert(10000000000ll);
| ^~~~~~
| insert
a.cc:110:14: error: 'class std::set<node>' has no member named 'Insert'; did you mean 'insert'?
110 | h[i].Insert(-10000000000ll);
| ^~~~~~
| insert
|
s955746473 | p03858 | C++ | #include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=998244353;
int INF=1e6;
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
main(){
int n,a,b;
cin>>n>>a>>b;
int x[110000],y[110000];
rep2(i,1,n){
scanf("%d %d",&x[i],&y[i]);
}
pii sum[110000]={},dif[110000]={};
rep2(i,1,n){
sum[i-1].first=x[i]+y[i]; sum[i-1].second=i;
dif[i-1].first=x[i]-y[i]; dif[i-1].second=i;
}
sort(sum,sum+n);
sort(dif,dif+n);
int flag[110000]={};
flag[a]=flag[b]=1;
queue<int> q;
q.push(a); q.push(b);
int r=abs(x[a]-x[b])+abs(y[a]-y[b]);
int ans=0;
while(!q.empty()){
int t=q.front();
q.pop();
//右上
int temp=x[t]+y[t]+r;
int l=lower_bound(sum,sum+n,make_pair(temp,0))-sum;
int rr=lower_bound(sum,sum+n,make_pair(temp,110000))-sum;
int m=x[t]+r;
rep2(i,l,rr-1){
if(sum[i].first==temp&&x[t]<x[sum[i].second]&&x[sum[i].second]<=m) {
if(flag[sum[i].second])
else {flag[sum[i].second]=1; q.push(sum[i].second);}
}
}
//左下
temp-=2*r;
m=x[t]-r;
l=lower_bound(sum,sum+n,make_pair(temp,0))-sum;
rr=lower_bound(sum,sum+n,make_pair(temp,110000))-sum;
rep2(i,l,rr-1){
if(sum[i].first==temp&&x[t]>x[sum[i].second]&&x[sum[i].second]>=m) {
if(flag[sum[i].second])
else { flag[sum[i].second]=1; q.push(sum[i].second);}
}
}
//左上
temp=x[t]-y[t];
temp-=r;
m=y[t]+r;
l=lower_bound(dif,dif+n,make_pair(temp,0))-dif;
rr=lower_bound(dif,dif+n,make_pair(temp,110000))-dif;
rep2(i,l,rr-1){
if(dif[i].first==temp&&y[t]<y[dif[i].second]&&y[dif[i].second]<=m) {
if(flag[dif[i].second])
else { flag[dif[i].second]=1; q.push(dif[i].second);}
}
}
//右下
temp+=r*2;
m=y[t]-r;
l=lower_bound(dif,dif+n,make_pair(temp,0))-dif;
rr=lower_bound(dif,dif+n,make_pair(temp,110000))-dif;
rep2(i,l,rr-1){
if(dif[i].first==temp&&y[t]>y[dif[i].second]&&
y[dif[i].second]>=m) {
if(flag[dif[i].second])
else { flag[dif[i].second]=1; q.push(dif[i].second);}
}
}
}
cout<<ans/2;
return 0;
} | a.cc:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:45:17: error: expected primary-expression before 'else'
45 | else {flag[sum[i].second]=1; q.push(sum[i].second);}
| ^~~~
a.cc:56:17: error: expected primary-expression before 'else'
56 | else { flag[sum[i].second]=1; q.push(sum[i].second);}
| ^~~~
a.cc:69:17: error: expected primary-expression before 'else'
69 | else { flag[dif[i].second]=1; q.push(dif[i].second);}
| ^~~~
a.cc:81:17: error: expected primary-expression before 'else'
81 | else { flag[dif[i].second]=1; q.push(dif[i].second);}
| ^~~~
|
s820747958 | p03858 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;
ll n;
ll ans;
ll x[100000], y[100000];
ll dx[4] = {1, 1, -1, -1}, dy[4] = {1, -1, 1, -1};
int a, b;
ll dis;
map<P, int> brd;
map<ll, vector<P>> mx;
map<ll, vector<P>> my;
set<ll> sx, sy;
int tox[100000], toy[100000];
bool done[100000];
vector<P> mx[10000];
bool cmp(P l, P r) {
return l.first < r.first;
}
int main(){
memset(tox, -1, sizeof(tox));
memset(toy, -1, sizeof(toy));
cin >> n >> a >> b;
rep(i,n) cin >> x[i] >> y[i];
a--; b--;
rep(i,n) {
ll tmp = x[i]+y[i];
y[i] = x[i]-y[i];
x[i] = tmp;
mx[x[i]].push_back(P(y[i],i));
my[y[i]].push_back(P(x[i],i));
brd[P(x[i],y[i])] = i;
//cout << x[i] << " " << y[i] << endl;
}
dis = max(abs(x[a]-x[b]), abs(y[a]-y[b]));
//cout << dis << endl;
rep(i,n) {
if (!sx.count(x[i])) {
vector<P> tmp = mx[x[i]];
sort(tmp.begin(), tmp.end());
mx[x[i]] = tmp;
sx.insert(x[i]);
}
if (!sy.count(y[i])) {
vector<P> tmp = my[y[i]];
sort(tmp.begin(), tmp.end());
my[y[i]] = tmp;
sy.insert(y[i]);
}
}
vector<ll> p; p.push_back(a); p.push_back(b);
done[a] = true; done[b] = true;
rep(i,p.size()) {
ll px = x[p[i]], py = y[p[i]];
rep(j,4) {
if (brd.count(P(px+dx[j]*dis, py+dy[j]*dis))) {
int tmp = brd[P(px+dx[j]*dis,py+dy[j]*dis)];
ans++;
if (!done[tmp]) {
done[tmp] = true;
p.push_back(tmp);
}
}
}
vector<P>::iterator st, en;
//rep(j,mx[px+dis].size()) cout << "P(" << mx[px+dis][j].first << "," << mx[px+dis][j].second << ") ";
//cout << endl;
//cout << "p " << py-dis+1 << " " << py+dis-1 << endl;
st = lower_bound(mx[px+dis].begin(), mx[px+dis].end(), P(py-dis+1,-1));
en = lower_bound(mx[px+dis].begin(), mx[px+dis].end(), P(py+dis,-1));
int sst = st-mx[px+dis].begin(), een = en-mx[px+dis].begin();
//cout << sst << " " << een << endl;
for (int j = sst; j < een; j++) {
int k = mx[px+dis][j].second;
if (!done[k]) {
done[k] = true;
p.push_back(k);
}
if (tox[k] == -1) tox[k] = een-1;
else {
if (tox[tox[k]] > 0) j = tox[tox[k]];
else j = tox[k];
}
}
ans += een-sst;
//rep(j,mx[px-dis].size()) cout << "P(" << mx[px-dis][j].first << "," << mx[px-dis][j].second << ") ";
//cout << endl;
//cout << "p " << py-dis+1 << " " << py+dis-1 << endl;
st = lower_bound(mx[px-dis].begin(), mx[px-dis].end(), P(py-dis+1,-1));
en = lower_bound(mx[px-dis].begin(), mx[px-dis].end(), P(py+dis,-1));
sst = st-mx[px-dis].begin(), een = en-mx[px-dis].begin();
//cout << sst << " " << een << endl;
for (int j = sst; j < een; j++) {
int k = mx[px-dis][j].second;
if (!done[k]) {
done[k] = true;
p.push_back(k);
}
if (tox[k] == -1) tox[k] = een-1;
else {
if (tox[tox[k]] > 0) j = tox[tox[k]];
else j = tox[k];
}
}
ans += een-sst;
//rep(j,my[py+dis].size()) cout << "P(" << my[py+dis][j].first << "," << my[py+dis][j].second << ") ";
//cout << endl;
//cout << "p " << px-dis+1 << " " << px+dis-1 << endl;
st = lower_bound(my[py+dis].begin(), my[py+dis].end(), P(px-dis+1,-1));
en = lower_bound(my[py+dis].begin(), my[py+dis].end(), P(px+dis,-1));
sst = st-my[py+dis].begin(), een = en-my[py+dis].begin();
//cout << sst << " " << een << endl;
for (int j = sst; j < een; j++) {
int k = my[py+dis][j].second;
if (!done[k]) {
done[k] = true;
p.push_back(k);
}
if (toy[k] == -1) toy[k] = een-1;
else {
if (toy[toy[k]] > 0) j = toy[toy[k]];
else j = toy[k];
}
}
ans += een-sst;
//rep(j,my[py-dis].size()) cout << "P(" << my[py-dis][j].first << " " << my[py-dis][j].second << ") ";
//cout << endl;
//cout << "p " << px-dis+1 << " " << px+dis-1 << endl;
st = lower_bound(my[py-dis].begin(), my[py-dis].end(), P(px-dis+1,-1));
en = lower_bound(my[py-dis].begin(), my[py-dis].end(), P(px+dis,-1));
sst = st-my[py-dis].begin(), een = en-my[py-dis].begin();
//cout << sst << " " << een << endl;
for (int j = sst; j < een; j++) {
int k = my[py-dis][j].second;
if (!done[k]) {
done[k] = true;
p.push_back(k);
}
if (toy[k] == -1) toy[k] = een-1;
else {
if (toy[toy[k]] > 0) j = toy[toy[k]];
else j = toy[k];
}
}
ans += een-sst;
}
cout << ans/2 << endl;
}
| a.cc:23:11: error: conflicting declaration 'std::vector<std::pair<long long int, long long int> > mx [10000]'
23 | vector<P> mx[10000];
| ^~
a.cc:18:20: note: previous declaration as 'std::map<long long int, std::vector<std::pair<long long int, long long int> > > mx'
18 | map<ll, vector<P>> mx;
| ^~
|
s997685498 | p03858 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define inf 1000000007000000007
typedef long long ll;
using namespace std;
typedef pair<ll,ll> P;
set<P> datx,daty,setx,sety;
set<P>::iterator ita,itb;
queue<P> Q;
ll ans=0,k;
void BFS(ll x,ll y){
ita=lower_bound(datx.begin(),datx.end(),make_pair(x-k,inf));
itb=lower_bound(datx.begin(),datx.end(),make_pair(x-k,-inf));
ans+=ita-itb;
ita=lower_bound(setx.begin(),setx.end(),make_pair(x-k,-inf));
while(ita<setx.end()){
if(ita->first>x-k)break;
Q.push(make_pair(ita->first,ita->second));
setx.erase(make_pair(ita->first,ita->second));
sety.erase(make_pair(ita->second,ita->first));
ita++;
}
ita=lower_bound(datx.begin(),datx.end(),make_pair(x+k,inf));
itb=lower_bound(datx.begin(),datx.end(),make_pair(x+k,-inf));
ans+=ita-itb;
ita=lower_bound(setx.begin(),setx.end(),make_pair(x+k,-inf));
while(ita<setx.end()){
if(ita->first>x+k)break;
Q.push(make_pair(ita->first,ita->second));
setx.erase(make_pair(ita->first,ita->second));
sety.erase(make_pair(ita->second,ita->first));
ita++;
}
ita=lower_bound(daty.begin(),daty.end(),make_pair(y-k,inf));
itb=lower_bound(daty.begin(),daty.end(),make_pair(y-k,-inf));
ans+=ita-itb;
ita=lower_bound(sety.begin(),sety.end(),make_pair(y-k,-inf));
while(ita<sety.end()){
if(ita->first>y-k)break;
Q.push(make_pair(ita->second,ita->first));
setx.erase(make_pair(ita->second,ita->first));
sety.erase(make_pair(ita->first,ita->second));
ita++;
}
ita=lower_bound(daty.begin(),daty.end(),make_pair(y+k,inf));
itb=lower_bound(daty.begin(),daty.end(),make_pair(y+k,-inf));
ans+=ita-itb;
ita=lower_bound(sety.begin(),sety.end(),make_pair(y+k,-inf));
while(ita<sety.end()){
if(ita->first>y+k)break;
Q.push(make_pair(ita->second,ita->first));
setx.erase(make_pair(ita->second,ita->first));
sety.erase(make_pair(ita->first,ita->second));
ita++;
}
}
int main(){
int n,f,g;
cin>>n>>f>>g;f--,g--;
ll sx,sy,gx,gy;
lol(i,n){
int x,y;cin>>x>>y;
datx.insert(make_pair(x,y));
daty.insert(make_pair(y,x));
setx.insert(make_pair(x,y));
sety.insert(make_pair(y,x));
if(i==f){Q.push(make_pair(x,y));sx=x,sy=y;}
if(j==g){Q.push(make_pair(x,y));gx=x,gy=y;}
}
k=abs(sx-gx)+abs(sy-gy);
while(!Q.empty()){
int x=Q.front.first;
int y=Q.front.second;
Q.pop();
BFS(x,y);
}
cout<<ans/2<<endl;
return 0;
} | a.cc: In function 'void BFS(ll, ll)':
a.cc:23:17: error: no match for 'operator-' (operand types are 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} and 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'})
23 | ans+=ita-itb;
| ~~~^~~~
| | |
| | _Rb_tree_const_iterator<[...]>
| _Rb_tree_const_iterator<[...]>
In file included from /usr/include/c++/14/string:48,
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_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
618 | operator-(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed:
a.cc:23:18: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
23 | ans+=ita-itb;
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1790 | operator-(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed:
a.cc:23:18: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
23 | ans+=ita-itb;
| ^~~
In file included from a.cc:6:
/usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)'
370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed:
a.cc:23:18: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::complex<_Tp>'
23 | ans+=ita-itb;
| ^~~
/usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)'
379 | operator-(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed:
a.cc:23:18: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::complex<_Tp>'
23 | ans+=ita-itb;
| ^~~
/usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)'
388 | operator-(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed:
a.cc:23:18: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::complex<_Tp>'
23 | ans+=ita-itb;
| ^~~
/usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)'
465 | operator-(const complex<_Tp>& __x)
| ^~~~~~~~
/usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided
a.cc:25:18: error: no match for 'operator<' (operand types are 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} and 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'})
25 | while(ita<setx.end()){
| ~~~^~~~~~~~~~~
| | |
| | _Rb_tree_const_iterator<[...]>
| _Rb_tree_const_iterator<[...]>
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:25:28: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
25 | while(ita<setx.end()){
| ^
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:25:28: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
25 | while(ita<setx.end()){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:25:28: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
25 | while(ita<setx.end()){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:25:28: note: 'std::set<std::pair<long long int, long long int> >::iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long |
s912476697 | p03858 | C++ | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
vector<P> vx[N], vy[N];
vector<ll> x, y, x2, y2, x3, y3;
ll n, a, b, d;
map<P, ll> cnt;
map<ll, ll> ix, iy;
bool used[N];
set<P> usedx[N], usedy[N];
ll dist(int a, int b){
return max(abs(x[a]-x[b]), abs(y[a]-y[b]));
}
void comp(vector<int> &x, const vector<int> &y, vector<int> &z, map<ll, ll> &ix){
z = vector<int>(y);
sort(all(z));
UNIQUE(z);
x = vector<int>(y.size());
rep(i, y.size()){
x[i] = lower_bound(z.begin(), z.end(), y[i])-z.begin();
}
rep(i, z.size()) ix[z[i]] = i;
}
int main(){
cin>>n>>a>>b; a--; b--;
x = y = vector<int>(n);
rep(i, n){
ll xx, yy;
cin>>xx>>yy;
x[i] = xx+yy;
y[i] = xx-yy;
++cnt[P(x[i], y[i])];
}
d = dist(a, b);
comp(x2, x, x3, ix); comp(y2, y, y3, iy);
rep(i, n){
vy[x2[i]].push_back(P(y[i], i));
vx[y2[i]].push_back(P(x[i], i));
}
rep(i, x3.size()) sort(all(vy[i]));
rep(i, y3.size()) sort(all(vx[i]));
ll res = 0;
queue<int> q;
q.push(a);
used[a] = true;
while(!q.empty()){
int u = q.front(); q.pop();
ll lx = x[u]-d, rx = lx+2*d, ly = y[u]-d, ry = ly+2*d;;
for(ll xx = lx; xx <= rx; xx+=2*d){
if(!ix.count(xx)) continue;
int px = ix[xx];
ll l = lower_bound(all(vy[px]), P(ly+1, 0))-vy[px].begin();
ll r = upper_bound(all(vy[px]), P(ry-1, INF))-vy[px].begin();
//cerr<<u<<" "<<l<<" "<<r<<endl;
//cerr<<xx<<" "<<vy[px].size()<<endl;
res += r-l;
//res -= cnt[P(xx, ly)]+cnt[P(xx, ry)];
auto p = usedy[px].lower_bound(P(l, 0));
auto p2 = p;
if(p2!=usedy[px].begin()) --p2;
if(p!=usedy[px].end()) r = min(r, p->fst);
if(p2!=usedy[px].end()) l = max(l, p2->snd);
if(l<r) usedy[px].insert(P(l, r));
for(int i = l; i < r; i++){
int v = vy[px][i].snd;
if(used[v]) continue;
used[v] = true;
q.push(v);
}
}
for(ll yy = ly; yy <= ry; yy+=2*d){
if(!iy.count(yy)) continue;
int py = iy[yy];
ll l = lower_bound(all(vx[py]), P(lx, 0))-vx[py].begin();
ll r = upper_bound(all(vx[py]), P(rx, INF))-vx[py].begin();
res += r-l;
auto p = usedx[py].lower_bound(P(l, 0));
auto p2 = p;
if(p2!=usedx[py].begin()) --p2;
if(p!=usedx[py].end()) r = min(r, p->fst);
if(p2!=usedx[py].end()) l = max(l, p2->snd);
if(l<r) usedx[py].insert(P(l, r));
for(int i = l; i < r; i++){
int v = vx[py][i].snd;
if(used[v]) continue;
used[v] = true;
q.push(v);
}
}
//cout<<u<<"'s res: "<<res-res2<<endl;
}
cout<<res/2<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:67:30: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
67 | x = y = vector<int>(n);
| ^
In file included from /usr/include/c++/14/vector:72,
from /usr/include/c++/14/functional:64,
from a.cc:9:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:76:14: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
76 | comp(x2, x, x3, ix); comp(y2, y, y3, iy);
| ^~
a.cc:54:24: note: in passing argument 1 of 'void comp(std::vector<int>&, const std::vector<int>&, std::vector<int>&, std::map<long long int, long long int>&)'
54 | void comp(vector<int> &x, const vector<int> &y, vector<int> &z, map<ll, ll> &ix){
| ~~~~~~~~~~~~~^
a.cc:76:35: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
76 | comp(x2, x, x3, ix); comp(y2, y, y3, iy);
| ^~
a.cc:54:24: note: in passing argument 1 of 'void comp(std::vector<int>&, const std::vector<int>&, std::vector<int>&, std::map<long long int, long long int>&)'
54 | void comp(vector<int> &x, const vector<int> &y, vector<int> &z, map<ll, ll> &ix){
| ~~~~~~~~~~~~~^
|
s717439667 | p03858 | C++ | #include "IntMod.h"
typedef IntMod<1000000007> MInt;
//#include "Union_Find.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先
#endif
struct CompBySecond {
bool operator()(const PP& a, const PP& b) const {
return a.second < b.second || (a.second == b.second && a.first < b.first);
}
};
template<class T>
class Array {
T* ptr_m;
size_t size_m;
};
//#include "Union_Find.h"
int N, K, A, B;
PP S;
set<PP> XS;
set<PP, CompBySecond> YS;
PP X[100001];
PP Y[100001];
bool used[100001];
queue<PP> Q;
void sub(set<PP>::iterator lit, set<PP>::iterator rit, bool x) {
for (auto it = lit; it != rit; ++it) {
x ? YS.erase(*it) : XS.erase(*it);
Q.push(*it);
}
x ? XS.erase(lit, rit) : YS.erase(lit, rit);
}
int solve() {
Q.push(S);
while (!Q.empty()) {
PP p = Q.front(); Q.pop();
LL l = p.first - K, r = p.first + K, d = p.second - K, u = p.second + K;
PP ld = PP(l, d), lu = PP(l, u), rd = PP(r, d), ru = PP(r, u);
sub(XS.lower_bound(ld), XS.upper_bound(lu), true);
sub(XS.lower_bound(rd), XS.upper_bound(ru), true);
sub(YS.upper_bound(ld), YS.lower_bound(rd), false);
sub(YS.upper_bound(lu), YS.lower_bound(ru), false);
}
Fill(used, true);
for (PP p : XS) {
used[find(X, X + N, p) - X] = false;
}
LL count = 0;
REP(i, 0, N) {
if (!used[i]) continue;
PP p = X[i];
LL l = p.first - K, r = p.first + K, d = p.second - K, u = p.second + K;
count += upper_bound(X, X + N, PP(l, u)) - lower_bound(X, X + N, PP(l, d));
count += upper_bound(X, X + N, PP(r, u)) - lower_bound(X, X + N, PP(r, d));
count += lower_bound(Y, Y + N, PP(r, d), CompBySecond()) - upper_bound(Y, Y + N, PP(l, d), CompBySecond());
count += lower_bound(Y, Y + N, PP(r, u), CompBySecond()) - upper_bound(Y, Y + N, PP(l, u), CompBySecond());
}
return count / 2;
}
int main() {
cin >> N >> A >> B;
--A; --B;
REP(i, 0, N) {
int x, y;
cin >> x >> y;
PP p{ x + y, x - y };
X[i] = Y[i] = p;
XS.insert(p);
YS.insert(p);
}
S = X[A];
K = max(abs(X[A].first - X[B].first), abs(X[A].second - X[B].second));
sort(X, X + N);
sort(Y, Y + N, CompBySecond());
cout << solve() << endl;
return 0;
} | a.cc:1:10: fatal error: IntMod.h: No such file or directory
1 | #include "IntMod.h"
| ^~~~~~~~~~
compilation terminated.
|
s149508734 | p03858 | C++ | #include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <set>
using namespace std;//(|xa-xb|==d&&|ya-yb|[-d,d])||(|xa-xb|[-d,d]&&|ya-yb|==d)
const int N=100001;
int n,a,b,mx=0,my=0,ans=0;
int head[N],next[2*N],adj[2*N],tot=0;
int f[N];
set <pair<int,int> > s;
int findr(int x)
{
if(x==f[x]) return f[x];
return f[x]=findr(f[x]);
}
void uniont(int x,int y)
{
if(findr(x)!=findr(y))
f[findr(x)]=findr(y);
return;
}
struct node
{
int x;
int y;
int s;
bool operator<(const node &p)const
{
if(x<p.x) return true;
if(x==p.x&&y<p.y) return true;
return false;
};
}t[N];
void addedge(int u,int v)
{
tot++;
next[tot]=head[u];
adj[tot]=v;
head[u]=tot;
return;
}
int finds(int x,int l,int r)
{
int le=l,ri=r;
while(le<=ri)
{
int mid=(le+ri)/2;
if(t[mid].x>=x) ri=mid-1;
else le=mid+1;
}
return le;
}
int findt(int x,int l,int r)
{
int le=l,ri=r;
while(le<=ri)
{
int mid=(le+ri)/2;
if(t[mid].x>x) ri=mid-1;
else le=mid+1;
}
return ri;
}
int ss(int x,int l,int r)
{
int le=l,ri=r;
while(le<=ri)
{
int mid=(le+ri)/2;
if(t[mid].y>=x) ri=mid-1;
else le=mid+1;
}
return le;
}
int st(int x,int l,int r)
{
int le=l,ri=r;
while(le<=ri)
{
int mid=(le+ri)/2;
if(t[mid].y>x) ri=mid-1;
else le=mid+1;
}
return ri;
}
int cmp(const void *a,const void *b)
{
struct node *c=(node *)a;
struct node *d=(node *)b;
if(c->y>d->y) return true;
if(c->y==d->y&&c->x>d->x) return true;
return false;
}
int main()
{
int i,j,d,tmp,in,out;
cin>>n>>a>>b;
for(i=1;i<=n;i++)
f[i]=i;
for(i=1;i<=n;i++)
{
scanf("%d %d",&t[i].x,&t[i].y);
tmp=t[i].x+t[i].y;
t[i].y=t[i].x-t[i].y;
t[i].x=tmp;
t[i].s=i;
mx=max(mx,t[i].x);
my=max(my,t[i].y);
}
d=max(abs(t[a].x-t[b].x),abs(t[a].y-t[b].y));
sort(t+1,t+n+1);
for(i=1;i<=n;i++)
{
if(t[i].x+d>mx) continue;
in=finds(t[i].x+d,1,n),out=findt(t[i].x+d,1,n);
if((t[in].x-t[i].x)!=d) continue;
int x1=ss(t[i].y-d,in,out),x2=st(t[i].y+d,in,out);
if(x2<x1) continue;
uniont(t[i].s,t[x1].s);
for(j=x1;j<x2;j++)
uniont(t[j].s,t[j+1].s);
for(j=x1;j<=x2;j++)
s.insert(make_pair(max(t[i].s,t[j].s),min(t[i].s,t[j].s)));
}
qsort(t+1,n,sizeof(t[0]),cmp);
for(i=1;i<=n;i++)
{
if(t[i].y+d>my) continue;
in=ss(t[i].y+d,1,n),out=st(t[i].y+d,1,n);
if((t[in].y-t[i].y)!=d) continue;
int x1=finds(t[i].x-d,in,out),x2=findt(t[i].x+d,in,out);
if(x2<x1) continue;
uniont(t[i].s,t[x1].s);
for(j=x1;j<x2;j++)
uniont(t[j].s,t[j+1].s);
for(j=x1;j<=x2;j++)
s.insert(make_pair(max(t[i].s,t[j].s),min(t[i].s,t[j].s)));
}
int num=findr(a);
for(set<pair<int,int> >::iterator l=s.begin();l!=s.end();l++)
if(findr(l->first)==findr(l->second)&&findr(l->first)==num)
ans++;
//cout<<l->first<<' '<<l->second<<endl;
cout<<ans;
return 0;
} | a.cc: In function 'void addedge(int, int)':
a.cc:42:5: error: reference to 'next' is ambiguous
42 | next[tot]=head[u];
| ^~~~
In file included from /usr/include/c++/14/string:47,
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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:13:13: note: 'int next [200002]'
13 | int head[N],next[2*N],adj[2*N],tot=0;
| ^~~~
|
s220085532 | p03858 | C++ | /*
%Dalao
--InterestingLSY
*/
/*
代码长度 - -
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define INF 9999999
#define LINF 9999999999999999
#define uint unsigned int
#define msn(a,v) memset(a,v,sizeof(a))
#define ms(a) msn(a,0)
#define NONE -1
#define ll long long
#define ull unsignedll
#define lb lower_bound
using namespace std;
#define MAXN 100010
int n,D,a,b;
/*****************************************/
class Dot{
public:
int x;int y;int id;
void read(int i){
scanf("%d%d",&x,&y);
id=i;
}
void rotate(){
int xx=x+y,yy=x-y;
x=xx;y=yy;
}
void chg(){
swap(x,y);
}
};Dot dot[MAXN];
Dot getdot(int x,int y,int id){
Dot d1;
d1.x=x;d1.y=y;d1.id=id;
return d1;
}
bool operator<(Dot d1,Dot d2){
if(d1.x!=d2.x)return d1.x<d2.x;
if(d1.y!=d2.y)return d1.y<d2.y;
return d1.id<d2.id;
}
int dsu[MAXN];
void init(){
for(int i=1;i<=n;i++)
dsu[i]=i;
}
int getfa(int pos){
if(dsu[pos]==pos)return pos;
dsu[pos]=getfa(dsu[pos]);
return dsu[pos];
}
void unite(int a,int b){
a=getfa(a);b=getfa(b);
dsu[a]=b;
}
int same(int a,int b){
return getfa(a)==getfa(b);
}
int s(int v){
if(v)return INF;
return v;
}
int du[MAXN];
void getdu(){
ms(du);
for(int j=0;j<2;j++){
sort(dot,dot+n);
for(int i=0;i<n;i++)
du[dot[i].id]+=
(lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y+D,s(!j)))-dot)-
(lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y-D,s(j)))-dot)+
(lb(dot,dot+n,getdot(dot[i].x+D,dot[i].y+D,s(!j)))-dot)-
(lb(dot,dot+n,getdot(dot[i].x+D,dot[i].y-D,s(j)))-dot)
;
if(j==1)return;
for(int i=0;i<n;i++)dot[i].chg();
}
}
void getlian(){
init();
int sum[MAXN];
for(int j=0;j<2;j++){
ms(sum);
sort(dot,dot+n);
for(int i=0;i<n;i++){
int u=lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y-D,0))-dot;
int d=lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y+D,INF))-dot;
if(u==d)continue;
unite(dot[u].id,dot[i].id);
sum[u]++;sum[d-1]--;
}
for(int i=0;i<n;i++){
if(i)sum[i]+=sum[i-1];
if(sum[i])unite(dot[i].id,dot[i+1].id);
}
if(j==1)return;
for(int i=0;i<n;i++)dot[i].chg();
}
}
/************************************************
所有数组下标都从0开始
************************************************/
intmain(){
freopen("E.txt","r",stdin);
scanf("%d%d%d",&n,&a,&b);
for(int i=0;i<n;i++)
dot[i].read(i);
a--;b--;
D=abs(dot[a].x-dot[b].x)+abs(dot[a].y-dot[b].y);
for(int i=0;i<n;i++)
dot[i].rotate();
getdu();
getlian();
ll ans=0;
for(int i=0;i<n;i++)
if(same(i,a))
ans+=du[i];
ans/=2;
printf("%lld\n",ans);
return 0;
} | a.cc:119:1: error: ISO C++ forbids declaration of 'intmain' with no type [-fpermissive]
119 | intmain(){
| ^~~~~~~
|
s470665860 | p03858 | C++ | #include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
vector<P> xys;
vector<P> yxs;
set<P> visited;
P rev(P s) {
return P(s.second, s.first);
}
int main(void) {
int n,a,b;
scanf("%d%d%d", &n, &a, &b);
for(int i=0; i<n; i++) {
int x,y;
scanf("%d%d", &x, &y);
xys.push_back( P(x+y, x-y) );
yxs.push_back( P(x-y, x+y) );
}
P axy = xys[a-1];
P bxy = xys[b-1];
int dis = max( abs(axy.first - bxy.first), abs(axy.second - bxy.second) );
sort(begin(xys), end(xys));
sort(begin(yxs), end(yxs));
queue<P> q;
q.push( axy );
visited.insert( axy );
int res=0;
while(!q.empty()) {
P fir = q.front(); q.pop();
auto ub = upper_bound( xys.begin(), xys.end(), P( fir.first - dis, fir.second + dis));
for(auto p = lower_bound( xys.begin(), xys.end(), P( fir.first - dis, fir.second - dis ));
p != ub;
p++) {
res++;
if(visited.insert((*p)).second)
q.push((*p));
}
}
ub = upper_bound( yxs.begin(), yxs.end(), P( fir.second - dis, fir.first + dis - 1));
for(auto p = lower_bound( yxs.begin(), yxs.end(), P( fir.second - dis, fir.first - dis + 1));
p != ub;
p++) {
res++;
if(visited.insert(rev(*p)).second)
q.push(rev(*p));
}
}
ub = upper_bound( xys.begin(), xys.end(), P( fir.first + dis, fir.second + dis));
for(auto p = lower_bound( xys.begin(), xys.end(), P( fir.first + dis, fir.second - dis ));
p != ub;
p++) {
res++;
if(visited.insert((*p)).second)
q.push((*p));
}
}
ub = upper_bound( yxs.begin(), yxs.end(), P( fir.second + dis, fir.first + dis - 1));
for(auto p = lower_bound( yxs.begin(), yxs.end(), P( fir.second + dis, fir.first - dis + 1));
p != ub;
p++) {
res++;
if(visited.insert(rev(*p)).second)
q.push(rev(*p));
}
}
}
printf("%d\n", res/2);
return 0;
}
| a.cc: In function 'int main()':
a.cc:56:9: error: 'ub' was not declared in this scope; did you mean 'b'?
56 | ub = upper_bound( yxs.begin(), yxs.end(), P( fir.second - dis, fir.first + dis - 1));
| ^~
| b
a.cc:56:54: error: 'fir' was not declared in this scope
56 | ub = upper_bound( yxs.begin(), yxs.end(), P( fir.second - dis, fir.first + dis - 1));
| ^~~
a.cc: At global scope:
a.cc:65:9: error: 'ub' does not name a type
65 | ub = upper_bound( xys.begin(), xys.end(), P( fir.first + dis, fir.second + dis));
| ^~
a.cc:66:9: error: expected unqualified-id before 'for'
66 | for(auto p = lower_bound( xys.begin(), xys.end(), P( fir.first + dis, fir.second - dis ));
| ^~~
a.cc:67:17: error: 'p' does not name a type
67 | p != ub;
| ^
a.cc:68:17: error: 'p' does not name a type
68 | p++) {
| ^
a.cc:73:9: error: expected declaration before '}' token
73 | }
| ^
a.cc:74:9: error: 'ub' does not name a type
74 | ub = upper_bound( yxs.begin(), yxs.end(), P( fir.second + dis, fir.first + dis - 1));
| ^~
a.cc:75:9: error: expected unqualified-id before 'for'
75 | for(auto p = lower_bound( yxs.begin(), yxs.end(), P( fir.second + dis, fir.first - dis + 1));
| ^~~
a.cc:76:17: error: 'p' does not name a type
76 | p != ub;
| ^
a.cc:77:17: error: 'p' does not name a type
77 | p++) {
| ^
a.cc:82:9: error: expected declaration before '}' token
82 | }
| ^
a.cc:83:5: error: expected declaration before '}' token
83 | }
| ^
a.cc:84:11: error: expected constructor, destructor, or type conversion before '(' token
84 | printf("%d\n", res/2);
| ^
a.cc:85:5: error: expected unqualified-id before 'return'
85 | return 0;
| ^~~~~~
a.cc:86:1: error: expected declaration before '}' token
86 | }
| ^
|
s386614118 | p03858 | C++ | #include <cmath>
#include <iostream>
#include <vector>
class DisjointSet {
public:
std::vector<unsigned> parent;
std::vector<unsigned> rank;
DisjointSet(unsigned size)
: parent(size),
rank(size, 0u) {
for (unsigned i = 0; i < size; ++i) { parent[i] = i; }
}
unsigned find(unsigned index) {
if (parent[index] != index) { return parent[index] = find(parent[index]); }
else { return index; }
}
void merge(unsigned index_a, unsigned index_b) {
auto parent_a = find(index_a);
auto parent_b = find(index_b);
if (parent_a == parent_b) { return; }
if (rank[parent_a] < rank[parent_b]) { parent[parent_a] = parent_b; }
else if (rank[parent_b] < rank[parent_b]) { parent[parent_b] = parent_a; }
else {
++rank[parent_a];
parent[parent_b] = parent_a;
}
}
};
template<class T>
class FenwickTree {
public:
std::vector<T> data;
FenwickTree<T>(unsigned size) : data(size + 1u, 0) {}
T sum(unsigned index) {
++index;
T ret = 0;
while (index) {
ret += data[index];
index &= index - 1u;
}
return ret;
}
void add(unsigned index, T x) {
++index;
while (index < data.size()) {
data[index] += x;
index += index & (~index + 1u);
}
}
};
int main() {
unsigned N, a, b;
std::cin >> N >> a >> b;
--a;
--b;
std::vector<std::pair<std::pair<int, int>, unsigned>> hole(N);
for (unsigned i = 0; i < N; ++i) {
unsigned x, y;
std::cin >> x >> y;
hole[i].first.first = x + y;
hole[i].first.second = x - y;
hole[i].second = i;
}
auto D = std::max(std::abs(hole[a].first.first - hole[b].first.first),
std::abs(hole[a].first.second - hole[b].first.second));
auto cmp_first = [](std::pair<std::pair<int, int>, unsigned> i,
std::pair<std::pair<int, int>, unsigned> j) -> bool {
return (i.first.first < j.first.first) || (i.first.first == j.first.first && i.first.second < j.first.second);
};
auto cmp_second = [](std::pair<std::pair<int, int>, unsigned> i,
std::pair<std::pair<int, int>, unsigned> j) -> bool {
return (i.first.second < j.first.second) || (i.first.second == j.first.second && i.first.first < j.first.first);
};
std::sort(hole.begin(), hole.end(), cmp_first);
//countするだけじゃなくて、union findとかで連結成分の管理もちゃんとしないとこんがらがりそう
//addした順にdfsっぽくfenwick treeにaddしても良いかもね
FenwickTree<long long> fenwickTree0(N+1);
FenwickTree<long long> fenwickTree1(N+1);
DisjointSet disjointSet(N+1);
std::vector<long long> degree(N, 0);
auto prev_p = hole.begin();
for (unsigned i = 0; i < N; ++i) {
auto key = std::make_pair(std::make_pair(hole[i].first.first + D, hole[i].first.second - D), 0);
auto pl = std::lower_bound(hole.begin(), hole.end(), key, cmp_first);
key.first.second += 2 * D - 1;
auto pu = std::upper_bound(hole.begin(), hole.end(), key, cmp_first);
fenwickTree0.add((unsigned int) (pl - hole.begin()), 1);
fenwickTree0.add((unsigned int) (pu - hole.begin()), -1);
for (auto p = std::max(prev_p, pl); p < pu; ++p) {
disjointSet.merge(hole[i].second, p->second);
}
prev_p = pu - pl > 0 ? pu - 1 : pu;
}
for (unsigned i = 0; i < N; ++i) {
degree[hole[i].second] += fenwickTree0.sum(i);
}
std::sort(hole.begin(), hole.end(), cmp_second);
prev_p = hole.begin();
//(0,2) or (2,0)がない
for (unsigned i = 0; i < N; ++i) {
auto key = std::make_pair(std::make_pair(hole[i].first.first - D + 1, hole[i].first.second + D), 0);
auto pl = std::lower_bound(hole.begin(), hole.end(), key, cmp_second);
key.first.first += 2 * D;
auto pu = std::upper_bound(hole.begin(), hole.end(), key, cmp_second);
fenwickTree1.add((unsigned int) (pl - hole.begin()), 1);
fenwickTree1.add((unsigned int) (pu - hole.begin()), -1);
for (auto p = std::max(prev_p, pl); p < pu; ++p) {
disjointSet.merge(hole[i].second, p->second);
}
prev_p = pu - pl > 0 ? pu - 1 : pu;
}
for (unsigned i = 0; i < N; ++i) {
degree[hole[i].second] += fenwickTree1.sum(i);
}
auto k = disjointSet.find(a);
long long ans = 0;
for (unsigned i = 0; i < N; ++i) {
if (k == disjointSet.find(i)) {
ans += degree[i];
}
}
std::cout << ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:77:8: error: 'sort' is not a member of 'std'; did you mean 'sqrt'?
77 | std::sort(hole.begin(), hole.end(), cmp_first);
| ^~~~
| sqrt
a.cc:87:31: error: no matching function for call to 'lower_bound(std::vector<std::pair<std::pair<int, int>, unsigned int> >::iterator, std::vector<std::pair<std::pair<int, int>, unsigned int> >::iterator, std::pair<std::pair<int, int>, int>&, main()::<lambda(std::pair<std::pair<int, int>, unsigned int>, std::pair<std::pair<int, int>, unsigned int>)>&)'
87 | auto pl = std::lower_bound(hole.begin(), hole.end(), key, cmp_first);
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
1530 | lower_bound(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate expects 3 arguments, 4 provided
a.cc:89:20: error: 'upper_bound' is not a member of 'std'; did you mean 'lower_bound'?
89 | auto pu = std::upper_bound(hole.begin(), hole.end(), key, cmp_first);
| ^~~~~~~~~~~
| lower_bound
a.cc:100:8: error: 'sort' is not a member of 'std'; did you mean 'sqrt'?
100 | std::sort(hole.begin(), hole.end(), cmp_second);
| ^~~~
| sqrt
a.cc:105:31: error: no matching function for call to 'lower_bound(std::vector<std::pair<std::pair<int, int>, unsigned int> >::iterator, std::vector<std::pair<std::pair<int, int>, unsigned int> >::iterator, std::pair<std::pair<int, int>, int>&, main()::<lambda(std::pair<std::pair<int, int>, unsigned int>, std::pair<std::pair<int, int>, unsigned int>)>&)'
105 | auto pl = std::lower_bound(hole.begin(), hole.end(), key, cmp_second);
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
1530 | lower_bound(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate expects 3 arguments, 4 provided
a.cc:107:20: error: 'upper_bound' is not a member of 'std'; did you mean 'lower_bound'?
107 | auto pu = std::upper_bound(hole.begin(), hole.end(), key, cmp_second);
| ^~~~~~~~~~~
| lower_bound
|
s922481077 | p03858 | C++ | #include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long lli;
lli n,a,b;
vector<pair<lli,lli> > c;
map<pair<lli,lli>,lli> cx;
map<pair<lli,lli>,lli> cy;
vector<pair<lli,lli> > k;
lli d;
vector<lli> counter;
lli ans = 0;
void dfs(lli x){
pair<lli,lli> o = c[x];
cx.erase(o);cy.erase(make_pair(o.second,o.first*-1));
ans += counter[x];
while(cx.lower_bound(make_pair(o.first-d,o.second-d)) != cx.upper_bound(make_pair(o.first-d,o.second+d-1))){
dfs(cx.lower_bound(make_pair(o.first-d,o.second-d))->second);
}
while(cx.lower_bound(make_pair(o.first+d,o.second-d+1)) != cx.upper_bound(make_pair(o.first+d,o.second+d))){
dfs(cx.lower_bound(make_pair(o.first+d,o.second-d+1))->second);
}
swap(o.first,o.second);o.second*=-1;
while(cy.lower_bound(make_pair(o.first-d,o.second-d)) != cy.upper_bound(make_pair(o.first-d,o.second+d-1))){
dfs(cy.lower_bound(make_pair(o.first-d,o.second-d))->second);
}
while(cy.lower_bound(make_pair(o.first+d,o.second-d+1)) != cy.upper_bound(make_pair(o.first+d,o.second+d))){
dfs(cy.lower_bound(make_pair(o.first+d,o.second-d+1))->second);
}
}
int main(int argc, char const *argv[]) {
cin >> n >> a >> b;
c = vector<pair<lli,lli> > (n);
for(lli i = 0;i < n;i++){
lli x,y;
cin >> x >> y;
c[i].first = x + y;
c[i].second = x - y;
cx[c[i]] = i;
cy[make_pair(c[i].second,c[i].first*-1)] = i;
}
a--;b--;
d = max(abs(c[a].first - c[b].first),abs(c[a].second - c[b].second));
counter = vector<lli> (n);
k = c;
sort(k.begin(),k.end());
for(lli i = 0;i < n;i++){
lli t = cx[k[i]];
counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second-d+1)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second+d));
}
for(lli i = 0;i < n;i++) swap(k[i].first,k[i].second),k[i].second*=-1;
sort(k.begin(),k.end());
for(lli i = 0;i < n;i++){
lli t = cy[k[i]];
counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second-d+1)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second+d));
}
dfs(a);
cout << -ans/2 << endl;
return 0;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:48:5: error: 'sort' was not declared in this scope; did you mean 'short'?
48 | sort(k.begin(),k.end());
| ^~~~
| short
a.cc:51:94: error: 'upper_bound' was not declared in this scope
51 | counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
| ^~~~~~~~~~~
a.cc:58:94: error: 'upper_bound' was not declared in this scope
58 | counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
| ^~~~~~~~~~~
|
s170760976 | p03858 | C++ | #include <iostream>
#include <map>
#include <set>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 1e6;
int n, a, b;
int x[100000];
int y[100000];
int d;
int c[100000];
map<int, set<P>> p, q;
map<int, vector<int>> f, g;
int u[100000];
vector<int>::iterator lb(vector<int>& v, int x){
return lower_bound(v.begin(), v.end(), x);
}
vector<int>::iterator ub(vector<int>& v, int x){
return upper_bound(v.begin(), v.end(), x);
}
void dfsall(set<P>::iterator b, set<P>::iterator a);
void dfs(int i){
u[i] = 1;
p[x[i]].erase(p[x[i]].lower_bound(P(y[i], -inf)), p[x[i]].upper_bound(P(y[i], inf)));
q[y[i]].erase(q[y[i]].lower_bound(P(x[i], -inf)), q[y[i]].upper_bound(P(x[i], inf)));
dfsall(p[x[i] - d].upper_bound(P(y[i] + d, inf)), p[x[i] - d].lower_bound(P(y[i] - d, -inf)));
dfsall(p[x[i] + d].upper_bound(P(y[i] + d, inf)), p[x[i] + d].lower_bound(P(y[i] - d, -inf)));
dfsall(q[y[i] - d].lower_bound(P(x[i] + d, -inf)), q[y[i] - d].upper_bound(P(x[i] - d, inf)));
dfsall(q[y[i] + d].lower_bound(P(x[i] + d, -inf)), q[y[i] + d].upper_bound(P(x[i] - d, inf)));
}
void dfsall(set<P>::iterator b, set<P>::iterator a){
vector<P> v(a, b);
for(P& x: v){
dfs(x.second);
}
}
int main(){
cin >> n >> a >> b;
--a;
--b;
rep(i, n){
int p, q;
cin >> p >> q;
x[i] = p - q;
y[i] = p + q;
}
d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
rep(i, n){
p[x[i]].insert(P(y[i], i));
q[y[i]].insert(P(x[i], i));
f[x[i]].push_back(y[i]);
g[y[i]].push_back(x[i]);
}
for(auto& v: f){
sort(v.second.begin(), v.second.end());
}
for(auto& v: g){
sort(v.second.begin(), v.second.end());
}
rep(i, n){
c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
c[i] += ub(f[x[i] + d], y[i] + d) - lb(f[x[i] + d], y[i] - d);
c[i] += lb(g[y[i] - d], x[i] + d) - ub(g[y[i] - d], x[i] - d);
c[i] += lb(g[y[i] + d], x[i] + d) - ub(g[y[i] + d], x[i] - d);
}
dfs(a);
ll ans = 0;
rep(i, n){
if(u[i]){
ans += c[i];
}
}
cout << ans / 2 << endl;
return 0;
} | a.cc:21:10: error: 'vector' was not declared in this scope
21 | map<int, vector<int>> f, g;
| ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
4 | #include <algorithm>
+++ |+#include <vector>
5 |
a.cc:21:20: error: template argument 2 is invalid
21 | map<int, vector<int>> f, g;
| ^~
a.cc:21:20: error: template argument 4 is invalid
a.cc:24:1: error: 'vector' does not name a type
24 | vector<int>::iterator lb(vector<int>& v, int x){
| ^~~~~~
a.cc:27:1: error: 'vector' does not name a type
27 | vector<int>::iterator ub(vector<int>& v, int x){
| ^~~~~~
a.cc: In function 'void dfsall(std::set<std::pair<int, int> >::iterator, std::set<std::pair<int, int> >::iterator)':
a.cc:43:3: error: 'vector' was not declared in this scope
43 | vector<P> v(a, b);
| ^~~~~~
a.cc:43:3: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:43:11: error: expected primary-expression before '>' token
43 | vector<P> v(a, b);
| ^
a.cc:43:13: error: 'v' was not declared in this scope
43 | vector<P> v(a, b);
| ^
a.cc: In function 'int main()':
a.cc:63:6: error: invalid types 'int[int]' for array subscript
63 | f[x[i]].push_back(y[i]);
| ^
a.cc:64:6: error: invalid types 'int[int]' for array subscript
64 | g[y[i]].push_back(x[i]);
| ^
a.cc:66:16: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
66 | for(auto& v: f){
| ^
| std::begin
In file included from /usr/include/c++/14/string:53,
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/range_access.h:114:37: note: 'std::begin' declared here
114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
| ^~~~~
a.cc:66:16: error: 'end' was not declared in this scope; did you mean 'std::end'?
66 | for(auto& v: f){
| ^
| std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
a.cc:69:16: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
69 | for(auto& v: g){
| ^
| std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
| ^~~~~
a.cc:69:16: error: 'end' was not declared in this scope; did you mean 'std::end'?
69 | for(auto& v: g){
| ^
| std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
a.cc:73:17: error: invalid types 'int[int]' for array subscript
73 | c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
| ^
a.cc:73:13: error: 'ub' was not declared in this scope; did you mean 'u'?
73 | c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
| ^~
| u
a.cc:73:45: error: invalid types 'int[int]' for array subscript
73 | c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
| ^
a.cc:73:41: error: 'lb' was not declared in this scope; did you mean 'll'?
73 | c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
| ^~
| ll
a.cc:74:17: error: invalid types 'int[int]' for array subscript
74 | c[i] += ub(f[x[i] + d], y[i] + d) - lb(f[x[i] + d], y[i] - d);
| ^
a.cc:74:45: error: invalid types 'int[int]' for array subscript
74 | c[i] += ub(f[x[i] + d], y[i] + d) - lb(f[x[i] + d], y[i] - d);
| ^
a.cc:75:17: error: invalid types 'int[int]' for array subscript
75 | c[i] += lb(g[y[i] - d], x[i] + d) - ub(g[y[i] - d], x[i] - d);
| ^
a.cc:75:45: error: invalid types 'int[int]' for array subscript
75 | c[i] += lb(g[y[i] - d], x[i] + d) - ub(g[y[i] - d], x[i] - d);
| ^
a.cc:76:17: error: invalid types 'int[int]' for array subscript
76 | c[i] += lb(g[y[i] + d], x[i] + d) - ub(g[y[i] + d], x[i] - d);
| ^
a.cc:76:45: error: invalid types 'int[int]' for array subscript
76 | c[i] += lb(g[y[i] + d], x[i] + d) - ub(g[y[i] + d], x[i] - d);
| ^
|
s378486329 | p03858 | C++ | #include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
const int MAX_N = 100005;
int a[MAX_N];
map<P,int> mx,my;
set<P> sx,sy;
set<int> ss;
int x[MAX_N],y[MAX_N];
void dfs(int v)
{
ss.insert(v);
sx.erase(sx.find(P(x[v],y[v])));
sy.erase(sy.find(P(y[v],x[v])));
P cur,end;
//left
cur = P(x[v]-d,y[v]-d);
end = P(x[v]-d,y[v]+d);
while(1){
auto it = sx.lower_bound(cur);
if(it = sx.end() || (*it) > end){
break;
}
cur = *it;
dfs(mx[cur]);
}
//right
cur = P(x[v]+d,y[v]-d);
end = P(x[v]+d,y[v]+d);
while(1){
auto it = sx.lower_bound(cur);
if(it = sx.end() || (*it) > end){
break;
}
cur = *it;
dfs(mx[cur]);
}
//up
cur = P(x[v]-d,y[v]-d);
end = P(x[v]-d,y[v]+d);
while(1){
auto it = sx.lower_bound(cur);
if(it = sy.end() || (*it) > end){
break;
}
cur = *it;
dfs(mx[cur]);
}
//down
cur = P(x[v]+d,y[v]-d);
end = P(x[v]+d,y[v]+d);
while(1){
auto it = sx.lower_bound(cur);
if(it = sy.end() || (*it) > end){
break;
}
cur = *it;
dfs(mx[cur]);
}
}
int main()
{
int n,a,b;
scanf("%d%d%d",&n,&a,&b);
int x,y,x[i],y[i];
rep(i,n){
scanf("%d%d",&x,&y);
x[i] = x - y;
y[i] = x + y;
mx[P(x[i],y[i])] = i;
my[P(y[i],x[i])] = i;
sx.insert(P(x[i],y[i]));
sy.insert(P(y[i],x[i]));
}
d = max(abs(x[a-1]-x[b-1]),abs(y[a-1]-y[b-1]));
dfs(a-1);
rep(i,n){
vx.push_back(P(x[i],y[i]));
vy.push_back(P(y[i],x[i]));
}
sort(vx.begin(),vx.end());
sort(vy.begin(),vy.end());
ll ans = 0;
rep(v,ss.size()){
P cur,end;
//left
cur = P(x[v]-d,y[v]-d);
end = P(x[v]-d,y[v]+d);
ans += vx.upper_bound(end) - vx.lower_bound(cur);
//right
cur = P(x[v]+d,y[v]-d);
end = P(x[v]+d,y[v]+d);
ans += vx.upper_bound(end) - vx.lower_bound(cur);
//up
cur = P(x[v]-d,y[v]-d);
end = P(x[v]-d,y[v]+d);
ans += vy.upper_bound(end) - vy.lower_bound(cur);
//down
cur = P(x[v]+d,y[v]-d);
end = P(x[v]+d,y[v]+d);
ans += vy.upper_bound(end) - vy.lower_bound(cur);
}
cout << ans / 2 << "\n";
} | a.cc: In function 'void dfs(int)':
a.cc:26:22: error: 'd' was not declared in this scope
26 | cur = P(x[v]-d,y[v]-d);
| ^
a.cc:30:34: error: no match for 'operator||' (operand types are 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} and 'bool')
30 | if(it = sx.end() || (*it) > end){
| ~~~~~~~~ ^~ ~~~~~~~~~~~
| | |
| | bool
| std::set<std::pair<int, int> >::iterator {aka std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator}
a.cc:30:34: note: candidate: 'operator||(bool, bool)' (built-in)
30 | if(it = sx.end() || (*it) > end){
| ~~~~~~~~~^~~~~~~~~~~~~~
a.cc:30:34: note: no known conversion for argument 1 from 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} to 'bool'
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:1:
/usr/include/c++/14/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
416 | _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: template argument deduction/substitution failed:
a.cc:30:45: note: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
30 | if(it = sx.end() || (*it) > end){
| ^~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
416 | _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: template argument deduction/substitution failed:
a.cc:30:45: note: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
30 | if(it = sx.end() || (*it) > end){
| ^~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
416 | _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: template argument deduction/substitution failed:
a.cc:30:45: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
30 | if(it = sx.end() || (*it) > end){
| ^~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
416 | _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: template argument deduction/substitution failed:
a.cc:30:45: note: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
30 | if(it = sx.end() || (*it) > end){
| ^~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_or, typename _Dom1::value_type>::result_type> std::operator||(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
416 | _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:416:5: note: template argument deduction/substitution failed:
a.cc:30:45: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool'
30 | if(it = sx.end() || (*it) > end){
| ^~~
/usr/include/c++/14/valarray:1207:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_or, _Tp>::result_type> std::operator||(const valarray<_Tp>&, const valarray<_Tp>&)'
1207 | _DEFINE_BINARY_OPERATOR(||, __logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1207:1: note: template argument deduction/substitution failed:
a.cc:30:45: note: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} is not derived from 'const std::valarray<_Tp>'
30 | if(it = sx.end() || (*it) > end){
| ^~~
/usr/include/c++/14/valarray:1207:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__logical_or, _Tp>::result_type> std::operator||(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
1207 | _DEFINE_BINARY_OPERATOR(||, __logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1207:1: note: template argument deduction/substitution failed:
a.cc:30:45: note: 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} is not derived from 'const std::valarray<_Tp>'
30 | if(it = sx.end() || (*it) > end){
| ^~~
/usr/include/c++/14/valarray:1207:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_or, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_or, _Tp>::result_type> std::operator||(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
1207 | _DEFINE_BINARY_OPERATOR(||, __logical_or)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1207:1: note: template argument deduction/substitution failed:
a.cc:30:45: note: mismatched types 'const std::valarray<_Tp>' and 'bool'
30 | if(it = sx.end() || (*it) > end){
| ^~~
a.cc:41:34: error: no match for 'operator||' (operand types are 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} and 'bool')
41 | if(it = sx.end() || (*it) > end){
| ~~~~~~~~ ^~ ~~~~~~~~~~~
| | |
| | bool
| std::set<std::pair<int, int> >::iterator {aka std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator}
a.cc:41:34: note: candidate: 'operator||(bool, bool)' (built-in)
41 | if(it = sx.end() || (*it) > end){
| ~~~~~~~~~^~~~~~~~~~~~~~
a.cc:41:34: note: no known conversion for argument 1 from 'std::set<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} to 'bool'
/usr/include/c++/14/bits/valarray_after.h:416:5: note: candidate: 'template<class _Dom1, class _Dom2> s |
s353240259 | p03858 | C++ | import java.util.Scanner;
/**
* Created by zzt on 17-1-16.
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int a = scanner.nextInt();
int b = scanner.nextInt();
int[][] pinholes = new int[N][2];
for (int i = 0; i < N; i++) {
pinholes[i][0] = scanner.nextInt();
pinholes[i][1] = scanner.nextInt();
}
int baseD = distance(pinholes[a - 1], pinholes[b - 1]);
UnionFind uf = new UnionFind(N);
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (distance(pinholes[i], pinholes[j]) == baseD) {
uf.union(i, j);
}
}
}
// int pairs = 0;
// for (int i = 0; i < N; i++) {
// for (int j = i + 1; j < N; j++) {
// if (distance(pinholes[i], pinholes[j]) == baseD
// && uf.connected(i,a))
// pairs++;
// }
// }
System.out.println(uf.edges[uf.find(a)]);
}
static int distance(int[] p, int[] q) {
return Math.abs(p[0] - q[0]) + Math.abs(p[1] - q[1]);
}
static class UnionFind {
private int[] id;
private int count;
private int[] sz;
private long[] edges;
public UnionFind(int n) {
count = n;
id = new int[n];
sz = new int[n];
edges = new long[n];
for (int i = 0; i < n; i++) {
id[i] = i;
sz[i] = 1;
}
}
public int count() {
return count;
}
public boolean connected(int p, int q) {
return find(p) == find(q);
}
public int find(int p) {
while (p != id[p]) {
id[p] = id[id[p]];
p = id[p];
}
return p;
}
public void union(int p, int q) {
int i = find(p);
int j = find(q);
if (i == j) {
edges[i]++;
return;
}
if (sz[i] < sz[j]) {
id[i] = j;
sz[j] += sz[i];
edges[i]++;
edges[j] += edges[i];
} else {
id[j] = id[i];
sz[i] += sz[j];
edges[j]++;
edges[i] += edges[j];
}
count--;
}
public int size(int p) {
return sz[find(p)];
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
6 | public class Main {
| ^~~~~~
|
s594017089 | p03858 | C++ | #include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"basic.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
#endif
struct Node{
vector<Node*> dests;
int x, y;
void count(set<Node*>& visited){
if(visited.count(this)){ return; }
visited.insert(this);
for(Node* d : dests){
d -> count(visited);
}
}
};
struct Elem{
int intercept, x, idx;
Elem(int in, int x, int id):intercept(in), x(x), idx(id){}
};
vector<Node> nodes;
set<Node*> visited;
set<pair<Node*, Node*>> answer;
void connect(Node* node, int yint, map<int, vector<pair<int, int>>>& rd, int xb, int xl, vector<Node*>& connected){
prints(node - &nodes[0]);
printd(yint);
auto& vrd = rd[yint];
auto beg = lower_bound(vrd.begin(), vrd.end(), pair<int, int>{xb, -M}),
ed = lower_bound(vrd.begin(), vrd.end(), pair<int, int>{xl, M});
for(; beg != ed; beg++){
auto* n = &nodes[beg -> second];
// if(visited.count(n)){ continue; }
// visited.insert(n);
node -> dests.push_back(n);
n -> dests.push_back(node);
if(answer.count({node, n})){ continue; }
answer.emplace(node, n);
answer.emplace(n, node);
prints("add", node - &nodes[0], n - &nodes[0]);
connected.push_back(n);
}
}
int main(){
int n, a, b;
cin >> n >> a >> b;
a--; b--;
nodes.resize(n);
nodes[a].dests.push_back(&nodes[b]);
nodes[b].dests.push_back(&nodes[a]);
map<int, vector<pair<int, int>>> ru, rd;
vector<Elem> ds, us;
vector<Node*> connected = {&nodes[a], &nodes[b]};
vector<int> ys, xs;
for(int i=0;i<n;i++){
int x, y;
cin >> x >> y;
nodes[i].x = x;
nodes[i].y = y;
rd[y + x].emplace_back(x, i);
ru[y - x].emplace_back(x, i);
if(a == i || b == i){
ds.emplace_back(x + y, x, i);
us.emplace_back(y - x, x, i);
ys.push_back(y);
xs.push_back(x);
}
}
int len = abs(ys[0] - ys[1]) + abs(xs[0] - xs[1]);
// cout << len << '\n';
printd(len);
for(auto& p : ru){ sort(p.second.begin(), p.second.end()); }
for(auto& p : rd){ sort(p.second.begin(), p.second.end()); }
printd(ru);
printd(rd);
// while(ds.size() || us.size()){
// set<int> ans = {a, b};
// for(int h=0;h<2;h++){
// set<int> visited1;
// while(ds.size()){
// auto d = ds.back(); ds.pop_back();
// if(visited1.count(d.intercept)){ continue; }
// visited1.insert(d.intercept);
// for(int i=0;i<2;i++){
// auto& v1 = rd[d.intercept + len * (i ? 1 : -1)];
// auto beg = lower_bound(v1.begin(), v1.end(), pair<int, int>{d.x - (i ^ h ? 0 : len), -2*M});
// auto ed = lower_bound(v1.begin(), v1.end(), pair<int, int>{d.x + (i ^ h ? len : 0), 2*M});
// for(auto ite=beg;ite!=ed;ite++){
// ds.emplace_back(d.intercept + len * (i ? 1 : -1), ite -> first, ite -> second);
// us.emplace_back(d.intercept + len * (i ? 1 : -1) + ite -> first * (h ? 2 : -2), ite -> first, ite -> second);
// ans.insert(ite -> second);
// nodes[d.idx].dests.push_back(&nodes[ite -> second]);
// nodes[ite -> second].dests.push_back(&nodes[d.idx]);
// cout<<"ite->second "<<ite->second<<'\n';
// }
// }
// }
// // ds = us;
// ds.swap(us);
// }
// }
answer.emplace(&nodes[a], &nodes[b]);
answer.emplace(&nodes[b], &nodes[a]);
while(connected.size()){
Node* n = connected.back(); connected.pop_back();
connect(n, n -> y + n -> x + len, rd, n -> x, n -> x + len, connected);
connect(n, n -> y + n -> x - len, rd, n -> x - len, n -> x, connected);
connect(n, n -> y - n -> x + len, ru, n -> x - len, n -> x, connected);
connect(n, n -> y - n -> x - len, ru, n -> x, n -> x + len, connected);
}
// cout << ans.size() << '\n';
// nodes[a].count(visited);
// for(auto p : visited){
// cout << p - &nodes[0] << '\n';
// }
// cout << visited.size() << '\n';
printl([](ostream& out, Node* a){ out << a - &nodes[0]; }, answer);
// printl(answer);
// prints(answer);
cout << answer.size() / 2 << '\n';
return 0;
}
| a.cc: In function 'void connect(Node*, int, std::map<int, std::vector<std::pair<int, int> > >&, int, int, std::vector<Node*>&)':
a.cc:48:5: error: 'printd' was not declared in this scope; did you mean 'prints'?
48 | printd(yint);
| ^~~~~~
| prints
a.cc: In function 'int main()':
a.cc:93:5: error: 'printd' was not declared in this scope; did you mean 'prints'?
93 | printd(len);
| ^~~~~~
| prints
|
s700155161 | p03858 | C++ | #include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include"basic.hpp"
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)
struct Node{
vector<Node*> dests;
int x, y;
void count(set<Node*>& visited){
if(visited.count(this)){ return; }
visited.insert(this);
for(Node* d : dests){
d -> count(visited);
}
}
};
struct Elem{
int intercept, x, idx;
Elem(int in, int x, int id):intercept(in), x(x), idx(id){}
};
vector<Node> nodes;
set<Node*> visited;
set<pair<Node*, Node*>> answer;
void connect(Node* node, int yint, map<int, vector<pair<int, int>>>& rd, int xb, int xl, vector<Node*>& connected){
prints(node - &nodes[0]);
printd(yint);
auto& vrd = rd[yint];
auto beg = lower_bound(vrd.begin(), vrd.end(), pair<int, int>{xb, -M}),
ed = lower_bound(vrd.begin(), vrd.end(), pair<int, int>{xl, M});
for(; beg != ed; beg++){
auto* n = &nodes[beg -> second];
// if(visited.count(n)){ continue; }
// visited.insert(n);
node -> dests.push_back(n);
n -> dests.push_back(node);
if(answer.count({node, n})){ continue; }
answer.emplace(node, n);
answer.emplace(n, node);
prints("add", node - &nodes[0], n - &nodes[0]);
connected.push_back(n);
}
}
int main(){
int n, a, b;
cin >> n >> a >> b;
a--; b--;
nodes.resize(n);
nodes[a].dests.push_back(&nodes[b]);
nodes[b].dests.push_back(&nodes[a]);
map<int, vector<pair<int, int>>> ru, rd;
vector<Elem> ds, us;
vector<Node*> connected = {&nodes[a], &nodes[b]};
vector<int> ys, xs;
for(int i=0;i<n;i++){
int x, y;
cin >> x >> y;
nodes[i].x = x;
nodes[i].y = y;
rd[y + x].emplace_back(x, i);
ru[y - x].emplace_back(x, i);
if(a == i || b == i){
ds.emplace_back(x + y, x, i);
us.emplace_back(y - x, x, i);
ys.push_back(y);
xs.push_back(x);
}
}
int len = abs(ys[0] - ys[1]) + abs(xs[0] - xs[1]);
// cout << len << '\n';
printd(len);
for(auto& p : ru){ sort(p.second.begin(), p.second.end()); }
for(auto& p : rd){ sort(p.second.begin(), p.second.end()); }
printd(ru);
printd(rd);
// while(ds.size() || us.size()){
// set<int> ans = {a, b};
// for(int h=0;h<2;h++){
// set<int> visited1;
// while(ds.size()){
// auto d = ds.back(); ds.pop_back();
// if(visited1.count(d.intercept)){ continue; }
// visited1.insert(d.intercept);
// for(int i=0;i<2;i++){
// auto& v1 = rd[d.intercept + len * (i ? 1 : -1)];
// auto beg = lower_bound(v1.begin(), v1.end(), pair<int, int>{d.x - (i ^ h ? 0 : len), -2*M});
// auto ed = lower_bound(v1.begin(), v1.end(), pair<int, int>{d.x + (i ^ h ? len : 0), 2*M});
// for(auto ite=beg;ite!=ed;ite++){
// ds.emplace_back(d.intercept + len * (i ? 1 : -1), ite -> first, ite -> second);
// us.emplace_back(d.intercept + len * (i ? 1 : -1) + ite -> first * (h ? 2 : -2), ite -> first, ite -> second);
// ans.insert(ite -> second);
// nodes[d.idx].dests.push_back(&nodes[ite -> second]);
// nodes[ite -> second].dests.push_back(&nodes[d.idx]);
// cout<<"ite->second "<<ite->second<<'\n';
// }
// }
// }
// // ds = us;
// ds.swap(us);
// }
// }
answer.emplace(&nodes[a], &nodes[b]);
answer.emplace(&nodes[b], &nodes[a]);
while(connected.size()){
Node* n = connected.back(); connected.pop_back();
connect(n, n -> y + n -> x + len, rd, n -> x, n -> x + len, connected);
connect(n, n -> y + n -> x - len, rd, n -> x - len, n -> x, connected);
connect(n, n -> y - n -> x + len, ru, n -> x - len, n -> x, connected);
connect(n, n -> y - n -> x - len, ru, n -> x, n -> x + len, connected);
}
// cout << ans.size() << '\n';
// nodes[a].count(visited);
// for(auto p : visited){
// cout << p - &nodes[0] << '\n';
// }
// cout << visited.size() << '\n';
printl([](ostream& out, Node* a){ out << a - &nodes[0]; }, answer);
// printl(answer);
// prints(answer);
cout << answer.size() / 2 << '\n';
return 0;
}
| a.cc:10:9: fatal error: basic.hpp: No such file or directory
10 | #include"basic.hpp"
| ^~~~~~~~~~~
compilation terminated.
|
s045809313 | p03858 | C | #include <stdio.h>
#include <stdlib.h>
#define MAX_HOLE 1000000000
// #define MAX_HOLE 1000
typedef struct xy {
int x, y;
} XY;
static int N = 0;
static XY hole[MAX_HOLE] = {0};
static int memo[MAX_HOLE][MAX_HOLE] = {0};
void memo_clear();
int memo_count();
int countup(int now_a, int now_b);
int d(int i, int j);
int main( void ){
int i, j, k;
int a,b;
scanf("%d %d %d", &N, &a, &b);
for( i = 0; i < N; i++ ){
scanf("%d %d", &hole[i].x, &hole[i].y);
}
memo_clear();
countup(a-1, b-1);
printf( "%d\n", memo_count() );
// printf( "%d\n", countup(a-1, b-1)+1 );
return 0;
}
int memo_count(){
int i,j;
int count;
for( i = 0; i < N; i++ ){
for( j = 0; j < N; j++ ){
if( memo[i][j] == 1 ){
count++;
}
}
}
return count/2;
}
void memo_clear(){
int i,j;
for( i = 0; i < N; i++ ){
for( j = 0; j < N; j++ ){
memo[i][j] = 0;
}
}
}
int d(int i, int j){
return abs(hole[i].x-hole[j].x)+abs(hole[i].y-hole[j].y);
}
int countup(int now_a, int now_b){
int i;
int count = 0;
// // // // // // // // // printf( "%d %d\n", now_a+1, now_b+1 );
for( i = 0; i < N; i++ ){
if( i != now_a && i != now_b ){
// printf( "d(now) = %d\n", d(now_a, now_b) );
// printf( "d(next1) = %d\n", d(now_a, i) );
// printf( "d(next2) = %d\n", d(i, now_b) );
// printf( "memo1 = %d\n", memo[now_a][i] );
if( ( d(now_a, now_b) == d(now_a, i) ) &&
( memo[now_a][i] == 0 ) ){
// printf( "a\n" );
// printf( "yes\n" );
memo[now_a][i] = 1;
memo[i][now_a] = 1;
count = countup(now_a, i) + 1;
}
// printf( "memo2 = %d\n", memo[i][now_b] );
if( ( d(now_a, now_b) == d(i, now_b) ) &&
( memo[now_b][i] == 0 ) ){
// printf( "b\n" );
// printf( "no\n" );
memo[i][now_b] = 1;
memo[now_b][i] = 1;
count = countup(i, now_b) + 1;
}
}
}
return count==0 ? 1 : count;
}
| /tmp/cc66YPU1.o: in function `memo_count':
main.c:(.text+0x111): relocation truncated to fit: R_X86_64_PC32 against `.bss'
/tmp/cc66YPU1.o: in function `memo_clear':
main.c:(.text+0x183): relocation truncated to fit: R_X86_64_PC32 against `.bss'
/tmp/cc66YPU1.o: in function `countup':
main.c:(.text+0x2b2): relocation truncated to fit: R_X86_64_PC32 against `.bss'
main.c:(.text+0x2dd): relocation truncated to fit: R_X86_64_PC32 against `.bss'
main.c:(.text+0x308): relocation truncated to fit: R_X86_64_PC32 against `.bss'
main.c:(.text+0x370): relocation truncated to fit: R_X86_64_PC32 against `.bss'
main.c:(.text+0x39b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
main.c:(.text+0x3c6): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status
|
s921210745 | p03858 | C++ | #include <iostream>
#include <map>
#include <set>
using namespace std;
int N, a, b, d;
set<pair<int, int>> s1, s2, s3;
int getD(pair<int, int> z1, pair<int, int> z2) {
return max(abs(z1.first - z2.first), abs(z1.second - z2.second));
}
void dfs(pair<int, int> z) {
s3.insert(z);
s1.erase(z);
s2.erase(pair<int, int>(z.second, z.first));
while (true) {
auto itr1 = lower_bound(s1.begin(), s1.end(),
pair<int, int>(z.first - d, z.second - d));
auto itr2 = upper_bound(s1.begin(), s1.end(),
pair<int, int>(z.first - d, z.second + d));
if (itr1 == itr2) break;
pair<int, int> p1 = *itr1;
dfs(p1);
}
while (true) {
auto itr1 = lower_bound(s1.begin(), s1.end(),
pair<int, int>(z.first + d, z.second - d));
auto itr2 = upper_bound(s1.begin(), s1.end(),
pair<int, int>(z.first + d, z.second + d));
if (itr1 == itr2) break;
pair<int, int> p1 = *itr1;
dfs(p1);
}
while (true) {
auto itr1 = lower_bound(s2.begin(), s2.end(),
pair<int, int>(z.second - d, z.first - d));
auto itr2 = upper_bound(s2.begin(), s2.end(),
pair<int, int>(z.second - d, z.first + d));
if (itr1 == itr2) break;
pair<int, int> p1 = pair<int, int>(itr1->second, itr1->first);
dfs(p1);
}
while (true) {
auto itr1 = lower_bound(s2.begin(), s2.end(),
pair<int, int>(z.second + d, z.first - d));
auto itr2 = upper_bound(s2.begin(), s2.end(),
pair<int, int>(z.second + d, z.first + d));
if (itr1 == itr2) break;
pair<int, int> p1 = pair<int, int>(itr1->second, itr1->first);
dfs(p1);
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> a >> b;
a--, b--;
pair<int, int> za, zb;
for (int i = 0; i < N; i++) {
int x, y;
cin >> x >> y;
int x2 = x + y, y2 = x - y;
if (i == a) za = pair<int, int>(x2, y2);
if (i == b) zb = pair<int, int>(x2, y2);
s1.insert(pair<int, int>(x2, y2));
s2.insert(pair<int, int>(y2, x2));
}
d = getD(za, zb);
dfs(za);
if(s1.find(zb) != s1.end())
dfs(zb);
vector<pair<int, int>> v3, v4;
for(auto z : s3){
v3.push_back(z);
v4.push_back(pair<int, int>(z.second, z.first));
}
sort(v3.begin(), v3.end());
sort(v4.begin(), v4.end());
int ans = 0;
for(auto z : s3){
ans += lower_bound(v3.begin(), v3.end(), pair<int, int>(z.first - d, z.second + d))
- lower_bound(v3.begin(), v3.end(), pair<int, int>(z.first - d, z.second - d));
ans += lower_bound(v3.begin(), v3.end(), pair<int, int>(z.first + d, z.second + d))
- lower_bound(v3.begin(), v3.end(), pair<int, int>(z.first + d, z.second - d));
ans += lower_bound(v4.begin(), v4.end(), pair<int, int>(z.second - d, z.first + d))
- lower_bound(v4.begin(), v4.end(), pair<int, int>(z.second - d, z.first - d));
ans += lower_bound(v4.begin(), v4.end(), pair<int, int>(z.second + d, z.first + d))
- lower_bound(v4.begin(), v4.end(), pair<int, int>(z.second + d, z.first - d));
}
cout << ans / 2 << endl;
return 0;
}
| a.cc: In function 'void dfs(std::pair<int, int>)':
a.cc:21:21: error: 'upper_bound' was not declared in this scope
21 | auto itr2 = upper_bound(s1.begin(), s1.end(),
| ^~~~~~~~~~~
a.cc:30:21: error: 'upper_bound' was not declared in this scope
30 | auto itr2 = upper_bound(s1.begin(), s1.end(),
| ^~~~~~~~~~~
a.cc:39:21: error: 'upper_bound' was not declared in this scope
39 | auto itr2 = upper_bound(s2.begin(), s2.end(),
| ^~~~~~~~~~~
a.cc:48:21: error: 'upper_bound' was not declared in this scope
48 | auto itr2 = upper_bound(s2.begin(), s2.end(),
| ^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:77:5: error: 'vector' was not declared in this scope
77 | vector<pair<int, int>> v3, v4;
| ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
3 | #include <set>
+++ |+#include <vector>
4 | using namespace std;
a.cc:77:25: error: expected primary-expression before '>' token
77 | vector<pair<int, int>> v3, v4;
| ^~
a.cc:77:28: error: 'v3' was not declared in this scope; did you mean 's3'?
77 | vector<pair<int, int>> v3, v4;
| ^~
| s3
a.cc:77:32: error: 'v4' was not declared in this scope
77 | vector<pair<int, int>> v3, v4;
| ^~
a.cc:82:5: error: 'sort' was not declared in this scope; did you mean 'short'?
82 | sort(v3.begin(), v3.end());
| ^~~~
| short
|
s801230922 | p03858 | C++ | f | a.cc:1:1: error: 'f' does not name a type
1 | f
| ^
|
s089908282 | p03858 | C++ | #include <bits/stdc++.h>
using namespace std;
struct UnionFind
{
vector< int > data;
UnionFind(int sz)
{
data.assign(sz, -1);
}
void unite(int x, int y)
{
x = find(x), y = find(y);
if(x != y) {
if(data[x] > data[y]) swap(x, y);
data[x] += data[y];
data[y] = x;
}
}
int find(int k)
{
if(data[k] < 0) return (k);
return (data[k] = find(data[k]));
}
int size(int k)
{
return (-data[find(k)]);
}
};
typedef long long int64;
int64 N, R, s, t;
int64 a[100000], b[100000];
UnionFind tree(100000);
int64 ret[100000];
void ask(int v)
{
map< int, vector< pair< int64, int > > > backet;
for(int i = 0; i < N; i++) {
backet[a[i]].push_back(make_pair(b[i], i));
}
for(auto &obj : backet) {
sort(begin(obj.second), end(obj.second));
}
for(int i = 0; i < N; i++) {
auto &cc = backet[a[i] - R];
auto p = lower_bound(begin(cc), end(cc), make_pair(b[i] - R - v, +INF));
auto q = lower_bound(begin(cc), end(cc), make_pair(b[i] + R + v, -INF));
ret[i] += q - p;
if(p != q) tree.unite(i, p->second);
}
for(int i = 0; i < N; i++) {
auto &cc = backet[a[i] + R];
auto p = lower_bound(begin(cc), end(cc), make_pair(b[i] - R - v, +INF));
auto q = lower_bound(begin(cc), end(cc), make_pair(b[i] + R + v, -INF));
ret[i] += q - p;
if(p != q) tree.unite(i, p->second);
}
}
int main()
{
cin >> N >> s >> t;
for(int i = 0; i < N; i++) {
int x, y;
cin >> x >> y;
a[i] = x + y;
b[i] = x - y;
}
--s, --t;
R = max(abs(a[s] - a[t]), abs(b[s] - b[t]));
ask(false);
for(int i = 0; i < N; i++) swap(a[i], b[i]);
ask(true);
long long res = 0;
for(int i = 0; i < N; i++) {
if(tree.find(i) == tree.find(s)) res += ret[i];
}
cout << res / 2 << endl;
} | a.cc: In function 'void ask(int)':
a.cc:54:71: error: 'INF' was not declared in this scope
54 | auto p = lower_bound(begin(cc), end(cc), make_pair(b[i] - R - v, +INF));
| ^~~
a.cc:61:71: error: 'INF' was not declared in this scope
61 | auto p = lower_bound(begin(cc), end(cc), make_pair(b[i] - R - v, +INF));
| ^~~
|
s684301998 | p03858 | C++ | #include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<double, int> PDI;
typedef vector<PDI> VD;
int n, a, b;
int x[100010], y[100010];
VI vxpyidx, vxmyidx;
int xpyidx[100010], xmyidx[100010];
VP xpy[100010], xmy[100010];
int dist;
queue<int> qu;
bool visited[100010];
int ans = 0;
signed main()
{
scanf("%lld%lld%lld", &n, &a, &b);
for(int i = 1; i <= n; i++){
scanf("%lld%lld", &x[i], &y[i]);
vxpyidx.PB(x[i] + y[i]);
vxmyidx.PB(x[i] - y[i]);
}
sort(vxpyidx.begin(), vxpyidx.end());
sort(vxmyidx.begin(), vxmyidx.end());
vxpyidx.erase(unique(vxpyidx.begin(), vxpyidx.end()), vxpyidx.end());
vxmyidx.erase(unique(vxmyidx.begin(), vxmyidx.end()), vxmyidx.end());
for(int i = 1; i <= n; i++){
xpyidx[i] = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[i] + y[i]) - vxpyidx.begin();
xmyidx[i] = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[i] - y[i]) - vxmyidx.begin();
}
for(int i = 1; i <= n; i++){
xpy[xpyidx[i]].PB(MP(x[i] - y[i], i));
xmy[xmyidx[i]].PB(MP(x[i] + y[i], i));
}
for(int i = 0; i <= n; i++){
sort(xpy[i].begin(), xpy[i].end());
sort(xmy[i].begin(), xmy[i].end());
}
dist = abs(x[a] - x[b]) + abs(y[a] - y[b]);
qu.push(a);
qu.push(b);
while(!qu.empty()){
int now = qu.front();
qu.pop();
if(!visited[now]){
visited[now] = true;
{
int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] + dist) - vxpyidx.begin();
if(vxpyidx[idx] == x[now] + y[now] + dist){
int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
for(int i = st; i < ed; i++){
qu.push(xpy[i].S);
ans++;
}
}
int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] - dist) - vxpyidx.begin();
if(vxpyidx[idx] == x[now] + y[now] - dist){
int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
for(int i = st; i < ed; i++){
qu.push(xpy[i].S);
ans++;
}
}
}
{
int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] + dist) - vxmyidx.begin();
if(vxmyidx[idx] == x[now] - y[now] + dist){
int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
int ed = upper_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] + dist, INF)) - xmy.begin();
for(int i = st; i < ed; i++){
qu.push(xmy[i].S);
ans++;
}
}
int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] - dist) - vxmyidx.begin();
if(vxmyidx[idx] == x[now] - y[now] - dist){
int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
int ed = upper_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] + dist, INF)) - xmy.begin();
for(int i = st; i < ed; i++){
qu.push(xmy[i].S);
ans++;
}
}
}
}
}
printf("%lld\n", ans / 2);
return 0;
}
| a.cc: In function 'int main()':
a.cc:71:36: error: 'i' was not declared in this scope
71 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^
a.cc:71:90: error: 'INF' was not declared in this scope
71 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~
a.cc:71:102: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
71 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~~~
a.cc:72:101: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
72 | int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
| ^~~~~
a.cc:6:11: error: 'VP' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
6 | #define S second
| ^~~~~~
a.cc:75:28: note: in expansion of macro 'S'
75 | qu.push(xpy[i].S);
| ^
a.cc:80:13: error: redeclaration of 'long long int idx'
80 | int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] - dist) - vxpyidx.begin();
| ^~~
a.cc:68:13: note: 'long long int idx' previously declared here
68 | int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] + dist) - vxpyidx.begin();
| ^~~
a.cc:83:36: error: 'i' was not declared in this scope
83 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^
a.cc:83:90: error: 'INF' was not declared in this scope
83 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~
a.cc:83:102: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
83 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~~~
a.cc:84:101: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
84 | int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
| ^~~~~
a.cc:6:11: error: 'VP' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
6 | #define S second
| ^~~~~~
a.cc:87:28: note: in expansion of macro 'S'
87 | qu.push(xpy[i].S);
| ^
a.cc:97:36: error: 'i' was not declared in this scope
97 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^
a.cc:97:90: error: 'INF' was not declared in this scope
97 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~
a.cc:97:102: error: request for member 'begin' in 'xmy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
97 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~~~
a.cc:98:101: error: request for member 'begin' in 'xmy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
98 | int ed = upper_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] + dist, INF)) - xmy.begin();
| ^~~~~
a.cc:6:11: error: 'VP' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
6 | #define S second
| ^~~~~~
a.cc:101:28: note: in expansion of macro 'S'
101 | qu.push(xmy[i].S);
| ^
a.cc:106:13: error: redeclaration of 'long long int idx'
106 | int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] - dist) - vxmyidx.begin();
| ^~~
a.cc:94:13: note: 'long long int idx' previously declared here
94 | int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] + dist) - vxmyidx.begin();
| ^~~
a.cc:109:36: error: 'i' was not declared in this scope
109 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^
a.cc:109:90: error: 'INF' was not declared in this scope
109 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~
a.cc:109:102: error: request for member 'begin' in 'xmy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
109 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~~~
a.cc:110:101: error: request for member 'begin' in 'xmy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
110 | int ed = upper_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] + dist, INF)) - xmy.begin();
| ^~~~~
a.cc:6:11: error: 'VP' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
6 | #define S second
| ^~~~~~
a.cc:113:28: note: in expansion of macro 'S'
113 | qu.push(xmy[i].S);
| ^
|
s237806144 | p03858 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
vector<string> split(const string &s, char c) {
vector<string> v; stringstream ss(s); string x;
while (getline(ss, x, c)) v.push_back(x);
return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
err(++it, args...);
}
typedef long long ll;
const int MOD = 1000000007;
template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }
const int N = 100005;
unordered_set<int> g[N];
int deg[N];
struct UF {
vector<int> par, rk;
UF(int _n) {
par.resize(_n + 1), rk.assign(_n + 1, 0);
for (int i = 0; i <= _n; ++i) {
par[i] = i;
}
}
int find(int x) {
if (x != par[x]) par[x] = find(par[x]);
return par[x];
}
bool same(int x, int y) {
return find(x) == find(y);
}
bool unite(int x, int y) {
x = find(x), y = find(y);
if (x == y) return false;
if (rk[x] < rk[y]) par[x] = y, deg[y] += deg[x];
else {
par[y] = x, deg[x] += deg[y];
if (rk[x] == rk[y]) rk[x]++;
}
return true;
}
};
typedef pair<ll, int> P;
int main(int argc, char *argv[]) {
ios_base::sync_with_stdio(false);
int n, a, b; cin >> n >> a >> b; --a, --b;
vector<int> xs(n), ys(n);
unordered_map<int, set<P>> mp1; // x+y
unordered_map<int, set<P>> mp2; // x-y
REPU(i, 0, n) {
int x, y; cin >> x >> y;
xs[i] = x, ys[i] = y;
mp1[x + y].push_back(P(x - y, i));
mp2[x - y].push_back(P(x + y, i));
}
int d = abs(xs[a] - xs[b]) + abs(ys[a] - ys[b]);
REPU(i, 0, n) {
{
ll f1 = xs[i] + ys[i];
ll f2 = f1 - d;
auto& st = mp1[f2];
ll tmp = xs[i] - ys[i]; tmp -= d;
auto it = st.lower_bound(P(tmp, -1));
while (it != st.end()) {
int v = (*it).second;
g[i].insert(v); g[v].insert(i);
}
}
{
ll f1 = xs[i] - ys[i];
ll f2 = f1 - d;
auto& st = mp2[f2];
ll tmp = xs[i] + ys[i]; tmp -= d;
auto it = st.lower_bound(P(tmp, -1));
for (int v : st) {
int v = (*it).second;
g[i].insert(v); g[v].insert(i);
}
}
}
REPU(i, 0, n) deg[i] = g[i].size();
UF uf(n);
REPU(i, 0, n) {
for (int v : g[i]) if (i < v) {
uf.unite(i, v);
}
}
int ans = deg[uf.find(a)] >> 1;
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main(int, char**)':
a.cc:80:28: error: 'std::unordered_map<int, std::set<std::pair<long long int, int> > >::mapped_type' {aka 'class std::set<std::pair<long long int, int> >'} has no member named 'push_back'
80 | mp1[x + y].push_back(P(x - y, i));
| ^~~~~~~~~
a.cc:81:28: error: 'std::unordered_map<int, std::set<std::pair<long long int, int> > >::mapped_type' {aka 'class std::set<std::pair<long long int, int> >'} has no member named 'push_back'
81 | mp2[x - y].push_back(P(x + y, i));
| ^~~~~~~~~
a.cc:102:38: error: cannot convert 'const std::pair<long long int, int>' to 'int' in initialization
102 | for (int v : st) {
| ^~
a.cc:103:37: error: redeclaration of 'int v'
103 | int v = (*it).second;
| ^
a.cc:102:34: note: 'int v' previously declared here
102 | for (int v : st) {
| ^
|
s134517472 | p03858 | C++ | #include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<double, int> PDI;
typedef vector<PDI> VD;
int n, a, b;
int x[100010], y[100010];
VI vxpyidx, vxmyidx;
int xpyidx[100010], xmyidx[100010];
VP xpy[100010], mpy[100010];
int dist;
queue<int> qu;
bool visited[100010];
int ans = 0;
signed main()
{
scanf("%lld%lld%lld", &n, &a, &b);
for(int i = 1; i <= n; i++){
scanf("%lld%lld", &x[i], &y[i]);
vxpyidx.PB(x[i] + y[i]);
vxmyidx.PB(x[i] - y[i]);
}
sort(vxpyidx.begin(), vxpyidx.end());
sort(vxmyidx.begin(), vxmyidx.end());
vxpyidx.erase(unique(vxpyidx.begin(), vxpyidx.end()), vxpyidx.end());
vxmyidx.erase(unique(vxmyidx.begin(), vxmyidx.end()), vxmyidx.end());
for(int i = 1; i <= n; i++){
xpyidx[i] = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[i] + y[i]) - vxpyidx.begin();
xmyidx[i] = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[i] - y[i]) - vxmyidx.begin();
}
for(int i = 1; i <= n; i++){
xpy[xpyidx[i]].PB(MP(x[i] - y[i], i));
xmy[xmyidx[i]].PB(MP(x[i] + y[i], i));
}
for(int i = 0; i <= n; i++){
sort(xpy[i].begin(), xpy[i].end());
sort(xmy[i].begin(), xmy[i].end());
}
dist = abs(x[a] - x[b]) + abs(y[a] - y[b]);
qu.push(a);
qu.push(b);
while(!qu.empty()){
int now = qu.front();
qu.pop();
if(!visited[now]){
visited[now] = true;
{
int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] + dist) - vxpyidx.begin();
if(vxpyidx[idx] == x[now] + y[now] + dist){
int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
for(int i = st; i < ed; i++){
qu.push(xpy[i].S);
ans++;
}
}
int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] - dist) - vxpyidx.begin();
if(vxpyidx[idx] == x[now] + y[now] - dist){
int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
for(int i = st; i < ed; i++){
qu.push(xpy[i].S);
ans++;
}
}
}
{
int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] + dist) - vxmyidx.begin();
if(vxmyidx[idx] == x[now] - y[now] + dist){
int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
int ed = upper_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] + dist, INF)) - xmy.begin();
for(int i = st; i < ed; i++){
qu.push(xmy[i].S);
ans++;
}
}
int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] - dist) - vxmyidx.begin();
if(vxmyidx[idx] == x[now] - y[now] - dist){
int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
int ed = upper_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] + dist, INF)) - xmy.begin();
for(int i = st; i < ed; i++){
qu.push(xmy[i].S);
ans++;
}
}
}
}
}
printf("%lld\n", ans / 2);
return 0;
}
| a.cc: In function 'int main()':
a.cc:47:5: error: 'xmy' was not declared in this scope; did you mean 'xpy'?
47 | xmy[xmyidx[i]].PB(MP(x[i] + y[i], i));
| ^~~
| xpy
a.cc:52:10: error: 'xmy' was not declared in this scope; did you mean 'xpy'?
52 | sort(xmy[i].begin(), xmy[i].end());
| ^~~
| xpy
a.cc:71:36: error: 'i' was not declared in this scope
71 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^
a.cc:71:90: error: 'INF' was not declared in this scope
71 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~
a.cc:71:102: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
71 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~~~
a.cc:72:101: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
72 | int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
| ^~~~~
a.cc:6:11: error: 'VP' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
6 | #define S second
| ^~~~~~
a.cc:75:28: note: in expansion of macro 'S'
75 | qu.push(xpy[i].S);
| ^
a.cc:80:13: error: redeclaration of 'long long int idx'
80 | int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] - dist) - vxpyidx.begin();
| ^~~
a.cc:68:13: note: 'long long int idx' previously declared here
68 | int idx = lower_bound(vxpyidx.begin(), vxpyidx.end(), x[now] + y[now] + dist) - vxpyidx.begin();
| ^~~
a.cc:83:36: error: 'i' was not declared in this scope
83 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^
a.cc:83:90: error: 'INF' was not declared in this scope
83 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~
a.cc:83:102: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
83 | int st = lower_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] - dist, -INF)) - xpy.begin();
| ^~~~~
a.cc:84:101: error: request for member 'begin' in 'xpy', which is of non-class type 'VP [100010]' {aka 'std::vector<std::pair<long long int, long long int> > [100010]'}
84 | int ed = upper_bound(xpy[i].begin(), xpy[i].end(), MP(x[now] - y[now] + dist, INF)) - xpy.begin();
| ^~~~~
a.cc:6:11: error: 'VP' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
6 | #define S second
| ^~~~~~
a.cc:87:28: note: in expansion of macro 'S'
87 | qu.push(xpy[i].S);
| ^
a.cc:97:32: error: 'xmy' was not declared in this scope; did you mean 'xpy'?
97 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~
| xpy
a.cc:97:36: error: 'i' was not declared in this scope
97 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^
a.cc:97:90: error: 'INF' was not declared in this scope
97 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~
a.cc:106:13: error: redeclaration of 'long long int idx'
106 | int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] - dist) - vxmyidx.begin();
| ^~~
a.cc:94:13: note: 'long long int idx' previously declared here
94 | int idx = lower_bound(vxmyidx.begin(), vxmyidx.end(), x[now] - y[now] + dist) - vxmyidx.begin();
| ^~~
a.cc:109:32: error: 'xmy' was not declared in this scope; did you mean 'xpy'?
109 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~
| xpy
a.cc:109:36: error: 'i' was not declared in this scope
109 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^
a.cc:109:90: error: 'INF' was not declared in this scope
109 | int st = lower_bound(xmy[i].begin(), xmy[i].end(), MP(x[now] + y[now] - dist, -INF)) - xmy.begin();
| ^~~
|
s293754652 | p03858 | C++ | #include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int SIZE = 1e5+10;
VPLL pp,pp2;
bool used[SIZE];
int get(PLL X){
return lower_bound(ALL(pp),X)-pp.begin();
}
LL dis(PII x,PII y){
return max(abs((LL)x.F-y.F),abs((LL)x.S-y.S));
}
int main(){
DRIII(n,id1,id2);id1--;id2--;
REP(i,n){
DRII(x,y);
pp.PB(MP(x-y,x+y));
pp2.PB(MP(x+y,x-y));
}
PII st1=pp[id1],st2=pp[id2];
LL D=dis(st1,st2);
sort(ALL(pp));
sort(ALL(pp2));
id1=get(st1);
id2=get(st2);
queue<int>qq;
qq.push(id1);
qq.push(id2);
used[id1]=used[id2]=1;
int an=0;
while(SZ(qq)){
PII me=pp[qq.front()];
qq.pop();
int it;
it=lower_bound(ALL(pp),MP(me.F-D,me.S-D))-pp.begin();
for(;it<SZ(pp)&&pp[it].F==me.F-D&&pp[it].S<=me.S+D;it++){
an++;
if(!used[it]){
used[it]=1;
qq.push(it);
}
}
it=lower_bound(ALL(pp),MP(me.F+D,me.S-D))-pp.begin();
for(;it<SZ(pp)&&pp[it].F==me.F+D&&pp[it].S<=me.S+D;it++){
an++;
if(!used[it]){
used[it]=1;
qq.push(it);
}
}
it=lower_bound(ALL(pp2),MP(me.S-D,me.F-D+1))-pp2.begin();
for(;it<SZ(pp2)&&pp2[it].F==me.S-D&&pp2[it].S<me.F+D;it++){
an++;
int it2=get(MP(pp2[it].S,pp2[it].F));
if(!used[it2]){
used[it2]=1;
qq.push(it2);
}
}
it=lower_bound(ALL(pp2),MP(me.S+D,me.F-D+1))-pp2.begin();
for(;it<SZ(pp2)&&pp2[it].F==me.S+D&&pp2[it].S<me.F+D;it++){
an++;
int it2=get(MP(pp2[it].S,pp2[it].F));
if(!used[it2]){
used[it2]=1;
qq.push(it2);
}
}
}
printf("%d\n",an/2);
return 0;
}
| a.cc: In function 'int main()':
a.cc:48:12: error: call of overloaded 'get(std::pair<int, int>&)' is ambiguous
48 | id1=get(st1);
| ~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
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_pair.h:1272:5: note: candidate: 'constexpr _Tp& std::get(pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
1272 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
1277 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'constexpr _Tp& std::get(pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
1292 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
1297 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
a.cc:31:5: note: candidate: 'int get(std::pair<long long int, long long int>)'
31 | int get(PLL X){
| ^~~
a.cc:49:12: error: call of overloaded 'get(std::pair<int, int>&)' is ambiguous
49 | id2=get(st2);
| ~~~^~~~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'constexpr _Tp& std::get(pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
1272 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_T1, _T2>&) [with _Tp = int; _Up = int]'
1277 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'constexpr _Tp& std::get(pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
1292 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'constexpr const _Tp& std::get(const pair<_Up, _Tp>&) [with _Tp = int; _Up = int]'
1297 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
a.cc:31:5: note: candidate: 'int get(std::pair<long long int, long long int>)'
31 | int get(PLL X){
| ^~~
|
s214265977 | p03859 | Java | import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import lib.io.ExtendedScanner;
import lib.io.Out;
import lib.util.IntPair;
public class Main {
public static void main(String[] args) throws Exception {
Field f = System.out.getClass().getDeclaredField("autoFlush");
f.setAccessible(true);
f.set(System.out, false);
execute(System.in, System.out);
}
public static void execute(InputStream in, OutputStream out) {
ExtendedScanner s = new ExtendedScanner(in);
Out o = new Out(out);
solve(s, o);
o.flush();
o.close();
}
public static void solve(ExtendedScanner sc, Out out) {
int mod = 1000000007;
int n = sc.nextInt();
int m = sc.nextInt();
var s = sc.nextChars();
var cum = new int[n + 1];
for (int i = 0; i < n; i++) {
cum[i + 1] = cum[i] + s[i] - '0';
}
var comb = new long[n + 1][];
for (int i = 0; i <= n; i++) {
comb[i] = new long[i + 1];
comb[i][0] = comb[i][i] = 1;
for (int j = 1; j < i; j++) {
comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
if (comb[i][j] >= mod) {
comb[i][j] -= mod;
}
}
}
var segs = new ArrayList<IntPair>();
for (int i = 0; i < m; i++) {
int l = sc.nextInt() - 1;
int r = sc.nextInt();
if (i == 0) {
segs.add(new IntPair(l, r));
} else {
var last = segs.get(segs.size() - 1);
if (last.fst == l && last.snd < r) {
last.snd = r;
} else if (last.fst < l && last.snd < r) {
segs.add(new IntPair(l, r));
}
}
}
m = segs.size();
var l = new int[m];
var r = new int[m];
for (int i = 0; i < m; i++) {
var seg = segs.get(i);
l[i] = seg.fst;
r[i] = seg.snd;
out.write(l[i]).write(' ').writeln(r[i]);
}
var dp = new long[m + 1][n + 1];
dp[0][cum[r[0]] - cum[l[0]]] = 1;
for (int i = 0; i < m - 1; i++) {
int w = r[i] - l[i];
int x = r[i] - l[i + 1];
if (x <= 0) {
long sum = 0;
for (int j = 0; j <= w; j++) {
sum += dp[i][j] * comb[w][j];
}
sum %= mod;
dp[i + 1][cum[r[i + 1]] - cum[l[i + 1]]] = sum;
continue;
}
int p = cum[r[i + 1]] - cum[r[i]];
for (int j = 0; j <= n; j++) {
if (dp[i][j] == 0) continue;
int l1 = Math.max(0, x - (w - j));
int r1 = Math.min(j, x);
for (int k = l1; k <= r1; k++) {
dp[i + 1][p + k] += comb[w - x][j - k] * dp[i][j];
dp[i + 1][p + k] %= mod;
}
}
}
for (int j = 0, w = r[m - 1] - l[m - 1]; j <= w; j++) {
dp[m][j] = (dp[m - 1][j] * comb[w][j]) % mod;
}
long ans = 0;
for (int j = 0; j <= n; j++) {
ans += dp[m][j];
}
ans %= mod;
out.writeln(ans < 0 ? ans + mod : ans);
}
}
| Main.java:9: error: package lib.io does not exist
import lib.io.ExtendedScanner;
^
Main.java:10: error: package lib.io does not exist
import lib.io.Out;
^
Main.java:11: error: package lib.util does not exist
import lib.util.IntPair;
^
Main.java:29: error: cannot find symbol
public static void solve(ExtendedScanner sc, Out out) {
^
symbol: class ExtendedScanner
location: class Main
Main.java:29: error: cannot find symbol
public static void solve(ExtendedScanner sc, Out out) {
^
symbol: class Out
location: class Main
Main.java:22: error: cannot find symbol
ExtendedScanner s = new ExtendedScanner(in);
^
symbol: class ExtendedScanner
location: class Main
Main.java:22: error: cannot find symbol
ExtendedScanner s = new ExtendedScanner(in);
^
symbol: class ExtendedScanner
location: class Main
Main.java:23: error: cannot find symbol
Out o = new Out(out);
^
symbol: class Out
location: class Main
Main.java:23: error: cannot find symbol
Out o = new Out(out);
^
symbol: class Out
location: class Main
Main.java:49: error: cannot find symbol
var segs = new ArrayList<IntPair>();
^
symbol: class IntPair
location: class Main
Main.java:54: error: cannot find symbol
segs.add(new IntPair(l, r));
^
symbol: class IntPair
location: class Main
Main.java:60: error: cannot find symbol
segs.add(new IntPair(l, r));
^
symbol: class IntPair
location: class Main
12 errors
|
s935892556 | p03859 | C++ | #pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
// #define INF 100000000
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
string stin() {string s;cin>>s;return s;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
const ll MOD=1e9+7;
const int N=1100000;
template <ll Modulus> class modint {
using u64 = ll;
public:
u64 a;
constexpr modint(const u64 x = 0) noexcept : a(((x % Modulus) + Modulus)%Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};
#define mint modint<MOD>
mint inv[N],comb[N],prd[N],invprd[N];
void calc_inv(){
inv[1]=1;
rep2(i,2,N-1){
inv[i]=inv[MOD%i]*(-MOD/i);
}
return;
}
void calc_product(){
prd[0]=prd[1]=1;
invprd[0]=invprd[1]=1;
rep2(i,2,N-1){
prd[i]=prd[i-1]*i;
invprd[i]=inv[i]*invprd[i-1];
}
return ;
}
mint cmb(int a,int b){
if(a<b)return 0;
if(a<0||b<0)return 0;
return {prd[a]*invprd[b]*invprd[a-b]};
}
mint modpow(mint x,ll n){
if(n==0) return 1;
mint res=modpow(x*x,n/2);
if(n&1) res=res*x;
return res;
}
void calc(){calc_inv();calc_product();}
using vmint = vector<mint> ;
void print(vmint v){
for(auto e:v)cout<<e.a<<" ";
cout<<endl;
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
int n=in(),m=in();
calc();
string s;cin>>s;
vec a;
a.pb(0);
for(auto e:s){
a.pb(a.back()+(e=='1'));
}
vecpii v;
rep(i,m){
int l=in(),r=in();
if(!v.empty() and v.back().fi==l)chmax(v.back().se,r);
else if(!v.empty() and v.back().se>=r) continue;
else v.eb(l,r);
}
v.eb(n+1,n+1);
vmint dp(n+1);
dp[0]=1;
int prel=0,prer=0;
rep(i,v.size()-1){
int x = v[i+1].fi-1 , y = v[i].se;
vmint next(n+1);
if(v[i+1].fi>v[i].se){
int l = a[y];
rep2(j,prel,prer){
next[l]+=dp[j]*cmb(v[i].se-v[i].fi+1,l-j);
}
dp=vmint(n+1);
dp[a[v[i+1].fi-1]]=next[l];
prel=prer=a[v[i+1].fi-1];
continue;
}
rep2(j,prel,prer){
int l = max((int)j,x-y+a[y]);
int r = min((int)j+x-v[i].fi+1,a[y]);
rep2(k,l,r){
next[k]+=dp[j]*cmb(x-v[i].fi+1,k-j);
}
}
dp=next;
prel=l,prer=r;
}
cout<<dp[a[n]].a<<endl;
}
| a.cc: In function 'int main()':
a.cc:171:14: error: 'l' was not declared in this scope
171 | prel=l,prer=r;
| ^
a.cc:171:21: error: 'r' was not declared in this scope
171 | prel=l,prer=r;
| ^
|
s018568922 | p03859 | C++ | #include <bits/stdc++.h>
#define endl '\n'
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return vec<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
namespace math {
template <typename T>
constexpr T pow(const T &n, ll k) {
T ret = n.mul_id_ele();
T cur = n;
while (k) {
if (k & 1) ret *= cur;
cur *= cur;
k /= 2;
}
return ret;
}
}
namespace math {
template <ll Mod>
struct Modint {
constexpr Modint(ll x) : x(x % Mod) { }
constexpr Modint() : Modint(0) { }
constexpr Modint<Mod> add_id_ele() const {
return Modint<Mod>(0);
}
constexpr Modint<Mod> mul_id_ele() const {
return Modint<Mod>(1);
}
constexpr ll& value() {
return x;
}
constexpr ll value() const {
return x;
}
constexpr Modint& operator +=(const Modint &oth) {
x += oth.value();
if (Mod <= x) x -= Mod;
return *this;
}
constexpr Modint& operator -=(const Modint &oth) {
x += Mod - oth.value();
if (Mod <= x) x -= Mod;
return *this;
}
constexpr Modint& operator *=(const Modint &oth) {
x *= oth.value();
x %= Mod;
return *this;
}
constexpr Modint& operator /=(const Modint &oth) {
x *= oth.inv();
x %= Mod;
return *this;
}
constexpr Modint operator +(const Modint &oth) const {
return Modint(x) += oth;
}
constexpr Modint operator -(const Modint &oth) const {
return Modint(x) -= oth;
}
constexpr Modint operator *(const Modint &oth) const {
return Modint(x) *= oth;
}
constexpr Modint operator /(const Modint &oth) const {
return Modint(x) /= oth;
}
constexpr Modint operator -() const {
return Modint((x != 0) * (Mod - x));
}
template <typename T>
constexpr typename std::enable_if<std::is_integral<T>::value, const Modint&>::type
operator =(T t) {
(*this) = Modint(std::forward<T>(t));
return *this;
}
constexpr Modint inv() const {
return ::math::pow(*this, Mod - 2);
}
constexpr ll mod() const {
return Mod;
}
private:
ll x;
};
}
const ll mod = 1e9 + 7;
const ll inf = 5e15;
using mint = math::Modint<mod>;
const std::size_t SIZE = 3010;
mint dp_buf[2][SIZE];
auto dp1 = dp_buf[0], dp2 = dp_buf[1];
int main() {
ll n, m;
std::string s;
std::cin >> n >> m >> s;
vec<ll> rights(n, -inf);
for (ll i = 0; i < m; i++) {
ll l, r;
std::cin >> l >> r;
chmax(rights[l - 1], r);
}
{
ll maxr = -inf;
for (ll i = 0; i < n; i++) {
if (rights[i] <= maxr) rights[i] = -inf;
else maxr = rights[i];
}
}
std::queue<pll> ops;
for (ll i = 0; i < n; i++) if (rights[i] != -inf) ops.emplace(i, rights[i]);
vec<ll> sum(n + 1);
for (ll i = 0; i < n; i++) sum[i + 1] = sum[i] + (s[i] == '1');
auto calc_dp = [&](std::queue<pll> &ranges) {
ll minl, cr;
std::tie(minl, cr) = ranges.front();
ranges.pop();
std::fill(dp1, dp1 + SIZE, mint(0));
dp1[0] = 1;
for (ll i = minl;; i++) {
if (ranges.empty() && i == cr) break;
std::fill(dp2, dp2 + SIZE, mint(0));
if (ranges.size() && ranges.front().first == i) {
cr = ranges.front().second;
ranges.pop();
}
for (ll j = 0; j <= sum[cr] - sum[minl]; j++) {
if (j < sum[cr] - sum[minl]) dp2[j + 1] += dp1[j];
if (sum[cr] - sum[minl] <= j + (cr - i) - 1) dp2[j] += dp1[j];
}
std::copy(dp2, dp2 + SIZE, dp1);
}
return dp1[sum[cr] - sum[minl]];
};
mint ans = 1;
while (ops.size()) {
std::queue<pll> que;
auto move_ele = [&] {
que.push(ops.front());
ops.pop();
};
move_ele();
ll cr = que.front().second;
while (ops.size()) {
ll l, r;
std::tie(l, r) = ops.front();
if (cr <= l) break;
cr = r;
move_ele();
}
vec<pll> tmp;
auto cpy = que;
while (cpy.size()) { tmp.push_back(cpy.front()); cpy.pop(); }
#endif
ans *= calc_dp(que);
}
std::cout << ans.value() << endl;
return 0;
}
| a.cc:208:2: error: #endif without #if
208 | #endif
| ^~~~~
|
s316691197 | p03859 | C++ | #include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=3e5+100;
const int MOD=1000000007;
const int inf=0x3f3f3f3f;
ll read()
{
ll sum=0;
ll flag=1;
char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-')
{
flag=-1;
}
c=getchar();
}
while(c>='0'&&c<='9')
{
sum=((sum*10)+c-'0');
c=getchar();
}
return sum*flag;
}
int n,m;
char s[twx];
int l[twx],r[twx];
int ans=0;
int one[twx];
int asd[twx][twx];
int To[twx];
ll add(ll x,ll y)
{
return x+y>=MOD?x+y-MOD:x+y;
}
ll sub(ll x,ll y)
{
return x-y<0?x-y+MOD:x-y;
}
ll mul(ll x,ll y)
{
return 1LL*x*y%MOD;
}
void init()
{
n=read();
m=read();
scanf("%s",s+1);
f1(1,n,i)
{
if(s[i]=='1')
{
one[i]=one[i-1]+1;
}
else
{
one[i]=one[i-1];
}
To[i]=i;
}
one[n+1]=one[n];
f1(1,m,i)
{
l[i]=read();
r[i]=read();
To[l[i]]=max(To[l[i]],r[i]);
}
f1(2,n+1,i)
{
To[i]=max(To[i],To[i-1]);
}
}
void work()
{
asd[1][one[To[1]]]=1;
f1(1,n,i)
{
f1(0,n,j)
{
if(asd[i][j])
{
int Left=To[i]+1;
int Right=To[i+1];
int tmp=one[Right]-one[Left-1];
int a=j;
int b=To[i]-i+1-a;
if(a)
{
asd[i+1][j+tmp-1]=add(asd[i+1][j+tmp-1],asd[i][j]);
}
if(b)
{
asd[i+1][j+tmp]=add(asd[i+1][j+tmp],asd[i][j]);
}
}
}
}
}
void print()
{
printf("%d\n",asd[n+1][0]);
}
int main()
{
init();
work();
print();
return 0;
} | /tmp/ccTTn28J.o: in function `init()':
a.cc:(.text+0x218): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x2f0): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x32a): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x360): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x377): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x39c): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
/tmp/ccTTn28J.o: in function `work()':
a.cc:(.text+0x3c3): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x450): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x470): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
a.cc:(.text+0x4c6): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccTTn28J.o
collect2: error: ld returned 1 exit status
|
s459904394 | p03859 | C++ | #include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=3e5+100;
const int MOD=1000000007;
const int inf=0x3f3f3f3f;
ll read()
{
ll sum=0;
ll flag=1;
char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-')
{
flag=-1;
}
c=getchar();
}
while(c>='0'&&c<='9')
{
sum=((sum*10)+c-'0');
c=getchar();
}
return sum*flag;
}
int n,m;
char s[twx];
int l[twx],r[twx];
int ans=0;
int one[twx];
int asd[twx][twx];
int To[twx];
ll add(ll x,ll y)
{
return x+y>=MOD?x+y-MOD:x+y;
}
ll sub(ll x,ll y)
{
return x-y<0?x-y+MOD:x-y;
}
ll mul(ll x,ll y)
{
return 1LL*x*y%MOD;
}
void init()
{
n=read();
m=read();
scanf("%s",s+1);
f1(1,n,i)
{
if(s[i]=='1')
{
one[i]=one[i-1]+1;
}
else
{
one[i]=one[i-1];
}
To[i]=i;
}
one[n+1]=one[n];
f1(1,m,i)
{
l[i]=read();
r[i]=read();
To[l[i]]=max(To[l[i]],r[i]);
}
f1(2,n+1,i)
{
To[i]=max(To[i],To[i-1]);
}
}
void work()
{
asd[1][one[To[1]]]=1;
f1(1,n,i)
{
f1(0,n,j)
{
if(asd[i][j])
{
int Left=To[i]+1;
int Right=To[i+1];
int tmp=one[Right]-one[Left-1];
int a=j;
int b=To[i]-i+1-a;
if(a)
{
asd[i+1][j+tmp-1]=add(asd[i+1][j+tmp-1],asd[i][j]);
}
if(b)
{
asd[i+1][j+tmp]=add(asd[i+1][j+tmp],asd[i][j]);
}
}
}
}
}
void print()
{
printf("%d\n",asd[n+1][0]);
}
int main()
{
init();
work();
print();
return 0;
} | /tmp/ccd2mm1S.o: in function `init()':
a.cc:(.text+0x218): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x2f0): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x32a): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x360): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x377): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x39c): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
/tmp/ccd2mm1S.o: in function `work()':
a.cc:(.text+0x3c3): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x450): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x470): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
a.cc:(.text+0x4c6): relocation truncated to fit: R_X86_64_PC32 against symbol `To' defined in .bss section in /tmp/ccd2mm1S.o
collect2: error: ld returned 1 exit status
|
s274619083 | p03859 | C++ | #include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m;
string s;
int cnt[3005];
int mx[3005], mn[3005];
int dp[3005][3005];
signed main()
{
cin>>n>>m>>s;
for(int i=1; i<=n; i++)
{
cnt[i]=cnt[i-1]+(s[i-1]=='1');
mx[i]=cnt[i], mn[i]=cnt[i];
}
for(int i=1; i<=m; i++)
{
int l, r;
cin>>l>>r;
int lol=mn[r]-mn[l-1], lel=mx[r]-mx[l-1];
for(int j=l; j<=r; j++)
{
mn[j]=min(mn[j], mn[l-1]+max(0, lol-(r-j)));
mx[j]=max(mx[j], mx[l-1]+min(j-l+1, lel));
}
}
// for(int i=1; i<=n; i++)
// {
// cout<<mx[i]<<" "<<mn[i]<<endl;
// }
dp[0][0]=1;
for(int i=1; i<=n; i++)
{
for(int j=mn[i]; j<=mx[i]; j++)
{
if(j>0)
{
dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
}
else
{
dp[i][j]=dp[i-1][j];
}
dp[i][j]%=1000000007;
}
}
cout<<dp[n][cnt[n]];
} | a.cc: In function 'int main()':
a.cc:28:53: error: no matching function for call to 'max(int, long long int)'
28 | mn[j]=min(mn[j], mn[l-1]+max(0, lol-(r-j)));
| ~~~^~~~~~~~~~~~~~
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: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:28:53: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
28 | mn[j]=min(mn[j], mn[l-1]+max(0, lol-(r-j)));
| ~~~^~~~~~~~~~~~~~
/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:
/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:28:53: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
28 | mn[j]=min(mn[j], mn[l-1]+max(0, lol-(r-j)));
| ~~~^~~~~~~~~~~~~~
|
s630819882 | p03859 | C++ | #include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 2005;
const int MOD = 1e9 + 7;
template <typename T> inline void read(T &AKNOI) {
T x = 0, flag = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') flag = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
AKNOI = flag * x;
}
int n, m, sum[MAXN], rbd[MAXN];
int dp[MAXN][MAXN];
inline int Inc(int &x, int y) {
x += y; if (x >= MOD) x -= MOD;
}
void init() {
read(n); read(m);
scanf("%s", s + 1);
for (int i=1;i<=n;++i) {
sum[i] = sum[i-1] + s[i] - '0';
rbd[i] = i;
}
sum[n+1] = sum[n]; rbd[n+1] = n+1;
for (int i=1;i<=m;++i) {
int l, r;
read(l); read(r);
cmax(rbd[l], r);
}
for (int i=1;i<=n;++i) {
cmax(rbd[i], rbd[i-1]);
}
}
void solvee() {
dp[1][sum[rbd[1]]] = 1;
for (int i=1;i<=n;++i) {
for (int j=0;j<=n;++j) {
int x = dp[i][j];
if (!x) continue;
int l = rbd[i], r = rbd[i+1];
int cnt1 = j, cnt0 = rbd[i] - i + 1 - j;
if (cnt0) Inc(dp[i+1][j+sum[r]-sum[l-1]], x);
if (cnt1) Inc(dp[i+1][j-1+sum[r]-sum[l-1]], x);
}
}
printf("%d\n", dp[n+1][0]);
}
int main() {
init();
solve();
return 0;
}
| a.cc: In function 'int Inc(int&, int)':
a.cc:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
29 | }
| ^
a.cc: In function 'void init()':
a.cc:33:21: error: 's' was not declared in this scope
33 | scanf("%s", s + 1);
| ^
a.cc:42:17: error: 'cmax' was not declared in this scope; did you mean 'fmax'?
42 | cmax(rbd[l], r);
| ^~~~
| fmax
a.cc:45:17: error: 'cmax' was not declared in this scope; did you mean 'fmax'?
45 | cmax(rbd[i], rbd[i-1]);
| ^~~~
| fmax
a.cc: In function 'int main()':
a.cc:66:9: error: 'solve' was not declared in this scope; did you mean 'solvee'?
66 | solve();
| ^~~~~
| solvee
|
s399718274 | p03859 | C++ | #include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#define SF scanf
#define PF printf
#define MAXN 3010
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[MAXN][MAXN];
int n,m;
char s[MAXN];
int end[MAXN],pre[MAXN];
int main(){
SF("%d%d",&n,&m);
SF("%s",s+1);
for(int i=1;i<=n+1;i++)
pre[i]=pre[i-1]+(s[i]=='1');
int las=1;
int u,v;
for(int i=1;i<=n+1;i++)
end[i]=max(end[i],i);
for(int i=1;i<=m;i++){
SF("%d%d",&u,&v);
end[u]=max(end[u],v);
}
for(int i=1;i<=n+1;i++)
end[i]=max(end[i],end[i-1]);
dp[1][pre[end[1]]]=1;
for(int i=1;i<=n;i++)
for(int j=0;j<=n;j++)
if(dp[i][j]){
int l=end[i];
int r=end[i+1];
int one=j;
int zero=end[i]-i+1-j;
if(zero)
(dp[i+1][j+pre[r]-pre[l]]+=dp[i][j])%=MOD;
if(one)
(dp[i+1][j-1+pre[r]-pre[l]]+=dp[i][j])%=MOD;
}
PF("%lld",dp[n+1][0]);
} | a.cc: In function 'int main()':
a.cc:26:17: error: reference to 'end' is ambiguous
26 | end[i]=max(end[i],i);
| ^~~
In file included from /usr/include/c++/14/map:65,
from a.cc:5:
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
from /usr/include/c++/14/bits/stl_algo.h:59,
from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:17:5: note: 'int end [3010]'
17 | int end[MAXN],pre[MAXN];
| ^~~
a.cc:26:28: error: reference to 'end' is ambiguous
26 | end[i]=max(end[i],i);
| ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:17:5: note: 'int end [3010]'
17 | int end[MAXN],pre[MAXN];
| ^~~
a.cc:29:17: error: reference to 'end' is ambiguous
29 | end[u]=max(end[u],v);
| ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:17:5: note: 'int end [3010]'
17 | int end[MAXN],pre[MAXN];
| ^~~
a.cc:29:28: error: reference to 'end' is ambiguous
29 | end[u]=max(end[u],v);
| ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:17:5: note: 'int end [3010]'
17 | int end[MAXN],pre[MAXN];
| ^~~
a.cc:32:17: error: reference to 'end' is ambiguous
32 | end[i]=max(end[i],end[i-1]);
| ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:17:5: note: 'int end [3010]'
17 | int end[MAXN],pre[MAXN];
| ^~~
a.cc:32:28: error: reference to 'end' is ambiguous
32 | end[i]=max(end[i],end[i-1]);
| ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:17:5: note: 'int end [3010]'
17 | int end[MAXN],pre[MAXN];
| ^~~
a.cc:32:35: error: reference to 'end' is ambiguous
32 | end[i]=max(end[i],end[i-1]);
| ^~~
/usr/include/c++/14/bits/range_acc |
s541392176 | p03859 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define int long long
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
int x = 0; char ch = gc(); bool positive = 1;
for (; !isdigit(ch); ch = gc()) if (ch == '-') positive = 0;
for (; isdigit(ch); ch = gc()) x = x * 10 + ch - '0';
return positive ? x : -x;
}
inline void write(int a){
if(a<0){
a=-a; putchar('-');
}
if(a>=10)write(a/10);
putchar('0'+a%10);
}
inline void writeln(int a){
write(a); puts("");
}
const int N=6005,mod=1000000007;
int n,m,tot,q[N],sum[N],l[N],r[N],f[N][N],c[N][N];
char ch[N];
signed main(){
n=read(); m=read();
scanf("%s",ch+1);
for(int i=1;i<=n;i++)sum[i]=sum[i-1]+ch[i]-'0';
for(int i=1;i<=m;i++){
l[i]=read(); r[i]=read();
if(r[i]>r[q[tot]])q[++tot]=i;
}
for(int i=0;i<N;i++){
c[i][0]=1;
for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
}
for(int i=1;i<=tot;i++){
l[i]=l[q[i]]; r[i]=r[q[i]];
}
m=tot; l[m+1]=n+1; f[0][0]=1;
for(int i=1;i<=m;i++){
int t=sum[r[i]]-sum[r[i-1]];
if(r[i]<l[i+1]){
int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+1);
for(int j=0;j+t<=jb&&j<=meiju;j++)f[i][0]=(f[i][0]+(ll)c[jb][j+t]*f[i-1][j])%mod;
}else{
int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+1);
for(int j=0;j<=r[i]-l[i+1]+1;j++){
for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
f[i][j]=(f[i][j]+(ll)c[jb][k+t-j]*f[i-1][k])%mod;
}
}
}
//for(int j=0;j<=max(0,r[i]-l[i+1]);j++)cout<<f[i][j]<<" "<<i<<" "<<j<<endl;
}
//cout<<f[1][0]<<" "<<f[1][1]<<endl;
cout<<f[m][0]<<endl;
}
| a.cc: In function 'int main()':
a.cc:57:53: error: no matching function for call to 'max(int, long long int)'
57 | int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+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: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:57:53: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
57 | int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+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:3:
/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:57:53: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
57 | int jb=r[i]-l[i]+1,meiju=max(0,r[i-1]-l[i]+1);
| ~~~^~~~~~~~~~~~~~~~~
a.cc:60:53: error: no matching function for call to 'max(int, long long int)'
60 | int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+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:53: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
60 | int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+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:53: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
60 | int jb=l[i+1]-l[i],meiju=max(0,r[i-1]-l[i]+1);
| ~~~^~~~~~~~~~~~~~~~~
a.cc:62:46: error: no matching function for call to 'max(long long int, int)'
62 | for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
| ~~~^~~~~~~
/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:62:46: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
62 | for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
| ~~~^~~~~~~
/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:62:46: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
62 | for(int k=max(j-t,0);k+t-j<=jb&&k<=meiju;k++){
| ~~~^~~~~~~
|
s692187203 | p03859 | C++ | #ifndef __INTMOD_H__0001__
#define __INTMOD_H__0001__
#include <vector>
#include <iostream>
#include <cassert>
#include <iostream>
/* Modulus must be less than 0x80000000, and not be 0. */
template <uint32_t Modulus>
class IntMod {
typedef int32_t Int;
typedef uint32_t UInt;
typedef int64_t Long;
typedef uint64_t ULong;
public:
template <unsigned int Modulus_>
friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
private:
UInt value_m;
public:
IntMod() { value_m = 0; }
IntMod(UInt value) { value_m = value % Modulus; }
IntMod(ULong value) { value_m = value % Modulus; }
IntMod(Int value) {
Int tmp = value % (Int)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(Long value) {
Int tmp = value % (Long)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(const IntMod& other) : value_m(other.value_m) {}
IntMod& operator=(const IntMod& other) { value_m = other.value_m; return *this; }
const IntMod& operator+() const { return *this; }
IntMod operator-() const { return IntMod(Modulus - value_m); }
IntMod& operator++() {
++value_m;
if (value_m == Modulus) value_m = 0;
return *this;
}
IntMod& operator--() {
if (value_m == 0) value_m = Modulus;
--value_m;
return *this;
}
IntMod operator++(int dummy) {
IntMod tmp(*this);
++(*this);
return tmp;
}
IntMod operator--(int dummy) {
IntMod tmp(*this);
--(*this);
return tmp;
}
IntMod& operator+=(const IntMod& right) {
value_m += right.value_m; // value_m < 0x80000000
if (value_m >= Modulus) value_m -= Modulus;
return *this;
}
IntMod& operator-=(const IntMod& right) {
if (value_m < right.value_m) value_m += Modulus;
value_m -= right.value_m;
return *this;
}
IntMod& operator*=(const IntMod& right) {
value_m = ((ULong)value_m * right.value_m) % Modulus;
return *this;
}
IntMod& operator/=(const IntMod& right) {
(*this) *= (right.Inverse());
return *this;
}
// for power
IntMod operator[](unsigned int exp) const {
return Pow(exp);
}
/* Modulus must be a prime. */
IntMod Inverse() const { return (*this).Pow(Modulus - 2); }
IntMod Pow(UInt exp) const {
IntMod product = 1;
IntMod factor(*this);
while (exp > 0) {
if (exp & 1) product *= factor;
factor *= factor;
exp >>= 1;
}
return product;
}
UInt Get_value() const {
return value_m;
}
static IntMod Fact(UInt num) {
static std::vector<IntMod> table(1, 1);
if (table.size() > num) return table[num];
int old_size = table.size();
table.resize(num + 1);
for (int i = old_size; i <= num; i++) {
table[i] = table[i - 1] * i;
}
return table[num];
}
static IntMod Combi(UInt n, UInt r) {
if (n < r) throw "okashii";
return IntMod::Fact(n) / (IntMod::Fact(n - r) * IntMod::Fact(r));
}
static std::vector<IntMod> Inverse_list(int size) {
assert(size < Modulus);
std::vector<IntMod> ret_arr(size + 1);
ret_arr[1] = 1;
for (int i = 2; i <= size; ++i) {
ret_arr[i] = ((ULong)(Modulus - Modulus / i) * ret_arr[Modulus % i].Get_value()) % Modulus;
}
return ret_arr;
}
};
template <unsigned int Modulus>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
IntMod<Modulus> ret(left);
ret += right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret -= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret *= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret /= right;
return ret;
}
template <unsigned int Modulus>
bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
template <unsigned int Modulus>
bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
/* for set/map */
template <unsigned int Modulus>
bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
template <unsigned int Modulus>
bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
template <unsigned int Modulus>
bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
template <unsigned int Modulus>
bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, Integer right) { return left + IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) + right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, Integer right) { return left - IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) - right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, Integer right) { return left * IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) * right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, Integer right) { return left / IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) / right; }
template <unsigned int Modulus>
std::istream& operator<<(std::istream& ist, const IntMod<Modulus>& val) {
uint64_t tmp;
ist >> tmp;
val = tmp;
return ist;
}
template <unsigned int Modulus>
std::ostream& operator<<(std::ostream& ost, const IntMod<Modulus>& val) {
ost << val.Get_value();
return ost;
}
typedef IntMod<1000000007> MInt;
#if 1
MInt operator"" _m(unsigned long long num) { return MInt((uint64_t)num); }
#endif
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先
#endif
struct CompBySecond {
bool operator()(const PP& a, const PP& b) const {
return a.second < b.second || (a.second == b.second && a.first < b.first);
}
};
template<class T>
class Array {
T* ptr_m;
size_t size_m;
};
//#include "Union_Find.h"
int N, M;
string S;
vector<int> L, R;
int X[3000];
int W[3000];
int O[3000];
bool flg[3000];
MInt DP[3001][3001];
MInt C(int n, int r)
return MInt::Combi(n, r);
}
int main() {
cin >> N >> M >> S;
REP(i, 0, M) {
int l, r;
cin >> l >> r;
--l;
L.push_back(l);
R.push_back(r);
}
REP(i, 1, L.size()) {
if (R[i - 1] >= R[i]) {
L.erase(L.begin() + i);
R.erase(R.begin() + i);
--i;
}
}
REP(i, 1, L.size()) {
if (R[i - 1] < L[i]) {
L.insert(L.begin() + i, R[i - 1]);
R.insert(R.begin() + i, R[i - 1] + 1);
}
}
M = L.size();
REP(i, 0, M) {
X[i] = i == M - 1 ? R[M - 1] - L[M - 1] : L[i + 1] - L[i];
W[i] = R[i] - L[i];
O[i] = count(S.begin(), S.begin() + R[i], '1');
}
DP[0][count(S.begin(), S.begin() + L[0], '1')] = 1;
REP(i, 1, M + 1) {
REP(j, max(0, X[i - 1] + O[i - 1] - W[i - 1]), min(N, O[i - 1]) + 1) {
REP(k, 0, min(j, X[i - 1]) + 1) {
DP[i][j] += DP[i - 1][j - k] * C(X[i - 1], k);
}
}
}
cout << DP[M][O[M - 1]].Get_value() << endl;
return 0;
}
| a.cc:10:11: error: 'uint32_t' has not been declared
10 | template <uint32_t Modulus>
| ^~~~~~~~
a.cc:13:17: error: 'uint32_t' does not name a type
13 | typedef uint32_t UInt;
| ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
6 | #include <cassert>
+++ |+#include <cstdint>
7 | #include <iostream>
a.cc:15:17: error: 'uint64_t' does not name a type
15 | typedef uint64_t ULong;
| ^~~~~~~~
a.cc:15:17: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:19:21: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
19 | friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:21:21: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
21 | friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:23:21: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
23 | friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:25:21: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
25 | friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:27:21: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
27 | friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:29:21: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
29 | friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:32:9: error: 'UInt' does not name a type; did you mean 'Int'?
32 | UInt value_m;
| ^~~~
| Int
a.cc:36:20: error: expected ')' before 'value'
36 | IntMod(UInt value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:37:21: error: expected ')' before 'value'
37 | IntMod(ULong value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:96:20: error: 'UInt' has not been declared
96 | IntMod Pow(UInt exp) const {
| ^~~~
a.cc:106:9: error: 'UInt' does not name a type; did you mean 'Int'?
106 | UInt Get_value() const {
| ^~~~
| Int
a.cc:110:28: error: 'UInt' has not been declared
110 | static IntMod Fact(UInt num) {
| ^~~~
a.cc:122:29: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:122:37: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:139:17: error: 'int operator+(const int&, int)' must have an argument of class or enumerated type
139 | IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
| ^~~~~~~~
a.cc:146:17: error: 'int operator-(const int&, const int&)' must have an argument of class or enumerated type
146 | IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:153:17: error: 'int operator*(const int&, const int&)' must have an argument of class or enumerated type
153 | IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:160:17: error: 'int operator/(const int&, const int&)' must have an argument of class or enumerated type
160 | IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:168:6: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
168 | bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
| ^~~~~~~~
a.cc:170:6: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
170 | bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
| ^~~~~~~~
a.cc:173:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
173 | bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
| ^~~~~~~~
a.cc:175:6: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
175 | bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
| ^~~~~~~~
a.cc:177:6: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
177 | bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
| ^~~~~~~~
a.cc:179:6: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
179 | bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
| ^~~~~~~~
a.cc: In function 'std::istream& operator<<(std::istream&, const int&)':
a.cc:200:9: error: 'uint64_t' was not declared in this scope
200 | uint64_t tmp;
| ^~~~~~~~
a.cc:200:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:201:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
201 | ist >> tmp;
| ^~~
| tm
a.cc: In function 'std::ostream& operator<<(std::ostream&, const int&)':
a.cc:208:20: error: request for member 'Get_value' in 'val', which is of non-class type 'const int'
208 | ost << val.Get_value();
| ^~~~~~~~~
a.cc: In function 'MInt operator""_m(long long unsigned int)':
a.cc:215:59: error: 'uint64_t' was not declared in this scope
215 | MInt operator"" _m(unsigned long long num) { return MInt((uint64_t)num); }
| ^~~~~~~~
a.cc:215:59: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'MInt C(int, int)':
a.cc:295:9: error: named return values are no longer supported
295 | return MInt::Combi(n, r);
| ^~~~~~
a.cc:337:33: error: request for member 'Get_value' in 'DP[M][O[(M - 1)]]', which is of non-class type 'MInt' {aka 'int'}
337 | cout << DP[M][O[M - 1]].Get_value() << endl;
| ^~~~~~~~~
|
s678193914 | p03859 | C++ | #ifndef __INTMOD_H__0001__
#define __INTMOD_H__0001__
#include <vector>
#include <iostream>
#include <cassert>
#include <iostream>
/* Modulus must be less than 0x80000000, and not be 0. */
template <uint32_t Modulus>
class IntMod {
typedef int32_t Int;
typedef uint32_t UInt;
typedef int64_t Long;
typedef uint64_t ULong;
public:
template <unsigned int Modulus_>
friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
private:
UInt value_m;
public:
IntMod() { value_m = 0; }
IntMod(UInt value) { value_m = value % Modulus; }
IntMod(ULong value) { value_m = value % Modulus; }
IntMod(Int value) {
Int tmp = value % (Int)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(Long value) {
Int tmp = value % (Long)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(const IntMod& other) : value_m(other.value_m) {}
IntMod& operator=(const IntMod& other) { value_m = other.value_m; return *this; }
const IntMod& operator+() const { return *this; }
IntMod operator-() const { return IntMod(Modulus - value_m); }
IntMod& operator++() {
++value_m;
if (value_m == Modulus) value_m = 0;
return *this;
}
IntMod& operator--() {
if (value_m == 0) value_m = Modulus;
--value_m;
return *this;
}
IntMod operator++(int dummy) {
IntMod tmp(*this);
++(*this);
return tmp;
}
IntMod operator--(int dummy) {
IntMod tmp(*this);
--(*this);
return tmp;
}
IntMod& operator+=(const IntMod& right) {
value_m += right.value_m; // value_m < 0x80000000
if (value_m >= Modulus) value_m -= Modulus;
return *this;
}
IntMod& operator-=(const IntMod& right) {
if (value_m < right.value_m) value_m += Modulus;
value_m -= right.value_m;
return *this;
}
IntMod& operator*=(const IntMod& right) {
value_m = ((ULong)value_m * right.value_m) % Modulus;
return *this;
}
IntMod& operator/=(const IntMod& right) {
(*this) *= (right.Inverse());
return *this;
}
// for power
IntMod operator[](unsigned int exp) const {
return Pow(exp);
}
/* Modulus must be a prime. */
IntMod Inverse() const { return (*this).Pow(Modulus - 2); }
IntMod Pow(UInt exp) const {
IntMod product = 1;
IntMod factor(*this);
while (exp > 0) {
if (exp & 1) product *= factor;
factor *= factor;
exp >>= 1;
}
return product;
}
UInt Get_value() const {
return value_m;
}
static IntMod Fact(UInt num) {
static std::vector<IntMod> table(1, 1);
if (table.size() > num) return table[num];
int old_size = table.size();
table.resize(num + 1);
for (int i = old_size; i <= num; i++) {
table[i] = table[i - 1] * i;
}
return table[num];
}
static IntMod Combi(UInt n, UInt r) {
if (n < r) throw "okashii";
return IntMod::Fact(n) / (IntMod::Fact(n - r) * IntMod::Fact(r));
}
static std::vector<IntMod> Inverse_list(int size) {
assert(size < Modulus);
std::vector<IntMod> ret_arr(size + 1);
ret_arr[1] = 1;
for (int i = 2; i <= size; ++i) {
ret_arr[i] = ((ULong)(Modulus - Modulus / i) * ret_arr[Modulus % i].Get_value()) % Modulus;
}
return ret_arr;
}
};
template <unsigned int Modulus>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
IntMod<Modulus> ret(left);
ret += right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret -= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret *= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret /= right;
return ret;
}
template <unsigned int Modulus>
bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
template <unsigned int Modulus>
bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
/* for set/map */
template <unsigned int Modulus>
bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
template <unsigned int Modulus>
bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
template <unsigned int Modulus>
bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
template <unsigned int Modulus>
bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, Integer right) { return left + IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) + right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, Integer right) { return left - IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) - right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, Integer right) { return left * IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) * right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, Integer right) { return left / IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) / right; }
template <unsigned int Modulus>
std::istream& operator<<(std::istream& ist, const IntMod<Modulus>& val) {
uint64_t tmp;
ist >> tmp;
val = tmp;
return ist;
}
template <unsigned int Modulus>
std::ostream& operator<<(std::ostream& ost, const IntMod<Modulus>& val) {
ost << val.Get_value();
return ost;
}
typedef IntMod<1000000007> MInt;
#if 1
MInt operator"" _m(unsigned long long num) { return MInt((uint64_t)num); }
#endif
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先
MInt operator"" _m(unsigned long long num) { return MInt(num); }
#endif
struct CompBySecond {
bool operator()(const PP& a, const PP& b) const {
return a.second < b.second || (a.second == b.second && a.first < b.first);
}
};
template<class T>
class Array {
T* ptr_m;
size_t size_m;
};
//#include "Union_Find.h"
int N, M;
string S;
vector<int> L, R;
int X[3000];
int W[3000];
int O[3000];
bool flg[3000];
MInt DP[3001][3001];
MInt C(int n, int r)
return MInt::Combi(n, r);
}
int main() {
cin >> N >> M >> S;
REP(i, 0, M) {
int l, r;
cin >> l >> r;
--l;
L.push_back(l);
R.push_back(r);
}
REP(i, 1, L.size()) {
if (R[i - 1] >= R[i]) {
L.erase(L.begin() + i);
R.erase(R.begin() + i);
--i;
}
}
REP(i, 1, L.size()) {
if (R[i - 1] < L[i]) {
L.insert(L.begin() + i, R[i - 1]);
R.insert(R.begin() + i, R[i - 1] + 1);
}
}
M = L.size();
REP(i, 0, M) {
X[i] = i == M - 1 ? R[M - 1] - L[M - 1] : L[i + 1] - L[i];
W[i] = R[i] - L[i];
O[i] = count(S.begin(), S.begin() + R[i], '1');
}
DP[0][count(S.begin(), S.begin() + L[0], '1')] = 1;
REP(i, 1, M + 1) {
REP(j, max(0, X[i - 1] + O[i - 1] - W[i - 1]), min(N, O[i - 1]) + 1) {
REP(k, 0, min(j, X[i - 1]) + 1) {
DP[i][j] += DP[i - 1][j - k] * C(X[i - 1], k);
}
}
}
cout << DP[M][O[M - 1]].Get_value() << endl;
return 0;
}
| a.cc:10:11: error: 'uint32_t' has not been declared
10 | template <uint32_t Modulus>
| ^~~~~~~~
a.cc:13:17: error: 'uint32_t' does not name a type
13 | typedef uint32_t UInt;
| ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
6 | #include <cassert>
+++ |+#include <cstdint>
7 | #include <iostream>
a.cc:15:17: error: 'uint64_t' does not name a type
15 | typedef uint64_t ULong;
| ^~~~~~~~
a.cc:15:17: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:19:21: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
19 | friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:21:21: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
21 | friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:23:21: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
23 | friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:25:21: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
25 | friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:27:21: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
27 | friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:29:21: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
29 | friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:32:9: error: 'UInt' does not name a type; did you mean 'Int'?
32 | UInt value_m;
| ^~~~
| Int
a.cc:36:20: error: expected ')' before 'value'
36 | IntMod(UInt value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:37:21: error: expected ')' before 'value'
37 | IntMod(ULong value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:96:20: error: 'UInt' has not been declared
96 | IntMod Pow(UInt exp) const {
| ^~~~
a.cc:106:9: error: 'UInt' does not name a type; did you mean 'Int'?
106 | UInt Get_value() const {
| ^~~~
| Int
a.cc:110:28: error: 'UInt' has not been declared
110 | static IntMod Fact(UInt num) {
| ^~~~
a.cc:122:29: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:122:37: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:139:17: error: 'int operator+(const int&, int)' must have an argument of class or enumerated type
139 | IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
| ^~~~~~~~
a.cc:146:17: error: 'int operator-(const int&, const int&)' must have an argument of class or enumerated type
146 | IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:153:17: error: 'int operator*(const int&, const int&)' must have an argument of class or enumerated type
153 | IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:160:17: error: 'int operator/(const int&, const int&)' must have an argument of class or enumerated type
160 | IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:168:6: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
168 | bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
| ^~~~~~~~
a.cc:170:6: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
170 | bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
| ^~~~~~~~
a.cc:173:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
173 | bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
| ^~~~~~~~
a.cc:175:6: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
175 | bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
| ^~~~~~~~
a.cc:177:6: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
177 | bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
| ^~~~~~~~
a.cc:179:6: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
179 | bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
| ^~~~~~~~
a.cc: In function 'std::istream& operator<<(std::istream&, const int&)':
a.cc:200:9: error: 'uint64_t' was not declared in this scope
200 | uint64_t tmp;
| ^~~~~~~~
a.cc:200:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:201:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
201 | ist >> tmp;
| ^~~
| tm
a.cc: In function 'std::ostream& operator<<(std::ostream&, const int&)':
a.cc:208:20: error: request for member 'Get_value' in 'val', which is of non-class type 'const int'
208 | ost << val.Get_value();
| ^~~~~~~~~
a.cc: In function 'MInt operator""_m(long long unsigned int)':
a.cc:215:59: error: 'uint64_t' was not declared in this scope
215 | MInt operator"" _m(unsigned long long num) { return MInt((uint64_t)num); }
| ^~~~~~~~
a.cc:215:59: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: At global scope:
a.cc:269:6: error: redefinition of 'MInt operator""_m(long long unsigned int)'
269 | MInt operator"" _m(unsigned long long num) { return MInt(num); }
| ^~~~~~~~
a.cc:215:6: note: 'MInt operator""_m(long long unsigned int)' previously defined here
215 | MInt operator"" _m(unsigned long long num) { return MInt((uint64_t)num); }
| ^~~~~~~~
a.cc: In function 'MInt C(int, int)':
a.cc:296:9: error: named return values are no longer supported
296 | return MInt::Combi(n, r);
| ^~~~~~
a.cc:338:33: error: request for member 'Get_value' in 'DP[M][O[(M - 1)]]', which is of non-class type 'MInt' {aka 'int'}
338 | cout << DP[M][O[M - 1]].Get_value() << endl;
| ^~~~~~~~~
|
s950033506 | p03859 | C++ | #ifndef __INTMOD_H__0001__
#define __INTMOD_H__0001__
#include <vector>
#include <iostream>
#include <cassert>
#include <iostream>
/* Modulus must be less than 0x80000000, and not be 0. */
template <uint32_t Modulus>
class IntMod {
typedef int32_t Int;
typedef uint32_t UInt;
typedef int64_t Long;
typedef uint64_t ULong;
public:
template <unsigned int Modulus_>
friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
private:
UInt value_m;
public:
IntMod() { value_m = 0; }
IntMod(UInt value) { value_m = value % Modulus; }
IntMod(ULong value) { value_m = value % Modulus; }
IntMod(Int value) {
Int tmp = value % (Int)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(Long value) {
Int tmp = value % (Long)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(const IntMod& other) : value_m(other.value_m) {}
IntMod& operator=(const IntMod& other) { value_m = other.value_m; return *this; }
const IntMod& operator+() const { return *this; }
IntMod operator-() const { return IntMod(Modulus - value_m); }
IntMod& operator++() {
++value_m;
if (value_m == Modulus) value_m = 0;
return *this;
}
IntMod& operator--() {
if (value_m == 0) value_m = Modulus;
--value_m;
return *this;
}
IntMod operator++(int dummy) {
IntMod tmp(*this);
++(*this);
return tmp;
}
IntMod operator--(int dummy) {
IntMod tmp(*this);
--(*this);
return tmp;
}
IntMod& operator+=(const IntMod& right) {
value_m += right.value_m; // value_m < 0x80000000
if (value_m >= Modulus) value_m -= Modulus;
return *this;
}
IntMod& operator-=(const IntMod& right) {
if (value_m < right.value_m) value_m += Modulus;
value_m -= right.value_m;
return *this;
}
IntMod& operator*=(const IntMod& right) {
value_m = ((ULong)value_m * right.value_m) % Modulus;
return *this;
}
IntMod& operator/=(const IntMod& right) {
(*this) *= (right.Inverse());
return *this;
}
// for power
IntMod operator[](unsigned int exp) const {
return Pow(exp);
}
/* Modulus must be a prime. */
IntMod Inverse() const { return (*this).Pow(Modulus - 2); }
IntMod Pow(UInt exp) const {
IntMod product = 1;
IntMod factor(*this);
while (exp > 0) {
if (exp & 1) product *= factor;
factor *= factor;
exp >>= 1;
}
return product;
}
UInt Get_value() const {
return value_m;
}
static IntMod Fact(UInt num) {
static std::vector<IntMod> table(1, 1);
if (table.size() > num) return table[num];
int old_size = table.size();
table.resize(num + 1);
for (int i = old_size; i <= num; i++) {
table[i] = table[i - 1] * i;
}
return table[num];
}
static IntMod Combi(UInt n, UInt r) {
if (n < r) throw "okashii";
return IntMod::Fact(n) / (IntMod::Fact(n - r) * IntMod::Fact(r));
}
static std::vector<IntMod> Inverse_list(int size) {
assert(size < Modulus);
std::vector<IntMod> ret_arr(size + 1);
ret_arr[1] = 1;
for (int i = 2; i <= size; ++i) {
ret_arr[i] = ((ULong)(Modulus - Modulus / i) * ret_arr[Modulus % i].Get_value()) % Modulus;
}
return ret_arr;
}
};
template <unsigned int Modulus>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
IntMod<Modulus> ret(left);
ret += right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret -= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret *= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret /= right;
return ret;
}
template <unsigned int Modulus>
bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
template <unsigned int Modulus>
bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
/* for set/map */
template <unsigned int Modulus>
bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
template <unsigned int Modulus>
bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
template <unsigned int Modulus>
bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
template <unsigned int Modulus>
bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, Integer right) { return left + IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) + right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, Integer right) { return left - IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) - right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, Integer right) { return left * IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) * right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, Integer right) { return left / IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) / right; }
template <unsigned int Modulus>
std::istream& operator<<(std::istream& ist, const IntMod<Modulus>& val) {
uint64_t tmp;
ist >> tmp;
val = tmp;
return ist;
}
template <unsigned int Modulus>
std::ostream& operator<<(std::ostream& ost, const IntMod<Modulus>& val) {
ost << val.Get_value();
return ost;
}
typedef IntMod<1000000007> MInt;
#if 1
MInt operator"" _m(unsigned long long num) { return MInt(num); }
#endif
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先
MInt operator"" _m(unsigned long long num) { return MInt(num); }
#endif
struct CompBySecond {
bool operator()(const PP& a, const PP& b) const {
return a.second < b.second || (a.second == b.second && a.first < b.first);
}
};
template<class T>
class Array {
T* ptr_m;
size_t size_m;
};
//#include "Union_Find.h"
int N, M;
string S;
vector<int> L, R;
int X[3000];
int W[3000];
int O[3000];
bool flg[3000];
MInt DP[3001][3001];
MInt C(int n, int r)
return MInt::Combi(n, r);
}
int main() {
cin >> N >> M >> S;
REP(i, 0, M) {
int l, r;
cin >> l >> r;
--l;
L.push_back(l);
R.push_back(r);
}
REP(i, 1, L.size()) {
if (R[i - 1] >= R[i]) {
L.erase(L.begin() + i);
R.erase(R.begin() + i);
--i;
}
}
REP(i, 1, L.size()) {
if (R[i - 1] < L[i]) {
L.insert(L.begin() + i, R[i - 1]);
R.insert(R.begin() + i, R[i - 1] + 1);
}
}
M = L.size();
REP(i, 0, M) {
X[i] = i == M - 1 ? R[M - 1] - L[M - 1] : L[i + 1] - L[i];
W[i] = R[i] - L[i];
O[i] = count(S.begin(), S.begin() + R[i], '1');
}
DP[0][count(S.begin(), S.begin() + L[0], '1')] = 1;
REP(i, 1, M + 1) {
REP(j, max(0, X[i - 1] + O[i - 1] - W[i - 1]), min(N, O[i - 1]) + 1) {
REP(k, 0, min(j, X[i - 1]) + 1) {
DP[i][j] += DP[i - 1][j - k] * C(X[i - 1], k);
}
}
}
cout << DP[M][O[M - 1]].Get_value() << endl;
return 0;
}
| a.cc:10:11: error: 'uint32_t' has not been declared
10 | template <uint32_t Modulus>
| ^~~~~~~~
a.cc:13:17: error: 'uint32_t' does not name a type
13 | typedef uint32_t UInt;
| ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
6 | #include <cassert>
+++ |+#include <cstdint>
7 | #include <iostream>
a.cc:15:17: error: 'uint64_t' does not name a type
15 | typedef uint64_t ULong;
| ^~~~~~~~
a.cc:15:17: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:19:21: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
19 | friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:21:21: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
21 | friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:23:21: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
23 | friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:25:21: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
25 | friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:27:21: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
27 | friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:29:21: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
29 | friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:32:9: error: 'UInt' does not name a type; did you mean 'Int'?
32 | UInt value_m;
| ^~~~
| Int
a.cc:36:20: error: expected ')' before 'value'
36 | IntMod(UInt value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:37:21: error: expected ')' before 'value'
37 | IntMod(ULong value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:96:20: error: 'UInt' has not been declared
96 | IntMod Pow(UInt exp) const {
| ^~~~
a.cc:106:9: error: 'UInt' does not name a type; did you mean 'Int'?
106 | UInt Get_value() const {
| ^~~~
| Int
a.cc:110:28: error: 'UInt' has not been declared
110 | static IntMod Fact(UInt num) {
| ^~~~
a.cc:122:29: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:122:37: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:139:17: error: 'int operator+(const int&, int)' must have an argument of class or enumerated type
139 | IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
| ^~~~~~~~
a.cc:146:17: error: 'int operator-(const int&, const int&)' must have an argument of class or enumerated type
146 | IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:153:17: error: 'int operator*(const int&, const int&)' must have an argument of class or enumerated type
153 | IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:160:17: error: 'int operator/(const int&, const int&)' must have an argument of class or enumerated type
160 | IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:168:6: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
168 | bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
| ^~~~~~~~
a.cc:170:6: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
170 | bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
| ^~~~~~~~
a.cc:173:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
173 | bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
| ^~~~~~~~
a.cc:175:6: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
175 | bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
| ^~~~~~~~
a.cc:177:6: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
177 | bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
| ^~~~~~~~
a.cc:179:6: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
179 | bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
| ^~~~~~~~
a.cc: In function 'std::istream& operator<<(std::istream&, const int&)':
a.cc:200:9: error: 'uint64_t' was not declared in this scope
200 | uint64_t tmp;
| ^~~~~~~~
a.cc:200:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:201:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
201 | ist >> tmp;
| ^~~
| tm
a.cc: In function 'std::ostream& operator<<(std::ostream&, const int&)':
a.cc:208:20: error: request for member 'Get_value' in 'val', which is of non-class type 'const int'
208 | ost << val.Get_value();
| ^~~~~~~~~
a.cc: At global scope:
a.cc:269:6: error: redefinition of 'MInt operator""_m(long long unsigned int)'
269 | MInt operator"" _m(unsigned long long num) { return MInt(num); }
| ^~~~~~~~
a.cc:215:6: note: 'MInt operator""_m(long long unsigned int)' previously defined here
215 | MInt operator"" _m(unsigned long long num) { return MInt(num); }
| ^~~~~~~~
a.cc: In function 'MInt C(int, int)':
a.cc:296:9: error: named return values are no longer supported
296 | return MInt::Combi(n, r);
| ^~~~~~
a.cc:338:33: error: request for member 'Get_value' in 'DP[M][O[(M - 1)]]', which is of non-class type 'MInt' {aka 'int'}
338 | cout << DP[M][O[M - 1]].Get_value() << endl;
| ^~~~~~~~~
|
s688622827 | p03859 | C++ | #ifndef __INTMOD_H__0001__
#define __INTMOD_H__0001__
#include <vector>
#include <iostream>
#include <cassert>
#include <iostream>
/* Modulus must be less than 0x80000000, and not be 0. */
template <uint32_t Modulus>
class IntMod {
typedef int32_t Int;
typedef uint32_t UInt;
typedef int64_t Long;
typedef uint64_t ULong;
public:
template <unsigned int Modulus_>
friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
private:
UInt value_m;
public:
IntMod() { value_m = 0; }
IntMod(UInt value) { value_m = value % Modulus; }
IntMod(ULong value) { value_m = value % Modulus; }
IntMod(Int value) {
Int tmp = value % (Int)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(Long value) {
Int tmp = value % (Long)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(const IntMod& other) : value_m(other.value_m) {}
IntMod& operator=(const IntMod& other) { value_m = other.value_m; return *this; }
const IntMod& operator+() const { return *this; }
IntMod operator-() const { return IntMod(Modulus - value_m); }
IntMod& operator++() {
++value_m;
if (value_m == Modulus) value_m = 0;
return *this;
}
IntMod& operator--() {
if (value_m == 0) value_m = Modulus;
--value_m;
return *this;
}
IntMod operator++(int dummy) {
IntMod tmp(*this);
++(*this);
return tmp;
}
IntMod operator--(int dummy) {
IntMod tmp(*this);
--(*this);
return tmp;
}
IntMod& operator+=(const IntMod& right) {
value_m += right.value_m; // value_m < 0x80000000
if (value_m >= Modulus) value_m -= Modulus;
return *this;
}
IntMod& operator-=(const IntMod& right) {
if (value_m < right.value_m) value_m += Modulus;
value_m -= right.value_m;
return *this;
}
IntMod& operator*=(const IntMod& right) {
value_m = ((ULong)value_m * right.value_m) % Modulus;
return *this;
}
IntMod& operator/=(const IntMod& right) {
(*this) *= (right.Inverse());
return *this;
}
// for power
IntMod operator[](unsigned int exp) const {
return Pow(exp);
}
/* Modulus must be a prime. */
IntMod Inverse() const { return (*this).Pow(Modulus - 2); }
IntMod Pow(UInt exp) const {
IntMod product = 1;
IntMod factor(*this);
while (exp > 0) {
if (exp & 1) product *= factor;
factor *= factor;
exp >>= 1;
}
return product;
}
UInt Get_value() const {
return value_m;
}
static IntMod Fact(UInt num) {
static std::vector<IntMod> table(1, 1);
if (table.size() > num) return table[num];
int old_size = table.size();
table.resize(num + 1);
for (int i = old_size; i <= num; i++) {
table[i] = table[i - 1] * i;
}
return table[num];
}
static IntMod Combi(UInt n, UInt r) {
if (n < r) throw "okashii";
return IntMod::Fact(n) / (IntMod::Fact(n - r) * IntMod::Fact(r));
}
static std::vector<IntMod> Inverse_list(int size) {
assert(size < Modulus);
std::vector<IntMod> ret_arr(size + 1);
ret_arr[1] = 1;
for (int i = 2; i <= size; ++i) {
ret_arr[i] = ((ULong)(Modulus - Modulus / i) * ret_arr[Modulus % i].Get_value()) % Modulus;
}
return ret_arr;
}
};
template <unsigned int Modulus>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
IntMod<Modulus> ret(left);
ret += right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret -= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret *= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret /= right;
return ret;
}
template <unsigned int Modulus>
bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
template <unsigned int Modulus>
bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
/* for set/map */
template <unsigned int Modulus>
bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
template <unsigned int Modulus>
bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
template <unsigned int Modulus>
bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
template <unsigned int Modulus>
bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, Integer right) { return left + IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) + right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, Integer right) { return left - IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) - right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, Integer right) { return left * IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) * right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, Integer right) { return left / IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) / right; }
template <unsigned int Modulus>
std::istream& operator<<(std::istream& ist, const IntMod<Modulus>& val) {
uint64_t tmp;
ist >> tmp;
val = tmp;
return ist;
}
template <unsigned int Modulus>
std::ostream& operator<<(std::ostream& ost, const IntMod<Modulus>& val) {
ost << val.Get_value();
return ost;
}
typedef IntMod<1000000007> MInt;
#if 1
MInt operator"" _m(uint64_t num) { return MInt(num); }
#endif
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先
MInt operator"" _m(unsigned long long num) { return MInt(num); }
#endif
struct CompBySecond {
bool operator()(const PP& a, const PP& b) const {
return a.second < b.second || (a.second == b.second && a.first < b.first);
}
};
template<class T>
class Array {
T* ptr_m;
size_t size_m;
};
//#include "Union_Find.h"
int N, M;
string S;
vector<int> L, R;
int X[3000];
int W[3000];
int O[3000];
bool flg[3000];
MInt DP[3001][3001];
MInt C(int n, int r)
return MInt::Combi(n, r);
}
int main() {
cin >> N >> M >> S;
REP(i, 0, M) {
int l, r;
cin >> l >> r;
--l;
L.push_back(l);
R.push_back(r);
}
REP(i, 1, L.size()) {
if (R[i - 1] >= R[i]) {
L.erase(L.begin() + i);
R.erase(R.begin() + i);
--i;
}
}
REP(i, 1, L.size()) {
if (R[i - 1] < L[i]) {
L.insert(L.begin() + i, R[i - 1]);
R.insert(R.begin() + i, R[i - 1] + 1);
}
}
M = L.size();
REP(i, 0, M) {
X[i] = i == M - 1 ? R[M - 1] - L[M - 1] : L[i + 1] - L[i];
W[i] = R[i] - L[i];
O[i] = count(S.begin(), S.begin() + R[i], '1');
}
DP[0][count(S.begin(), S.begin() + L[0], '1')] = 1;
REP(i, 1, M + 1) {
REP(j, max(0, X[i - 1] + O[i - 1] - W[i - 1]), min(N, O[i - 1]) + 1) {
REP(k, 0, min(j, X[i - 1]) + 1) {
DP[i][j] += DP[i - 1][j - k] * C(X[i - 1], k);
}
}
}
cout << DP[M][O[M - 1]].Get_value() << endl;
return 0;
}
| a.cc:10:11: error: 'uint32_t' has not been declared
10 | template <uint32_t Modulus>
| ^~~~~~~~
a.cc:13:17: error: 'uint32_t' does not name a type
13 | typedef uint32_t UInt;
| ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
6 | #include <cassert>
+++ |+#include <cstdint>
7 | #include <iostream>
a.cc:15:17: error: 'uint64_t' does not name a type
15 | typedef uint64_t ULong;
| ^~~~~~~~
a.cc:15:17: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:19:21: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
19 | friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:21:21: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
21 | friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:23:21: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
23 | friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:25:21: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
25 | friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:27:21: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
27 | friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:29:21: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
29 | friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:32:9: error: 'UInt' does not name a type; did you mean 'Int'?
32 | UInt value_m;
| ^~~~
| Int
a.cc:36:20: error: expected ')' before 'value'
36 | IntMod(UInt value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:37:21: error: expected ')' before 'value'
37 | IntMod(ULong value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:96:20: error: 'UInt' has not been declared
96 | IntMod Pow(UInt exp) const {
| ^~~~
a.cc:106:9: error: 'UInt' does not name a type; did you mean 'Int'?
106 | UInt Get_value() const {
| ^~~~
| Int
a.cc:110:28: error: 'UInt' has not been declared
110 | static IntMod Fact(UInt num) {
| ^~~~
a.cc:122:29: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:122:37: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:139:17: error: 'int operator+(const int&, int)' must have an argument of class or enumerated type
139 | IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
| ^~~~~~~~
a.cc:146:17: error: 'int operator-(const int&, const int&)' must have an argument of class or enumerated type
146 | IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:153:17: error: 'int operator*(const int&, const int&)' must have an argument of class or enumerated type
153 | IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:160:17: error: 'int operator/(const int&, const int&)' must have an argument of class or enumerated type
160 | IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:168:6: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
168 | bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
| ^~~~~~~~
a.cc:170:6: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
170 | bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
| ^~~~~~~~
a.cc:173:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
173 | bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
| ^~~~~~~~
a.cc:175:6: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
175 | bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
| ^~~~~~~~
a.cc:177:6: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
177 | bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
| ^~~~~~~~
a.cc:179:6: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
179 | bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
| ^~~~~~~~
a.cc: In function 'std::istream& operator<<(std::istream&, const int&)':
a.cc:200:9: error: 'uint64_t' was not declared in this scope
200 | uint64_t tmp;
| ^~~~~~~~
a.cc:200:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:201:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
201 | ist >> tmp;
| ^~~
| tm
a.cc: In function 'std::ostream& operator<<(std::ostream&, const int&)':
a.cc:208:20: error: request for member 'Get_value' in 'val', which is of non-class type 'const int'
208 | ost << val.Get_value();
| ^~~~~~~~~
a.cc: At global scope:
a.cc:215:6: error: declaration of 'operator""_m' as non-function
215 | MInt operator"" _m(uint64_t num) { return MInt(num); }
| ^~~~~~~~
a.cc:215:20: error: 'uint64_t' was not declared in this scope
215 | MInt operator"" _m(uint64_t num) { return MInt(num); }
| ^~~~~~~~
a.cc:215:20: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'MInt C(int, int)':
a.cc:296:9: error: named return values are no longer supported
296 | return MInt::Combi(n, r);
| ^~~~~~
a.cc:338:33: error: request for member 'Get_value' in 'DP[M][O[(M - 1)]]', which is of non-class type 'MInt' {aka 'int'}
338 | cout << DP[M][O[M - 1]].Get_value() << endl;
| ^~~~~~~~~
|
s240138221 | p03859 | C++ | #ifndef __INTMOD_H__0001__
#define __INTMOD_H__0001__
#include <vector>
#include <iostream>
#include <cassert>
#include <iostream>
/* Modulus must be less than 0x80000000, and not be 0. */
template <uint32_t Modulus>
class IntMod {
typedef int32_t Int;
typedef uint32_t UInt;
typedef int64_t Long;
typedef uint64_t ULong;
public:
template <unsigned int Modulus_>
friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
template <unsigned int Modulus_>
friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
private:
UInt value_m;
public:
IntMod() { value_m = 0; }
IntMod(UInt value) { value_m = value % Modulus; }
IntMod(ULong value) { value_m = value % Modulus; }
IntMod(Int value) {
Int tmp = value % (Int)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(Long value) {
Int tmp = value % (Long)Modulus;
value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp);
}
IntMod(const IntMod& other) : value_m(other.value_m) {}
IntMod& operator=(const IntMod& other) { value_m = other.value_m; return *this; }
const IntMod& operator+() const { return *this; }
IntMod operator-() const { return IntMod(Modulus - value_m); }
IntMod& operator++() {
++value_m;
if (value_m == Modulus) value_m = 0;
return *this;
}
IntMod& operator--() {
if (value_m == 0) value_m = Modulus;
--value_m;
return *this;
}
IntMod operator++(int dummy) {
IntMod tmp(*this);
++(*this);
return tmp;
}
IntMod operator--(int dummy) {
IntMod tmp(*this);
--(*this);
return tmp;
}
IntMod& operator+=(const IntMod& right) {
value_m += right.value_m; // value_m < 0x80000000
if (value_m >= Modulus) value_m -= Modulus;
return *this;
}
IntMod& operator-=(const IntMod& right) {
if (value_m < right.value_m) value_m += Modulus;
value_m -= right.value_m;
return *this;
}
IntMod& operator*=(const IntMod& right) {
value_m = ((ULong)value_m * right.value_m) % Modulus;
return *this;
}
IntMod& operator/=(const IntMod& right) {
(*this) *= (right.Inverse());
return *this;
}
// for power
IntMod operator[](unsigned int exp) const {
return Pow(exp);
}
/* Modulus must be a prime. */
IntMod Inverse() const { return (*this).Pow(Modulus - 2); }
IntMod Pow(UInt exp) const {
IntMod product = 1;
IntMod factor(*this);
while (exp > 0) {
if (exp & 1) product *= factor;
factor *= factor;
exp >>= 1;
}
return product;
}
UInt Get_value() const {
return value_m;
}
static IntMod Fact(UInt num) {
static std::vector<IntMod> table(1, 1);
if (table.size() > num) return table[num];
int old_size = table.size();
table.resize(num + 1);
for (int i = old_size; i <= num; i++) {
table[i] = table[i - 1] * i;
}
return table[num];
}
static IntMod Combi(UInt n, UInt r) {
if (n < r) throw "okashii";
return IntMod::Fact(n) / (IntMod::Fact(n - r) * IntMod::Fact(r));
}
static std::vector<IntMod> Inverse_list(int size) {
assert(size < Modulus);
std::vector<IntMod> ret_arr(size + 1);
ret_arr[1] = 1;
for (int i = 2; i <= size; ++i) {
ret_arr[i] = ((ULL)(Modulus - Modulus / i) * ret_arr[Modulus % i].Get_value()) % Modulus;
}
return ret_arr;
}
};
template <unsigned int Modulus>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
IntMod<Modulus> ret(left);
ret += right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret -= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret *= right;
return ret;
}
template <unsigned int Modulus>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
IntMod<Modulus> ret(left);
ret /= right;
return ret;
}
template <unsigned int Modulus>
bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
template <unsigned int Modulus>
bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
/* for set/map */
template <unsigned int Modulus>
bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
template <unsigned int Modulus>
bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
template <unsigned int Modulus>
bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
template <unsigned int Modulus>
bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(const IntMod<Modulus>& left, Integer right) { return left + IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator+(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) + right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(const IntMod<Modulus>& left, Integer right) { return left - IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator-(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) - right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(const IntMod<Modulus>& left, Integer right) { return left * IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator*(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) * right; }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(const IntMod<Modulus>& left, Integer right) { return left / IntMod<Modulus>(right); }
template <unsigned int Modulus, class Integer>
IntMod<Modulus> operator/(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) / right; }
template <unsigned int Modulus>
std::istream& operator<<(std::istream& ist, const IntMod<Modulus>& val) {
uint64_t tmp;
ist >> tmp;
val = tmp;
return ist;
}
template <unsigned int Modulus>
std::ostream& operator<<(std::ostream& ost, const IntMod<Modulus>& val) {
ost << val.Get_value();
return ost;
}
typedef IntMod<1000000007> MInt;
#if 1
MInt operator"" _m(unsigned long long num) { return MInt(num); }
#endif
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先
MInt operator"" _m(unsigned long long num) { return MInt(num); }
#endif
struct CompBySecond {
bool operator()(const PP& a, const PP& b) const {
return a.second < b.second || (a.second == b.second && a.first < b.first);
}
};
template<class T>
class Array {
T* ptr_m;
size_t size_m;
};
//#include "Union_Find.h"
int N, M;
string S;
vector<int> L, R;
int X[3000];
int W[3000];
int O[3000];
bool flg[3000];
MInt DP[3001][3001];
MInt C(int n, int r)
return MInt::Combi(n, r);
}
int main() {
cin >> N >> M >> S;
REP(i, 0, M) {
int l, r;
cin >> l >> r;
--l;
L.push_back(l);
R.push_back(r);
}
REP(i, 1, L.size()) {
if (R[i - 1] >= R[i]) {
L.erase(L.begin() + i);
R.erase(R.begin() + i);
--i;
}
}
REP(i, 1, L.size()) {
if (R[i - 1] < L[i]) {
L.insert(L.begin() + i, R[i - 1]);
R.insert(R.begin() + i, R[i - 1] + 1);
}
}
M = L.size();
REP(i, 0, M) {
X[i] = i == M - 1 ? R[M - 1] - L[M - 1] : L[i + 1] - L[i];
W[i] = R[i] - L[i];
O[i] = count(S.begin(), S.begin() + R[i], '1');
}
DP[0][count(S.begin(), S.begin() + L[0], '1')] = 1;
REP(i, 1, M + 1) {
REP(j, max(0, X[i - 1] + O[i - 1] - W[i - 1]), min(N, O[i - 1]) + 1) {
REP(k, 0, min(j, X[i - 1]) + 1) {
DP[i][j] += DP[i - 1][j - k] * C(X[i - 1], k);
}
}
}
cout << DP[M][O[M - 1]].Get_value() << endl;
return 0;
}
| a.cc:10:11: error: 'uint32_t' has not been declared
10 | template <uint32_t Modulus>
| ^~~~~~~~
a.cc:13:17: error: 'uint32_t' does not name a type
13 | typedef uint32_t UInt;
| ^~~~~~~~
a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
6 | #include <cassert>
+++ |+#include <cstdint>
7 | #include <iostream>
a.cc:15:17: error: 'uint64_t' does not name a type
15 | typedef uint64_t ULong;
| ^~~~~~~~
a.cc:15:17: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:19:21: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
19 | friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:21:21: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
21 | friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:23:21: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
23 | friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:25:21: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
25 | friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:27:21: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
27 | friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:29:21: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
29 | friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right);
| ^~~~~~~~
a.cc:32:9: error: 'UInt' does not name a type; did you mean 'Int'?
32 | UInt value_m;
| ^~~~
| Int
a.cc:36:20: error: expected ')' before 'value'
36 | IntMod(UInt value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:37:21: error: expected ')' before 'value'
37 | IntMod(ULong value) { value_m = value % Modulus; }
| ~ ^~~~~~
| )
a.cc:96:20: error: 'UInt' has not been declared
96 | IntMod Pow(UInt exp) const {
| ^~~~
a.cc:106:9: error: 'UInt' does not name a type; did you mean 'Int'?
106 | UInt Get_value() const {
| ^~~~
| Int
a.cc:110:28: error: 'UInt' has not been declared
110 | static IntMod Fact(UInt num) {
| ^~~~
a.cc:122:29: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:122:37: error: 'UInt' has not been declared
122 | static IntMod Combi(UInt n, UInt r) {
| ^~~~
a.cc:139:17: error: 'int operator+(const int&, int)' must have an argument of class or enumerated type
139 | IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) {
| ^~~~~~~~
a.cc:146:17: error: 'int operator-(const int&, const int&)' must have an argument of class or enumerated type
146 | IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:153:17: error: 'int operator*(const int&, const int&)' must have an argument of class or enumerated type
153 | IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:160:17: error: 'int operator/(const int&, const int&)' must have an argument of class or enumerated type
160 | IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) {
| ^~~~~~~~
a.cc:168:6: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
168 | bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; }
| ^~~~~~~~
a.cc:170:6: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type
170 | bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; }
| ^~~~~~~~
a.cc:173:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type
173 | bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; }
| ^~~~~~~~
a.cc:175:6: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type
175 | bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; }
| ^~~~~~~~
a.cc:177:6: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type
177 | bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; }
| ^~~~~~~~
a.cc:179:6: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type
179 | bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; }
| ^~~~~~~~
a.cc: In function 'std::istream& operator<<(std::istream&, const int&)':
a.cc:200:9: error: 'uint64_t' was not declared in this scope
200 | uint64_t tmp;
| ^~~~~~~~
a.cc:200:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:201:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
201 | ist >> tmp;
| ^~~
| tm
a.cc: In function 'std::ostream& operator<<(std::ostream&, const int&)':
a.cc:208:20: error: request for member 'Get_value' in 'val', which is of non-class type 'const int'
208 | ost << val.Get_value();
| ^~~~~~~~~
a.cc: At global scope:
a.cc:269:6: error: redefinition of 'MInt operator""_m(long long unsigned int)'
269 | MInt operator"" _m(unsigned long long num) { return MInt(num); }
| ^~~~~~~~
a.cc:215:6: note: 'MInt operator""_m(long long unsigned int)' previously defined here
215 | MInt operator"" _m(unsigned long long num) { return MInt(num); }
| ^~~~~~~~
a.cc: In function 'MInt C(int, int)':
a.cc:296:9: error: named return values are no longer supported
296 | return MInt::Combi(n, r);
| ^~~~~~
a.cc:338:33: error: request for member 'Get_value' in 'DP[M][O[(M - 1)]]', which is of non-class type 'MInt' {aka 'int'}
338 | cout << DP[M][O[M - 1]].Get_value() << endl;
| ^~~~~~~~~
|
s994703329 | p03859 | C | #include<bits/stdc++.h>
#define N 3005
using namespace std;
const int mod=1e9+7;
int n,m;
int s[N],val[N],dp[2][N];
int main(){
scanf("%d%d",&n,&m);
char t[2];gets(t);
for(int i=1;i<=n;i++) s[i]=getchar()-'0'+s[i-1];
int cnt=0;
for(int i=1,ml,mr;i<=m;i++)
scanf("%d%d",&ml,&mr),val[ml]=max(val[ml],mr);
for(int i=1;i<=n;i++) val[i]=max(max(i,val[i]),val[i-1]);
int now=0;
dp[now][0]=1;
for(int i=1;i<=n;i++,now^=1){
memset(dp[now^1],0,sizeof(dp[0]));
for(int j=s[val[i]]-(val[i]-i);j<=s[val[i]];j++)
dp[now^1][j]=(dp[now][j]+ (j==0?0:dp[now][j-1]) )%mod;
}
cout<<dp[now][s[n]]<<endl;
return 0;
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s391232863 | p03859 | C++ | #include<bits/stdc++.h>
#define N 3005
using namespace std;
const int mod=1e9+7;
int n,m;
int s[N],val[N],dp[2][N];
int main(){
scanf("%d%d",&n,&m);
char t[2];gets(t);
for(int i=1;i<=n;i++) s[i]=getchar()-'0'+s[i-1];
int cnt=0;
for(int i=1,ml,mr;i<=m;i++)
scanf("%d%d",&ml,&mr),val[ml]=max(val[ml],mr);
for(int i=1;i<=n;i++) val[i]=max(max(i,val[i]),val[i-1]);
int now=0;
dp[now][0]=1;
for(int i=1;i<=n;i++,now^=1){
memset(dp[now^1],0,sizeof(dp[0]));
for(int j=s[val[i]]-(val[i]-i);j<=s[val[i]];j++)
dp[now^1][j]=(dp[now][j]+ (j==0?0:dp[now][j-1]) )%mod;
}
cout<<dp[now][s[n]]<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:19: error: 'gets' was not declared in this scope; did you mean 'getw'?
9 | char t[2];gets(t);
| ^~~~
| getw
|
s543406000 | p03859 | C++ | //#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
ifstream cin ("x.in"); ofstream cout ("x.out");
const int nmax = 3000;
const int mod = 1e9 + 7;
int n, m;
int s[nmax + 1];
int d[nmax + 1][nmax + 1];
pair<int, int> w[nmax + 1];
vector< pair<int, int> > unu;
string vs;
int v[nmax + 1];
inline bool cmpdr (int x) {
return x == 0;
}
inline bool cmpst (int x) {
return x > 0;
}
void precalc() {
unu.push_back(make_pair(0, 0));
for (int i = 0; i < n; ++ i) {
if (vs[ i ] == '1') {
v[i + 1] = unu.size();
unu.push_back(make_pair(0, 0));
}
}
for (int i = 1; i <= m; ++ i) {
stable_partition(v + w[ i ].first, v + w[ i ].second + 1, cmpdr);
}
for (int i = 1; i <= n; ++ i) {
if (v[ i ]) {
unu[ v[ i ] ].second = i;
}
}
int shp = 0;
for (int i = 0; i < n; ++ i) {
if (vs[ i ] == '1') {
v[i + 1] = ++ shp;
} else {
v[i + 1] = 0;
}
}
for (int i = 1; i <= m; ++ i) {
stable_partition(v + w[ i ].first, v + w[ i ].second + 1, cmpst);
}
for (int i = 1; i <= n; ++ i) {
if (v[ i ]) {
unu[ v[ i ] ].first = i;
}
}
}
int main() {
cin >> n >> m >> vs;
for (int i = 1; i <= m; ++ i) {
int x, y;
cin >> x >> y;
w[ i ] = make_pair(x, y);
}
precalc();
d[ 0 ][ 0 ] = 1;
for (int i = 0; i <= n; ++ i) s[ i ] = 1;
for (int i = 1; i < (int)unu.size(); ++ i) {
for (int j = unu[ i ].first; j <= unu[ i ].second; ++ j) {
d[ i ][ j ] = s[j - 1];
}
s[ 0 ] = 0;
for (int j = 1; j <= n; ++ j) {
s[ j ] = s[j - 1] + d[ i ][ j ];
if (s[ j ] >= mod) {
s[ j ] -= mod;
}
}
}
cout << s[ n ] << "\n";
return 0;
}
| a.cc:9:14: error: variable 'std::ifstream cin' has initializer but incomplete type
9 | ifstream cin ("x.in"); ofstream cout ("x.out");
| ^
a.cc:6:1: note: 'std::ifstream' is defined in header '<fstream>'; this is probably fixable by adding '#include <fstream>'
5 | #include <algorithm>
+++ |+#include <fstream>
6 |
a.cc:9:38: error: variable 'std::ofstream cout' has initializer but incomplete type
9 | ifstream cin ("x.in"); ofstream cout ("x.out");
| ^
a.cc:9:38: note: 'std::ofstream' is defined in header '<fstream>'; this is probably fixable by adding '#include <fstream>'
a.cc: In function 'int main()':
a.cc:72:5: error: reference to 'cin' is ambiguous
72 | cin >> n >> m >> vs;
| ^~~
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: candidates are: 'std::istream std::cin'
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:9:10: note: '<typeprefixerror>cin'
9 | ifstream cin ("x.in"); ofstream cout ("x.out");
| ^~~
a.cc:76:9: error: reference to 'cin' is ambiguous
76 | cin >> x >> y;
| ^~~
/usr/include/c++/14/iostream:62:18: note: candidates are: 'std::istream std::cin'
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:9:10: note: '<typeprefixerror>cin'
9 | ifstream cin ("x.in"); ofstream cout ("x.out");
| ^~~
a.cc:99:5: error: reference to 'cout' is ambiguous
99 | cout << s[ n ] << "\n";
| ^~~~
/usr/include/c++/14/iostream:63:18: note: candidates are: 'std::ostream std::cout'
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:9:33: note: '<typeprefixerror>cout'
9 | ifstream cin ("x.in"); ofstream cout ("x.out");
| ^~~~
|
s601312976 | p03859 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long lli;
lli n,m;
string s;
vector<lli> sum;
vector<lli> rightend;
vector<vector<lli> > dp;
int main(){
cin >> n >> m;
cin >> s;
sum = vector<lli> (n+1);
rightend = vector<lli> (n+1);
for(lli i = 1;i <= n;i++){
rightend[i] = i;
}
for(lli i = 0;i < n;i++){
sum[i+1] = sum[i] + (s[i] - '0');
}
for(lli i = 0;i < m;i++){
lli l,r;
cin >> l >> r;
for(lli j = l,j <= r;j++) rightend[j] = max(rightend[j],r);
}
dp = vector<vector<lli> > (n+1,vector<lli> (n+1));
dp[0][0] = 1;
for(lli i = 0;i < n;i++){
lli b,e;
b = max(0ll,i - (rightend[i] - sum[rightend[i]]));
e = min(i,sum[rightend[i]]);
for(lli j = b;j <= e;j++){
dp[i+1][j] += dp[i][j];dp[i+1][j] %= 1000000007;
dp[i+1][j+1] += dp[i][j];dp[i+1][j] %= 1000000007;
}
}
cout < dp[n][sum[n]] << endl;
}
| a.cc: In function 'int main()':
a.cc:23:24: error: expected ';' before '<=' token
23 | for(lli j = l,j <= r;j++) rightend[j] = max(rightend[j],r);
| ^~~
| ;
a.cc:23:25: error: expected primary-expression before '<=' token
23 | for(lli j = l,j <= r;j++) rightend[j] = max(rightend[j],r);
| ^~
a.cc:36:26: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator<<'
36 | cout < dp[n][sum[n]] << endl;
|
s580471647 | p03859 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long lli;
lli n,m;
string s;
vector<lli> sum;
vector<lli> rightend;
vector<vector<lli> > dp;
int main(){
cin >> n >> m;
cin >> s;
sum = vector<lli> (n+1);
rightend = vector<lli> (n+1);
for(lli i = 1;i <= n;i++){
rightend[i] = i;
}
for(lli i = 0;i < n;i++){
sum[i+1] = sum[i] + (s[i] - '0');
}
for(lli i = 0;i < m;i++){
lli l,r;
cin >> l >> r;
for(lli j = l,j <= r;j++) rightend[j] = max(rightend[j],r);
}
dp = vector<vector<lli> > (n+1,vector<lli> (n+1));
dp[0][0] = 1;
for(lli i = 0;i < n;i++){
lli b,e;
b = max(0,i - (rightend[i] - sum[rightend[i]]));
e = min(i,sum[rightend[i]]);
for(lli j = b;j <= e;j++){
dp[i+1][j] += dp[i][j];dp[i+1][j] %= 1000000007;
dp[i+1][j+1] += dp[i][j];dp[i+1][j] %= 1000000007;
}
}
cout < dp[n][sum[n]] << endl;
}
| a.cc: In function 'int main()':
a.cc:23:24: error: expected ';' before '<=' token
23 | for(lli j = l,j <= r;j++) rightend[j] = max(rightend[j],r);
| ^~~
| ;
a.cc:23:25: error: expected primary-expression before '<=' token
23 | for(lli j = l,j <= r;j++) rightend[j] = max(rightend[j],r);
| ^~
a.cc:29:16: error: no matching function for call to 'max(int, lli)'
29 | b = max(0,i - (rightend[i] - sum[rightend[i]]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: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:29:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'lli' {aka 'long long int'})
29 | b = max(0,i - (rightend[i] - sum[rightend[i]]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:29:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
29 | b = max(0,i - (rightend[i] - sum[rightend[i]]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:36:26: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator<<'
36 | cout < dp[n][sum[n]] << endl;
|
s365170860 | p03859 | C++ | #include <iostream>
#include <string>
#include <set>
using namespace std;
const long long MOD=1000000007;
void op(set<string> &sSet,int l,int r)
{
l--;
r--;
int strLen=r-l+1;
set<string> tmpSet;
set<string>::iterator sit;
for (sit=sSet.begin();sit!=sSet.end();sit++){
char *S=(char*)(*sit).c_str();
int n=0;
while (n<strLen){
char ch=*(S+l);
memcpy(S+l,S+l+1,strLen);
*(S+r)=ch;
tmpSet.insert(S);
n++;
}
}
sSet.insert(tmpSet.begin(),tmpSet.end());
tmpSet.clear();
return;
}
int main(int argc, char* argv[])
{
int N,M;
cin>>N>>M;
string S;
cin>>S;
set<string> sSet;
sSet.insert(S);
int i;
int l,r;
long long aw=0;
for (i=0;i<M;i++){
cin>>l>>r;
op(sSet,l,r);
}
cout<<sSet.size()%MOD<<endl;
return 0;
} | a.cc: In function 'void op(std::set<std::__cxx11::basic_string<char> >&, int, int)':
a.cc:19:25: error: 'memcpy' was not declared in this scope
19 | memcpy(S+l,S+l+1,strLen);
| ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <set>
+++ |+#include <cstring>
4 |
|
s597923467 | p03859 | C++ | #include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
int N, M, mod, s[3009], rgt[3009], dp[3009][3009];
char sir[3009];
void ad (int &i, int j)
{
i += j;
if (i >= mod) i -= mod;
}
int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);
scanf ("%d %d\n", &N, &M), mod = 1e9 + 7;
gets (sir + 1);
for (int i=1; i<=N; i++)
s[i] = s[i - 1] + (sir[i] == '1');
for (int i=1; i<=N; i++)
rgt[i] = i;
while (M --)
{
int x, y;
scanf ("%d %d", &x, &y);
if (y > rgt[x]) rgt[x] = y;
}
dp[0][0] = 1;
int R = 0;
for (int i=0; i<N; i++)
{
for (int j=0; j<=R - i; j++)
if (dp[i][j])
{
//printf ("primele %d si pe [%d, %d] inca %d de 1 -> %d\n", i, i + 1, R, j, dp[i][j]);
int k1 = j, k0 = (R - i) - j, mk0 = 0, mk1 = 0;
if (rgt[i + 1] > R) mk1 = s[rgt[i + 1]] - s[R], mk0 = rgt[i + 1] - R - mk1;
k0 += mk0, k1 += mk1;
if (k1 >= 1) ad (dp[i + 1][k1 - 1], dp[i][j]);
if (k0 >= 1) ad (dp[i + 1][k1], dp[i][j]);
}
if (rgt[i + 1] > R) R = rgt[i + 1];
}
printf ("%d\n", dp[N][0]);
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:1: error: 'gets' was not declared in this scope; did you mean 'getw'?
22 | gets (sir + 1);
| ^~~~
| getw
|
s426741466 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t, u;
cin << s << t << u;
char first = t.at(0);
cout << 'A' + t.at(0) + 'C' << endl;
}
| a.cc: In function 'int main()':
a.cc:6:7: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
6 | cin << s << t << u;
| ~~~ ^~ ~
| | |
| | std::string {aka std::__cxx11::basic_string<char>}
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1715:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const sub_match<_Bi_iter>&)'
1715 | operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1715:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)'
125 | operator<<(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed:
a.cc:6:3: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte'
6 | cin << s << t << u;
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)'
763 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4077 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/bitset:1687:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const bitset<_Nb>&)'
1687 | operator<<(std::basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bitset:1687:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
In file included from /usr/include/c++/14/bits/ios_base.h:46,
from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)'
339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
| ^~~~~~~~
/usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
In file included from /usr/include/c++/14/memory:80,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56:
/usr/include/c++/14/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)'
70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
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:
/usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)'
563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)'
573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)'
579 | operator<<(basic_ostream<char, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)'
590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)'
595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)'
654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)'
307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
| ^~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)'
671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed:
a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
6 | cin << s << t << u;
| ^
/usr/include/c++/14/ostream:684:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<cha |
s956724170 | p03860 | Java | import java.io.*;
public class BoxesAndCandies {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String a = "AtCoder ";
String b = " Contest";
String s = br.readLine();
String s1 = s.toLowerCase();
String s2 = s1.substring(0,1).toUpperCase() + s1.substring(1);
String name = a + s2 + b;
System.out.println("A"+s2.charAt(0)+"C");
}
}
| Main.java:3: error: class BoxesAndCandies is public, should be declared in a file named BoxesAndCandies.java
public class BoxesAndCandies {
^
1 error
|
s791904611 | p03860 | Java | import java.io.*;
public class AtCodersContest {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
String s1 = s.toLowerCase();
String s2 = s1.substring(0,1).toUpperCase() + s1.substring(1);
System.out.println("A"+s2.charAt(0)+"C");
}
}
| Main.java:3: error: class AtCodersContest is public, should be declared in a file named AtCodersContest.java
public class AtCodersContest {
^
1 error
|
s203581746 | p03860 | Java | import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String x = input.nextLine();
String Splitt[] = x.split(" ");
for(String word : Splitt){
System.out.print(word.charAt(0));
}
}
} | Main.java:8: error: illegal character: '\u00a0'
?String x = input.nextLine();
^
Main.java:9: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ?
^
Main.java:9: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ?
^
Main.java:12: error: illegal character: '\u00a0'
? ? ?
^
Main.java:12: error: illegal character: '\u00a0'
? ? ?
^
Main.java:12: error: illegal character: '\u00a0'
? ? ?
^
Main.java:13: error: illegal character: '\u00a0'
} ? ?
^
Main.java:13: error: illegal character: '\u00a0'
} ? ?
^
8 errors
|
s852348081 | p03860 | Java | import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String x = in.nextLine();
String[] arr = x.split(" ");
for (int i = 0; i < arr.length; i++) {
String s = arr[i];
System.out.println(s.charAt(0));
}
}
} | Main.java:2: error: class A is public, should be declared in a file named A.java
public class A {
^
1 error
|
s140257268 | p03860 | Java | import java.util.*;
class Main{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String Sentence = input.nextLine();
String splitSen[] = Sentence.split(" ");
for(String word : splitSen){
System.out.print(word.charAt(0));
}
}
} | Main.java:6: error: illegal character: '\u00a0'
?String Sentence = input.nextLine();
^
Main.java:7: error: illegal character: '\u00a0'
String splitSen[] = Sentence.split(" "); ? ?
^
Main.java:7: error: illegal character: '\u00a0'
String splitSen[] = Sentence.split(" "); ? ?
^
Main.java:10: error: illegal character: '\u00a0'
? ? ?
^
Main.java:10: error: illegal character: '\u00a0'
? ? ?
^
Main.java:10: error: illegal character: '\u00a0'
? ? ?
^
6 errors
|
s803129846 | p03860 | Java | import java.util.*;
class Main{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String x = input.nextLine();
String Splitt[] = x.split(" ");
for(String word : Splitt){
System.out.print(word.charAt(0));
}
}
} | Main.java:5: error: illegal character: '\u00a0'
?String x = input.nextLine();
^
Main.java:6: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ? ?
^
Main.java:6: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ? ?
^
Main.java:6: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ? ?
^
Main.java:9: error: illegal character: '\u00a0'
? ? ?
^
Main.java:9: error: illegal character: '\u00a0'
? ? ?
^
Main.java:9: error: illegal character: '\u00a0'
? ? ?
^
Main.java:10: error: illegal character: '\u00a0'
} ? ?
^
Main.java:10: error: illegal character: '\u00a0'
} ? ?
^
9 errors
|
s964778917 | p03860 | Java | import java.util.*;
class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String x = input.nextLine();
String Splitt[] = x.split(" ");
for(String word : Splitt){
System.out.print(word.charAt(0));
}
}
} | Main.java:8: error: illegal character: '\u00a0'
?String x = input.nextLine();
^
Main.java:9: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ? ?
^
Main.java:9: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ? ?
^
Main.java:9: error: illegal character: '\u00a0'
String Splitt[] = x.split(" "); ? ? ?
^
Main.java:12: error: illegal character: '\u00a0'
? ? ?
^
Main.java:12: error: illegal character: '\u00a0'
? ? ?
^
Main.java:12: error: illegal character: '\u00a0'
? ? ?
^
7 errors
|
s396994440 | p03860 | Java |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s;
s = input.nextLine();
switch (s) {
case "AtCoder Beginner Contest":
System.out.println("ABC");
System.out.println("The contest in which you are participating now.");
break;
case "AtCoder Snuke Contest":
System.out.println("ASC");
System.out.println("The contest does not actually exist.");
break;
case "AtCoder X Contest":
System.out.println("AXC");
break;
}
} | Main.java:23: error: reached end of file while parsing
}
^
1 error
|
s533653774 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string x, y, z;
cin >> x >> y >> z;
char c;
c = y.at(0);
cout << "A" + c + "C" << endl;
} | a.cc: In function 'int main()':
a.cc:10:19: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
10 | cout << "A" + c + "C" << endl;
| ~~~~~~~ ^ ~~~
| | |
| | const char [2]
| const char*
|
s450585395 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string x, y, z;
cin >> x >> y >> z;
char c;
c = y.at(0);
cout << "A" + c + "C" << endl;
} | a.cc: In function 'int main()':
a.cc:10:19: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
10 | cout << "A" + c + "C" << endl;
| ~~~~~~~ ^ ~~~
| | |
| | const char [2]
| const char*
|
s783338407 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
char c;
c = s.at(9);
cout << "A" + c + "C" << endl;
} | a.cc: In function 'int main()':
a.cc:11:19: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
11 | cout << "A" + c + "C" << endl;
| ~~~~~~~ ^ ~~~
| | |
| | const char [2]
| const char*
|
s649045054 | p03860 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ll long long
void shakespeare() {
string a,b,c;
cin >> a >> b >> c;
cout << a.at(0) << b.at(0) << c.at(0) << endl;
} | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s903576972 | p03860 | C++ | #include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
cin >> "AtCoder" >> s >> "Contest";
cout << "A" << s[0] << "C" << "\n";
} | a.cc: In function 'int main()':
a.cc:7:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'const char [8]')
7 | cin >> "AtCoder" >> s >> "Contest";
| ~~~ ^~ ~~~~~~~~~
| | |
| | const char [8]
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:1:
/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:7:16: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'const char*'
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
/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:7:16: error: invalid conversion from 'const char*' to 'short int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(short int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const char*' to 'short unsigned int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(short unsigned int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const char*' to 'unsigned int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(unsigned int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const char*' to 'long int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(long int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const char*' to 'long unsigned int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(long unsigned int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const char*' to 'long long int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(long long int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const char*' to 'long long unsigned int' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const char*
a.cc:7:16: error: cannot bind rvalue '(long long unsigned int)((const char*)"AtCoder")' 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:7:16: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
7 | cin >> "AtCoder" >> s >> "Contest";
| ^~~~~~~~~
| |
| const void*
a.cc:7:16: error: cannot bind rvalue '(void*)((const void*)((const char*)"AtCoder"))' to 'void*&'
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'const char [8]' to 'float&'
219 | operator>>(float& __f)
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'const char [8]' to 'double&'
223 | operator>>(double& __f)
| ~~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'const char [8]' to 'long double&'
227 | operator>>(long double& __f)
| ~~~~~~~~~~~~~^~~
/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>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'const char [8]' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::b |
s488454419 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
cin >> a >> b >> c;
cout << a[0] << b[0] << c[0] << end;
} | a.cc: In function 'int main()':
a.cc:7:34: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
7 | cout << a[0] << b[0] << c[0] << end;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
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:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_ |
s647798853 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
string str;
char A,C;
char c = str at.size(0);
cin>>str>>A>>C>>c;
cout<< A+c+C <<endl;
} | a.cc: In function 'int main()':
a.cc:6:11: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char' in initialization
6 | char c = str at.size(0);
| ^~~
| |
| std::string {aka std::__cxx11::basic_string<char>}
|
s676952104 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
string s;
char c = s at.size(0);
cin>>s>>c;
cout<< A+c+C <<endl;
} | a.cc: In function 'int main()':
a.cc:5:11: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char' in initialization
5 | char c = s at.size(0);
| ^
| |
| std::string {aka std::__cxx11::basic_string<char>}
a.cc:7:9: error: 'A' was not declared in this scope
7 | cout<< A+c+C <<endl;
| ^
a.cc:7:13: error: 'C' was not declared in this scope
7 | cout<< A+c+C <<endl;
| ^
|
s059204794 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
char A,B,C;
cin >> A >> B >> C;
cout << "A"<< B.at(0) <<"C"<< endl; // a
} | a.cc: In function 'int main()':
a.cc:9:19: error: request for member 'at' in 'B', which is of non-class type 'char'
9 | cout << "A"<< B.at(0) <<"C"<< endl; // a
| ^~
|
s672053624 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string B;
cin >> B;
string answer = B.at(0);
cout << 'A' << answer << 'C' << endl;
}
| a.cc: In function 'int main()':
a.cc:8:23: error: conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
8 | string answer = B.at(0);
| ~~~~^~~
|
s514771056 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string B;
cin >> B;
string answer = B.st(0);
cout << 'A' << answer << 'C' << endl;
} | a.cc: In function 'int main()':
a.cc:8:21: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'st'; did you mean 'at'?
8 | string answer = B.st(0);
| ^~
| at
|
s144431047 | p03860 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
getline(cin, S) ;
cout << "A" + S.at(8) + "C" << endl;
}
| a.cc: In function 'int main()':
a.cc:8:23: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
8 | cout << "A" + S.at(8) + "C" << endl;
| ~~~~~~~~~~~~~ ^ ~~~
| | |
| const char* const char [2]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.