submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s111065743 | p03769 | C++ | #include <stdio.h>
#include <iostream>
using namespace std;
const int maxn=105;
int odd[maxn],even[maxn];
long long n;
int main(){
int i,num=1;
scanf("%lld",&n);n++;
while(n>1){
if(n&1)odd[++odd[0]]=num++,n--;
else even[++even[0]]=num++,n/=2;
}
printf("%d\n",odd[0]+even[0]<<1);
for(i=1;i<=odd[0];i++)printf("%d ",odd[i]);
for(i=even[0];i>=1;i--)printf("%d ",even[i]);
for(i=odd[0]+even[0];i>=1;i--)printf("%d ",i);
return 0;
} | a.cc:5:25: error: expected initializer before '\U0000ff1b'
5 | int odd[maxn],even[maxn];
| ^~
a.cc: In function 'int main()':
a.cc:9:19: error: 'n' was not declared in this scope
9 | scanf("%lld",&n);n++;
| ^
a.cc:12:14: error: 'even' was not declared in this scope
12 | else even[++even[0]]=num++,n/=2;
| ^~~~
a.cc:14:26: error: 'even' was not declared in this scope
14 | printf("%d\n",odd[0]+even[0]<<1);
| ^~~~
|
s623347409 | p03769 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
tread x;
return 0;
} | a.cc: In function 'int main()':
a.cc:11:3: error: 'tread' was not declared in this scope; did you mean 'read'?
11 | tread x;
| ^~~~~
| read
|
s460313282 | p03769 | C++ | #include<bits/stdc++.h>
using namespace std;
void read(int &x) {
x=0;int f=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}
void print(int x) {
if(x<0) putchar('-'),x=-x;
if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}
#define lf double
#define ll long long
#define pb push_back
const long long maxn = 1e5+10;
const long long inf = 1e9;
const lf eps = 1e-8;
long long n;
vector<int > s,t;
signed main() {
read(n);long long p=101;n++;
while(n>1) {if(n&1) t.pb(--p),n--;else s.pb(--p),n>>=1;}
int m=s.size()+t.size();printf("%lld\n",m<<1);
for(int i=0;i<(int)t.size();i++) printf("%lld ",t[i]);
for(int i=s.size()-1;~i;i--) printf("%lld ",s[i]);
for(int i=100-m+1;i<=100;i++) printf("%lld ",i);
return 0;
} | a.cc: In function 'int main()':
a.cc:30:10: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
30 | read(n);long long p=101;n++;
| ^
a.cc:6:16: note: initializing argument 1 of 'void read(int&)'
6 | void read(int &x) {
| ~~~~~^
|
s115501636 | p03769 | C++ | #include<bits/stdc++.h>
using namespace std;
void read(int &x) {
x=0;int f=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}
void print(int x) {
if(x<0) putchar('-'),x=-x;
if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}
#define lf double
#define ll long long
#define pb push_back
const int maxn = 1e5+10;
const int inf = 1e9;
const lf eps = 1e-8;
long long n;
vector<int > s,t;
signed main() {
read(n);long long p=101;n++;
while(n>1) {if(n&1) t.pb(--p),n--;else s.pb(--p),n>>=1;}
int m=s.size()+t.size();printf("%lld\n",m<<1);
for(int i=0;i<(int)t.size();i++) printf("%lld ",t[i]);
for(int i=s.size()-1;~i;i--) printf("%lld ",s[i]);
for(int i=100-m+1;i<=100;i++) printf("%lld ",i);
return 0;
} | a.cc: In function 'int main()':
a.cc:30:10: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
30 | read(n);long long p=101;n++;
| ^
a.cc:6:16: note: initializing argument 1 of 'void read(int&)'
6 | void read(int &x) {
| ~~~~~^
|
s888324742 | p03769 | C++ | /**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back
const long long MAXN = 1e6 + 1;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long readInt() {
bool minus1 = false;
long long result = 0;
char ch;
ch = getchar();
while (true) {
if (ch == '-') break;
if (ch >= '0' && ch <= '9') break;
ch = getchar();
}
if (ch == '-') minus1 = true; else result = ch-'0';
while (true) {
ch = getchar();
if (ch < '0' || ch > '9') break;
result = result*10 + (ch - '0');
}
if (minus1)
return -result;
else
return result;
}
#define int __int64
main() {
#ifdef IZI_KATKA
assert(freopen("input", "r", stdin));
assert(freopen("output", "w", stdout));
#endif
int n = readInt();
int k = 100;
vector <int> ans;
for (int i = 1; i <= k; i++) {
ans.pb(i);
}
int l = 1, r = k;
while (n) {
if (!(n & 1)) {
n--;
ans.pb(r--);
}
ans.pb(l++);
--n;
n >>= 1;
}
cout << ans.size() << endl;
for (int i : ans) {
cout << i << ' ';
}
return 0;
}
| a.cc:63:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
63 | main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:68:5: note: in expansion of macro 'int'
68 | int n = readInt();
| ^~~
a.cc:69:9: error: expected ';' before 'k'
69 | int k = 100;
| ^
a.cc:70:16: error: template argument 2 is invalid
70 | vector <int> ans;
| ^
a.cc:71:14: error: expected ';' before 'i'
71 | for (int i = 1; i <= k; i++) {
| ^
a.cc:71:21: error: 'i' was not declared in this scope
71 | for (int i = 1; i <= k; i++) {
| ^
a.cc:71:26: error: 'k' was not declared in this scope
71 | for (int i = 1; i <= k; i++) {
| ^
a.cc:30:12: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
30 | #define pb push_back
| ^~~~~~~~~
a.cc:72:13: note: in expansion of macro 'pb'
72 | ans.pb(i);
| ^~
a.cc:74:9: error: expected ';' before 'l'
74 | int l = 1, r = k;
| ^
a.cc:75:12: error: 'n' was not declared in this scope; did you mean 'yn'?
75 | while (n) {
| ^
| yn
a.cc:30:12: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
30 | #define pb push_back
| ^~~~~~~~~
a.cc:78:17: note: in expansion of macro 'pb'
78 | ans.pb(r--);
| ^~
a.cc:78:20: error: 'r' was not declared in this scope
78 | ans.pb(r--);
| ^
a.cc:30:12: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
30 | #define pb push_back
| ^~~~~~~~~
a.cc:80:13: note: in expansion of macro 'pb'
80 | ans.pb(l++);
| ^~
a.cc:80:16: error: 'l' was not declared in this scope; did you mean 'll'?
80 | ans.pb(l++);
| ^
| ll
a.cc:84:17: error: request for member 'size' in 'ans', which is of non-class type 'int'
84 | cout << ans.size() << endl;
| ^~~~
a.cc:85:14: error: expected ';' before 'i'
85 | for (int i : ans) {
| ^
a.cc:88:5: error: expected primary-expression before 'return'
88 | return 0;
| ^~~~~~
a.cc:87:6: error: expected ';' before 'return'
87 | }
| ^
| ;
88 | return 0;
| ~~~~~~
a.cc:88:5: error: expected primary-expression before 'return'
88 | return 0;
| ^~~~~~
a.cc:87:6: error: expected ')' before 'return'
87 | }
| ^
| )
88 | return 0;
| ~~~~~~
a.cc:85:9: note: to match this '('
85 | for (int i : ans) {
| ^
|
s092276490 | p03769 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string ans;
ll N;
ll moji[205];
void f(int in) {
cout << in << endl;
//char out = (char)('0' + in);
string now;
for(int i = 1; i <= 200; i++) {
if(moji[i] > N) {
N -= moji[i - 1];
break;
}
ans.push_back(out);
}
//return now;
return;
}
int main() {
//cout.precision(10);
cin >> N;
moji[0] = 0;
moji[1] = 1;
for(int i = 2; i <= 50; i++) {
moji[i] = moji[i - 1] * 2;
}
for(int i = 1; i <= 50; i++) {
moji[i]--;
}
for(int i = 1; i <= 10000; i++) {
if(N == 0) break;
//ans = ans + f(i % 100 + 1);
f(i % 90 + 1);
}
//cout << ans << endl;
cout << ans.size() << endl;
for(int i = 0; i < ans.size(); i++) {
cout << ans[i];
if(i + 1 < ans.size()) cout << " ";
}
cout << endl;
return 0;
}
| a.cc: In function 'void f(int)':
a.cc:21:23: error: 'out' was not declared in this scope
21 | ans.push_back(out);
| ^~~
|
s089991871 | p03769 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll=__int128;
const ll INF=1e15;
int main(){
vector<vector<ll>> comb(300,vector<ll>(300,0));
for(int i=0;i<300;i++){
comb[i][0]=1;
comb[i][i]=1;
}
for(int i=1;i<300;i++){
for(int j=1;j<i;j++){
comb[i][j]=min(comb[i-1][j]+comb[i-1][j-1],INF);
}
}
long long bufn;
cin>>bufn;
ll n=bufn;
vector<int> ans;
auto calcPatSingle=[&](int len){
ll sum=0;
for(int k=2;k<=len;k+=2){
sum+=comb[len][k];
}
return sum;
};
auto calcPatCross=[&](int l1,int l2){
return comb[2*l1][l1]*comb[2*l2][l2];
};
int num=1;
while(n){
int besti=-1;
int bestj=-1;
ll bestSum=0;
for(int i=0;i<=41;i++){
for(int j=0;j<i;j++){
ll sum=calcPatSingle(i)+calcPatSingle(j)+calcPatCross(i,j);
if(sum<=n && double(bestSum)/(besti+bestj)<double(sum)/(j+j)){
besti=i,bestj=j;
bestSum=sum;
}
}
}
n-=bestSum;
for(int k=0;k<2;k++){
for(int i=0;i<besti;i++){
ans.push_back(num);
}
for(int j=0;j<bestj;j++){
ans.push_back(num+1);
}
}
num+=2;
}
cout<<ans.size()<<endl;
for(int i=0;i<ans.size();i++){
cout<<ans[i]<<(i+1==ans.size() ? "\n" : " ");
}
return 0;
}#include<bits/stdc++.h>
using namespace std;
using ll=__int128;
const ll INF=1e15;
int main(){
vector<vector<ll>> comb(300,vector<ll>(300,0));
for(int i=0;i<300;i++){
comb[i][0]=1;
comb[i][i]=1;
}
for(int i=1;i<300;i++){
for(int j=1;j<i;j++){
comb[i][j]=min(comb[i-1][j]+comb[i-1][j-1],INF);
}
}
long long bufn;
cin>>bufn;
ll n=bufn;
vector<int> ans;
auto calcPatSingle=[&](int len){
ll sum=0;
for(int k=2;k<=len;k+=2){
sum+=comb[len][k];
}
return sum;
};
auto calcPatCross=[&](int l1,int l2){
return comb[2*l1][l1]*comb[2*l2][l2];
};
int num=1;
while(n){
int besti=-1;
int bestj=-1;
ll bestSum=0;
for(int i=0;i<=41;i++){
for(int j=0;j<i;j++){
ll sum=calcPatSingle(i)+calcPatSingle(j)+calcPatCross(i,j);
if(sum<=n && double(bestSum)/(besti+bestj)<double(sum)/(j+j)){
besti=i,bestj=j;
bestSum=sum;
}
}
}
n-=bestSum;
for(int k=0;k<2;k++){
for(int i=0;i<besti;i++){
ans.push_back(num);
}
for(int j=0;j<bestj;j++){
ans.push_back(num+1);
}
}
num+=2;
}
cout<<ans.size()<<endl;
for(int i=0;i<ans.size();i++){
cout<<ans[i]<<(i+1==ans.size() ? "\n" : " ");
}
return 0;
} | a.cc:64:2: error: stray '#' in program
64 | }#include<bits/stdc++.h>
| ^
a.cc:64:3: error: 'include' does not name a type
64 | }#include<bits/stdc++.h>
| ^~~~~~~
a.cc:68:10: error: redefinition of 'const ll INF'
68 | const ll INF=1e15;
| ^~~
a.cc:5:10: note: 'const ll INF' previously defined here
5 | const ll INF=1e15;
| ^~~
a.cc:69:5: error: redefinition of 'int main()'
69 | int main(){
| ^~~~
a.cc:6:5: note: 'int main()' previously defined here
6 | int main(){
| ^~~~
a.cc: In lambda function:
a.cc:92:23: error: mangling of 'main()::<lambda(int, int)>' as '_ZZ4mainENKUliiE_clEii' conflicts with a previous mangle
92 | auto calcPatCross=[&](int l1,int l2){
| ^
a.cc:29:23: note: previous mangling 'main()::<lambda(int, int)>'
29 | auto calcPatCross=[&](int l1,int l2){
| ^
a.cc:92:23: note: a later '-fabi-version=' (or =0) avoids this error with a change in mangling
92 | auto calcPatCross=[&](int l1,int l2){
| ^
|
s011990805 | p03769 | C++ | #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
inline char get(void) {
static char buf[100000], *S = buf, *T = buf;
if (S == T) {
T = (S = buf) + fread(buf, 1, 100000, stdin);
if(S == T) return EOF;
}
return *S++;
}
template<typename T>
inline void read(T &x) {
static char c; x = 0; int sgn = 0;
for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
if (sgn) x = -x;
}
const int N = 101010;
int a[N << 2];
int n;
long long sum;
int main(void) {
read(n);
for (int i = 0; i < n * 3; i++) {
read(a[i]); a[i] = -a[i];
}
sort(a, a + n * 3);
for (int i = 0; i < n; i++) sum -= a[i << 1 | 1];
print(%d,sum);
}
| a.cc: In function 'int main()':
a.cc:35:15: error: expected primary-expression before '%' token
35 | print(%d,sum);
| ^
a.cc:35:16: error: 'd' was not declared in this scope
35 | print(%d,sum);
| ^
a.cc:35:9: error: 'print' was not declared in this scope; did you mean 'printf'?
35 | print(%d,sum);
| ^~~~~
| printf
|
s015542667 | p03769 | C++ | #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
inline char get(void) {
static char buf[100000], *S = buf, *T = buf;
if (S == T) {
T = (S = buf) + fread(buf, 1, 100000, stdin);
if(S == T) return EOF;
}
return *S++;
}
template<typename T>
inline void read(T &x) {
static char c; x = 0; int sgn = 0;
for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
if (sgn) x = -x;
}
const int N = 101010;
int a[N << 2];
int n;
long long sum;
int main(void) {
read(n);
for (int i = 0; i < n * 3; i++) {
read(a[i]); a[i] = -a[i];
}
sort(a, a + n * 3);
for (int i = 0; i < n; i++) sum -= a[i << 1 | 1];
print(%d,&sum);
}
| a.cc: In function 'int main()':
a.cc:35:15: error: expected primary-expression before '%' token
35 | print(%d,&sum);
| ^
a.cc:35:16: error: 'd' was not declared in this scope
35 | print(%d,&sum);
| ^
a.cc:35:9: error: 'print' was not declared in this scope; did you mean 'printf'?
35 | print(%d,&sum);
| ^~~~~
| printf
|
s658308741 | p03769 | C++ | #include <bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define pii pair<int,int>
#define sit set<int>:: iterator
#define IOS ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int MAXLOG=60;
ll pw[MAXLOG];
int main(){
int n;
cin>>n;
pw[0]=1;
rep(i,1,MAXLOG)
pw[i]=pw[i-1]*2;
int cnt=1;
per(i,0,MAXLOG)
if(pw[i]<=n){
rep(j,0,i+1)
V.pb(cnt);
cnt++;
n-=pw[i];
}
cout<<V.size()<<endl;
for(auto tmp:V)
cout<<tmp<<' ';
cout<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:17: error: 'V' was not declared in this scope
26 | V.pb(cnt);
| ^
a.cc:30:11: error: 'V' was not declared in this scope
30 | cout<<V.size()<<endl;
| ^
|
s401336428 | p03769 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
ll cnt(string c) {
ll ret=0;
REP(i,(1<<(ll)c.size())) {
bitset<64> bi(i);
if(bi.count()%2) continue;
string tmp;
REP(j,c.size()) {
if(bi[j]) tmp+=c[j];
}
if(tmp.substr(0,tmp.size()/2)==tmp.substr(tmp.size()/2,tmp.size()/2)) {
if(tmp.size()!=0) ret++;
}
}
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin>>n;
vector<ll> v;
ll _n=n;
while(_n>0) {
v.pb(_n);
_n=(_n-1)/2;
}
reverse(ALL(v));
string a="";
string b="";
ll tmp=0;
if(v[0]==1) {
a="1";
b="1";
tmp=2;
} else {
a="21";
b="21";
tmp=3;
}
FOR(j,1,v.size()) {
if(v[j]==v[j-1]*2+1) {
a+=to_string(tmp-1);
} else {
a+=to_string(tmp);
b+=to_string(tmp);
tmp++;
}
//cout<<a+b<<":"<<cnt(a+b)<<endl;
}
cout<<a.size()+b.size()<<endl;Y
REP(i,a.size()) {
cout<<a[i]<<" ";
}
REP(i,b.size()) {
cout<<b[i];
if(i==(ll)b.size()-1) cout<<endl;
else cout<<" ";
}
}
| a.cc: In function 'int main()':
a.cc:66:39: error: 'Y' was not declared in this scope
66 | cout<<a.size()+b.size()<<endl;Y
| ^
a.cc:67:13: error: 'i' was not declared in this scope
67 | REP(i,a.size()) {
| ^
a.cc:9:31: note: in definition of macro 'FOR'
9 | #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
| ^
a.cc:67:9: note: in expansion of macro 'REP'
67 | REP(i,a.size()) {
| ^~~
|
s198938759 | p03769 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
int main() {
ll N;
cin >> N;
++N;
vi ans;
for (int i = 1; i <= 100; ++i) {
ans.pb(i);
}
vi nums, vec;
int mn = -1, mx = -1;
while (N) {
if (N & 1) {
vec.pb(1);
--N;
}
if (N == 2) {
mn = mx = 0;
nums.pb(0);
break;
}
vec.pb(0);
N /= 2;
}
reverse(ALL(vec));
for (int f : vec) {
if (mn == -1 && mx == -1) {
mn = mx = 0;
nums.pb(0);
continue;
}
if (f == 0) {
nums.pb(mx + 1);
++mx;
} else {
nums.pb(mn - 1);
--mn;
}
}
if (p) {
nums.pb(mn - 1);
--mn;
}
for (int x : nums) {
ans.pb(x - mn + 1);
}
cout << ans.size() << endl;
rep(i, ans.size()) cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');
return 0;
} | a.cc: In function 'int main()':
a.cc:65:13: error: 'p' was not declared in this scope
65 | if (p) {
| ^
|
s399757902 | p03769 | C++ | 299
| a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 299
| ^~~
|
s280893751 | p03769 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
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){
if(a<0){
a=-a; putchar('-');
}
write(a); puts("");
}
inline int rnd(int x){
return (rand()<<16|rand())%x;
}
ll n;
deque<int> ans;
void solve(ll n,int id){
if(n==1)return;
if(n&1){
solve(n-1,id+1); fro.push_front(id); bac.push_back(id);
}else{
solve(n>>1,id+1); fro.push_back(id); bac.push_back(id);
}
}
int main(){
cin>>n; n++;
solve(n,1);
cout<<fro.size()*2<<endl;
while(fro.size()){
cout<<fro.front()<<" "; fro.pop_front();
}
while(bac.size()){
cout<<bac.front()<<" "; bac.pop_front();
}
} | a.cc: In function 'void solve(ll, int)':
a.cc:40:34: error: 'fro' was not declared in this scope
40 | solve(n-1,id+1); fro.push_front(id); bac.push_back(id);
| ^~~
a.cc:40:54: error: 'bac' was not declared in this scope
40 | solve(n-1,id+1); fro.push_front(id); bac.push_back(id);
| ^~~
a.cc:42:35: error: 'fro' was not declared in this scope
42 | solve(n>>1,id+1); fro.push_back(id); bac.push_back(id);
| ^~~
a.cc:42:55: error: 'bac' was not declared in this scope
42 | solve(n>>1,id+1); fro.push_back(id); bac.push_back(id);
| ^~~
a.cc: In function 'int main()':
a.cc:49:15: error: 'fro' was not declared in this scope
49 | cout<<fro.size()*2<<endl;
| ^~~
a.cc:53:15: error: 'bac' was not declared in this scope
53 | while(bac.size()){
| ^~~
|
s009396199 | p03769 | C++ | #ifdef DEBUG
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <cassert>
#include <sstream>
#include <fstream>
#include <functional>
#include <set>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#else
#include <bits/stdc++.h>
#endif
#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(i, n) for (int i = 0, i##_end_ = (n); i < i##_end_; ++i)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define forn(i, l, r) for (int i = (l), i##_end_ = (r); i <= i##_end_; ++i)
#define nrof(i, r, l) for (int i = (r), i##_end_ = (l); i >= i##_end_; --i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long LL;
template<typename T> inline bool chkmax(T &x, const T &y) {
return x < y ? x = y, 1 : 0;
}
#ifdef DEBUG
char *input_file, *output_file;
#endif
struct IO {
static const int maxn = (1 << 25) + 10;
char a[maxn], *s, b[maxn], *t;
void INPUT() {
s = a;
t = b;
#ifdef DEBUG
FILE *f = fopen(input_file, "r");
a[fread(a, 1, sizeof a, f)] = 0;
#else
a[fread(a, 1, sizeof a, stdin)] = 0;
#endif
}
void OUTPUT() {
#ifdef DEBUG
FILE *f = fopen(output_file, "w");
fwrite(b, 1, t - b, f);
#else
fwrite(b, 1, t - b, stdout);
#endif
}
operator int() {
int x = 0;
while(*s != '-' && (*s < '0' || *s > '9')) {
++s;
}
bool f = 0;
if(*s == '-') {
f = 1;
++s;
}
while(*s >= '0' && *s <= '9') {
(x *= 10) += *s - '0';
++s;
}
if(f) {
x = -x;
}
return x;
}
operator LL() {
LL x = 0;
while(*s != '-' && (*s < '0' || *s > '9')) {
++s;
}
bool f = 0;
if(*s == '-') {
f = 1;
++s;
}
while(*s >= '0' && *s <= '9') {
(x *= 10) += *s - '0';
++s;
}
if(f) {
x = -x;
}
return x;
}
operator char() {
while(*s <= 32) {
++s;
}
char ret = *s;
++s;
return ret;
}
inline void out(int x) {
if(!x) {
*t++ = '0';
return;
}
if(x < 0) {
*t++ = '-';
x = -x;
}
static char c[20], *i;
i = c;
while(x) {
int y = x / 10;
*i++ = x - y * 10 + '0';
x = y;
}
while(i != c) {
*t++ = *--i;
}
return;
}
inline void out(int x, char C) {
if(!x) {
*t++ = '0';
*t++ = C;
return;
}
if(x < 0) {
*t++ = '-';
x = -x;
}
static char c[20], *i;
i = c;
while(x) {
int y = x / 10;
*i++ = x - y * 10 + '0';
x = y;
}
while(i != c) {
*t++ = *--i;
}
*t++ = C;
return;
}
inline void out(LL x) {
if(!x) {
*t++ = '0';
return;
}
if(x < 0) {
*t++ = '-';
x = -x;
}
static char c[20], *i;
i = c;
while(x) {
LL y = x / 10;
*i++ = x - y * 10 + '0';
x = y;
}
while(i != c) {
*t++ = *--i;
}
return;
}
inline void out(LL x, char C) {
if(!x) {
*t++ = '0';
*t++ = C;
return;
}
if(x < 0) {
*t++ = '-';
x = -x;
}
static char c[20], *i;
i = c;
while(x) {
LL y = x / 10;
*i++ = x - y * 10 + '0';
x = y;
}
while(i != c) {
*t++ = *--i;
}
*t++ = C;
return;
}
inline void out(char c) {
*t++ = c;
return;
}
inline void out(char *s) {
while(*s >= ' ') {
*t++ = *s++;
}
return;
}
}io;
void Main();
int main(int argc, char *argv[]) {
#ifdef DEBUG
input_file = argv[1];
output_file = argv[2];
#endif
io.INPUT();
Main();
io.OUTPUT();
return 0;
}
//---------------------------------------------------------------------------------------head---------------------------------------------------------------------------------------
const int maxn = 102;
LL n;
int m;
int pos[maxn], ans[maxn];
void solve(int i, LL base, int j) {
if(!(n & base)) {
n -= (base << 1);
assert(n >= 0);
pos[i] = pos[i + 1] = j;
if(!n) {
m = i + 1;
return;
}
return solve(i + 2, base << 1, j + 1);
}
pos[i] = j;
n ^= base;
if(!n) {
m = i;
return;
}
return solve(i + 1, base << 1, j + 1);
}
void Main() {
n = io;
solve(1, 1, 0);
ans[1] = 1;
forn(i, 2, m) {
int p = pos[i];
nrof(j, i, p + 2) {
ans[j] = ans[j - 1];
}
ans[p + 1] = i;
}
io.out(m << 1, ‘\n’);
forn(i, 1, m) {
io.out(i, ' ');
}
forn(i, 1, m) {
io.out(ans[i], ' ');
}
return;
}
| a.cc:287:24: error: extended character ‘ is not valid in an identifier
287 | io.out(m << 1, ‘\n’);
| ^
a.cc:287:25: error: stray '\' in program
287 | io.out(m << 1, ‘\n’);
| ^
a.cc:287:26: error: extended character ’ is not valid in an identifier
287 | io.out(m << 1, ‘\n’);
| ^
a.cc: In function 'void Main()':
a.cc:287:24: error: '‘' was not declared in this scope
287 | io.out(m << 1, ‘\n’);
| ^
|
s102649459 | p03769 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <deque>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
long long N;
cin >> N;
N++;
int A, B;
vector<int> ops;
while(N != 1){
if(N % 2 == 1){
ops.push_back(0);
N--;
| a.cc: In function 'int main()':
a.cc:23:17: error: expected '}' at end of input
23 | N--;
| ^
a.cc:21:23: note: to match this '{'
21 | if(N % 2 == 1){
| ^
a.cc:23:17: error: expected '}' at end of input
23 | N--;
| ^
a.cc:20:18: note: to match this '{'
20 | while(N != 1){
| ^
a.cc:23:17: error: expected '}' at end of input
23 | N--;
| ^
a.cc:12:11: note: to match this '{'
12 | int main(){
| ^
|
s547596680 | p03769 | C++ | #include<bits\stdc++.h>
using namespace std;
typedef long long ll;
ll N;
int main()
{
scanf("%lld",&N);
ll now = 2;
for(ll i = 63; i >= 2; i--)
{
ll num = pow(2,i - 1) - 1;
while(N >= num)
{
for(int j = 0; j < i; j++)
{
printf("%d ",now);
}
N -= num;
now++;
}
}
printf("1\n");
return 0;
}
| a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
1 | #include<bits\stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s961476669 | p03769 | C++ | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
int main(){
ll n;
cin >> n;
n++;
VI a;
while (n){
a.push_back(n%2);
n /= 2;
}
reverse(ALL(a));
// int m = a.size();
// REP(i,m) cout << a[i];
// cout << endl;
deque<int> ans;
int x = 1;
FOR(i,1,m-1){
ans.push_back(x++);
if (a[i]) ans.push_front(x++);
}
cout << ans.size() * 2 << endl;
FOR(i,1,ans.size()) cout << i << " ";
while (!ans.empty()){
cout << ans.front() << " ";
ans.pop_front();
}
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:43:13: error: 'm' was not declared in this scope
43 | FOR(i,1,m-1){
| ^
a.cc:16:36: note: in definition of macro 'FOR'
16 | #define FOR(i,a,b) for(int i=a; i<=b; ++i)
| ^
|
s143972880 | p03769 | Java | public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long N = sc.nextLong();
long[] c = new long[200];
int[] result = new int[200];
int sum = 0;
int num = 1;
while(N!=0) {
long pos = 0x0000000000000001L;
int posi = 63;
String s = "";
while (pos != 0) {
if ((N & pos) == 0) {
s += "0";
} else {
s += "1";
}
pos = pos << 1;
}
int i = s.lastIndexOf("1") + 1;
int j = s.lastIndexOf("0", i - 1) + 1;
int x = j;
int y = i - j;
if (x < y) {
y = i / 2;
x = i - y;
}
for(int a=0;a<x+1;a++){
for(int b=0;b<y;b++){
result[sum]=num+b;
sum++;
}
}
num+=y;
N-=(Math.pow(2,x)-1)*(Math.pow(2,y)-1);
if(N==1){
result[sum]=num;
sum++;
result[sum]=num;
sum++;
break;
}
}
System.out.println(sum);
for(int i=0;i<sum;i++){
System.out.print(result[i]+" ");
}
}
} | Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s777549906 | p03769 | Java |
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long N = sc.nextLong();
long[] c = new long[200];
int[] result = new int[200];
int sum = 0;
int num = 1;
while(N!=0) {
long pos = 0x0000000000000001L;
int posi = 63;
String s = "";
while (pos != 0) {
if ((N & pos) == 0) {
s += "0";
} else {
s += "1";
}
pos = pos << 1;
}
int i = s.lastIndexOf("1") + 1;
int j = s.lastIndexOf("0", i - 1) + 1;
int x = j;
int y = i - j;
if (x < y) {
y = i / 2;
x = i - y;
}
for(int a=0;a<x;a++){
for(int b=0;b<y;b++){
result[sum]=num+b;
sum++;
}
}
num+=y;
N-=(Math.pow(2,x)-1)*(Math.pow(2,y)-1);
if(N==1){
break;
}
}
System.out.println(sum);
for(int i=0;i<sum;i++){
System.out.print(result[i]+" ");
}
}
} | Main.java:5: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s302133997 | p03769 | C++ | // Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
#ifdef LOCAL
#include "contest.h"
#else
#define error(args...)
#endif
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }
void iostream_init() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.setf(ios::fixed);
cout.precision(12);
}
//}}}
int eval(LL N, int rest=0) {
if(rest == 0) {
int res = 0;
while(N > 0) {
for(int i = 1; i < 50; i++) {
LL nx = (1L<<(i+1)) - 1;
if(N < nx) {
LL x = (1L<<i) - 1;
res += i;
N -= x;
break;
}
}
}
return res;
} else {
int res = INT_MAX;
for(int i = 1; i < 50; i++) {
LL x = (1L<<i) - 1;
if(N - x >= 0) {
res = min(res, eval(N - x, rest-1) + i);
}
}
}
}
vector<int> solve(LL N) {
vector<int> ans;
int cnt = 0;
while(N > 0) {
vector<pair<int, int>> ps;
for(int i = 1; i < 50; i++) {
LL x = (1L<<i) - 1;
if(N - x >= 0) {
ps.push_back(make_pair(eval(N - x) + i, i));
}
}
sort(ps.begin(), ps.end());
assert(ps.size() > 0);
int idx = ps[0].second;
REP(i, idx) ans.push_back(cnt);
cnt++;
N -= ((1L<<(idx))-1);
}
assert(N == 0);
return ans;
}
int main(){
LL test = 549755813887LL;
iostream_init();
LL N;
cin >> N;
auto v = solve(N);
assert(v.size() <= 200);
cout << v.size() << endl;
REP(i, v.size()) {
cout << v[i];
if(i+1 == v.size()) {
cout << endl;
} else {
cout << " ":
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:85:24: error: expected ';' before ':' token
85 | cout << " ":
| ^
| ;
a.cc: In function 'int eval(LL, int)':
a.cc:49:1: warning: control reaches end of non-void function [-Wreturn-type]
49 | }
| ^
|
s166935568 | p03769 | C++ | def nCr(a,b):
tmp=1
for i in range(a,a-b,-1):tmp*=i
for i in range(1,b+1,1):tmp//=i
return tmp
n=int(input())
out=[]
co=1
coo=0
while n>0:
t=2
while True:
sum1=0
for j in range(2,t+1,2):
sum1+=nCr(t,j)
# print(n,sum)
if n<sum1:
t-=1
# n-=rco
break
rco=sum1
t+=1
ad=[co for _ in range(t)]
sum1=rco
ma=sum1
# print(ma)
for toa in range(1,4):
for tob in range(1,4):
CO=0
for r in range(1,min(toa,tob)+1):
CO+=nCr(toa,r)*nCr(tob,r)
for a in range(1,t):
sum2=sum1+((2**(toa+tob-1))-1)
for b in range(1,a+1):
sum2+=nCr(a,b)*nCr(t-a,b)*CO
if sum2>n:continue
if ma<sum2:
ma=sum2
ad=[co for _ in range(a)]
for _ in range(toa):ad.append(100-coo)
for _ in range(t-a):ad.append(co)
for _ in range(tob):ad.append(100-coo)
# print(ad,0,ma)
for t in ad:out.append(t)
# out.append(ad)
n-=ma
coo+=1
co+=1
print(len(out))
print(*out)
| a.cc:17:17: error: invalid preprocessing directive #print
17 | # print(n,sum)
| ^~~~~
a.cc:20:25: error: invalid preprocessing directive #n
20 | # n-=rco
| ^
a.cc:27:9: error: invalid preprocessing directive #print
27 | # print(ma)
| ^~~~~
a.cc:46:9: error: invalid preprocessing directive #print
46 | # print(ad,0,ma)
| ^~~~~
a.cc:48:9: error: invalid preprocessing directive #out
48 | # out.append(ad)
| ^~~
a.cc:1:1: error: 'def' does not name a type
1 | def nCr(a,b):
| ^~~
|
s843495800 | p03769 | Java |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class IntersectingDates
{
public static void main(String[]args)throws Throwable
{
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
PrintWriter out = new PrintWriter(System.out);
int len = 200;
ArrayList<Integer> ans = new ArrayList();
for(int i = 1 ; i <= 100 ; ++i)
{
long lst = 0;
for(int j = 1 ; j <= len ; ++j)
{
if((1 << (j - 1)) - 1 > n)
break;
lst = j;
}
n -= (1 << lst) - 1;
len -= lst;
for(int k = 0 ; k < lst ; ++k)
ans.add(i);
}
System.out.println(ans.size());
for(Integer x : ans)
System.out.print(x+" ");
}
static class Scanner
{
BufferedReader br;
StringTokenizer st;
Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); }
String next() throws IOException
{
while(st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); }
long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); }
}
}
| Main.java:14: error: class IntersectingDates is public, should be declared in a file named IntersectingDates.java
public class IntersectingDates
^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
|
s471524927 | p03769 | C++ | #define _GLIBCXX_IOSTREAM
#include<bits/stdc++.h>
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double llf;
typedef std::pair<int,int> pii;
#define xx first
#define yy second
template<typename T> inline T max(T a,T b){return a>b?a:b;}
template<typename T> inline T min(T a,T b){return a<b?a:b;}
template<typename T> inline T abs(T a){return a>0?a:-a;}
template<typename T> inline bool repr(T &a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool repl(T &a,T b){return a>b?a=b,1:0;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b){while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
template<typename T> inline T sqr(T x){return x*x;}
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
#define I inline
#define mset(a,b) memset(a,b,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define fo0(i,n) for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define fd0(i,n) for(int i=(n)-1;~i;i--)
#define fd1(i,n) for(int i=n;i;i--)
#define fd(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define foe(i,x)for(__typeof(x.end())i=x.begin();i!=x.end();++i)
struct Cg{I char operator()(){return getchar();}};
struct Cp{I void operator()(char x){putchar(x);}};
#define OP operator
#define RT return *this;
#define RX x=0;char t=P();while((t<'0'||t>'9')&&t!='-')t=P();bool f=0;\
if(t=='-')t=P(),f=1;x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define RL if(t=='.'){lf u=0.1;for(t=P();t>='0'&&t<='9';t=P(),u*=0.1)x+=u*(t-'0');}if(f)x=-x
#define RU x=0;char t=P();while(t<'0'||t>'9')t=P();x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define TR *this,x;return x;
I bool IS(char x){return x==10||x==13||x==' ';}template<typename T>struct Fr{T P;I Fr&OP,(int &x)
{RX;if(f)x=-x;RT}I OP int(){int x;TR}I Fr&OP,(ll &x){RX;if(f)x=-x;RT}I OP ll(){ll x;TR}I Fr&OP,(char &x)
{for(x=P();IS(x);x=P());RT}I OP char(){char x;TR}I Fr&OP,(char *x){char t=P();for(;IS(t);t=P());if(~t){
for(;!IS(t)&&~t;t=P())*x++=t;}*x++=0;RT}I Fr&OP,(lf &x){RX;RL;RT}I OP lf(){lf x;TR}I Fr&OP,(llf &x){RX;RL;RT}I OP llf(){llf x;TR}
I Fr&OP,(uint &x){RU;RT}I OP uint(){uint x;TR}I Fr&OP,(ull &x){RU;RT}I OP ull(){ull x;TR}};Fr<Cg>in;
#define WI(S) if(x){if(x<0)P('-'),x=-x;char s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
#define WL if(y){lf t=0.5;for(int i=y;i--;)t*=0.1;if(x>=0)x+=t;else x-=t,P('-');*this,(ll)(abs(x));P('.');if(x<0)x=-x;\
while(y--){x*=10;x-=floor(x*0.1)*10;P(((int)x)%10+'0');}}else if(x>=0)*this,(ll)(x+0.5);else *this,(ll)(x-0.5);
#define WU(S) if(x){char s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}
I Fw&OP()(ull x){WU(20);RT}I Fw&OP,(char x){P(x);RT}I Fw&OP()(char x){P(x);RT}I Fw&OP,(const char *x){while(*x)P(*x++);RT}
I Fw&OP()(const char *x){while(*x)P(*x++);RT}I Fw&OP()(lf x,int y){WL;RT}I Fw&OP()(llf x,int y){WL;RT}};Fw<Cp>out;
int main()
{
std::list<int>s;
int tot=0;
ll n=in;
while(n)
{
if(n&1)
{
tot++;
s.pb(tot);
s.pb(tot);
n--;
}
else
{
tot++;
s.push_front(tot);
s.pb(tot);
n>>=1;
}
}
out,s.size(),'\n';
//foe(i,s)out,*i,' ';out,'\n';
for(auto i:s)out,i,' ';
} | a.cc: In function 'int main()':
a.cc:80:12: error: ambiguous overload for 'operator,' (operand types are 'Fw<Cp>' and 'std::__cxx11::list<int>::size_type' {aka 'long unsigned int'})
80 | out,s.size(),'\n';
| ~~~^~~~~~~~~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(int) [with T = Cp]'
37 | #define OP operator
| ^~~~~~~~
a.cc:53:40: note: in expansion of macro 'OP'
53 | template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(uint) [with T = Cp; uint = unsigned int]'
37 | #define OP operator
| ^~~~~~~~
a.cc:53:93: note: in expansion of macro 'OP'
53 | template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(ll) [with T = Cp; ll = long long int]'
37 | #define OP operator
| ^~~~~~~~
a.cc:54:34: note: in expansion of macro 'OP'
54 | I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(ull) [with T = Cp; ull = long long unsigned int]'
37 | #define OP operator
| ^~~~~~~~
a.cc:54:85: note: in expansion of macro 'OP'
54 | I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(char) [with T = Cp]'
37 | #define OP operator
| ^~~~~~~~
a.cc:55:33: note: in expansion of macro 'OP'
55 | I Fw&OP()(ull x){WU(20);RT}I Fw&OP,(char x){P(x);RT}I Fw&OP()(char x){P(x);RT}I Fw&OP,(const char *x){while(*x)P(*x++);RT}
| ^~
|
s563809744 | p03769 | C++ | #define _GLIBCXX_IOSTREAM
#include<bits/stdc++.h>
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double llf;
typedef std::pair<int,int> pii;
#define xx first
#define yy second
template<typename T> inline T max(T a,T b){return a>b?a:b;}
template<typename T> inline T min(T a,T b){return a<b?a:b;}
template<typename T> inline T abs(T a){return a>0?a:-a;}
template<typename T> inline bool repr(T &a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool repl(T &a,T b){return a>b?a=b,1:0;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b){while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
template<typename T> inline T sqr(T x){return x*x;}
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
#define I inline
#define mset(a,b) memset(a,b,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define fo0(i,n) for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define fd0(i,n) for(int i=(n)-1;~i;i--)
#define fd1(i,n) for(int i=n;i;i--)
#define fd(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define foe(i,x)for(__typeof(x.end())i=x.begin();i!=x.end();++i)
struct Cg{I char operator()(){return getchar();}};
struct Cp{I void operator()(char x){putchar(x);}};
#define OP operator
#define RT return *this;
#define RX x=0;char t=P();while((t<'0'||t>'9')&&t!='-')t=P();bool f=0;\
if(t=='-')t=P(),f=1;x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define RL if(t=='.'){lf u=0.1;for(t=P();t>='0'&&t<='9';t=P(),u*=0.1)x+=u*(t-'0');}if(f)x=-x
#define RU x=0;char t=P();while(t<'0'||t>'9')t=P();x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define TR *this,x;return x;
I bool IS(char x){return x==10||x==13||x==' ';}template<typename T>struct Fr{T P;I Fr&OP,(int &x)
{RX;if(f)x=-x;RT}I OP int(){int x;TR}I Fr&OP,(ll &x){RX;if(f)x=-x;RT}I OP ll(){ll x;TR}I Fr&OP,(char &x)
{for(x=P();IS(x);x=P());RT}I OP char(){char x;TR}I Fr&OP,(char *x){char t=P();for(;IS(t);t=P());if(~t){
for(;!IS(t)&&~t;t=P())*x++=t;}*x++=0;RT}I Fr&OP,(lf &x){RX;RL;RT}I OP lf(){lf x;TR}I Fr&OP,(llf &x){RX;RL;RT}I OP llf(){llf x;TR}
I Fr&OP,(uint &x){RU;RT}I OP uint(){uint x;TR}I Fr&OP,(ull &x){RU;RT}I OP ull(){ull x;TR}};Fr<Cg>in;
#define WI(S) if(x){if(x<0)P('-'),x=-x;char s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
#define WL if(y){lf t=0.5;for(int i=y;i--;)t*=0.1;if(x>=0)x+=t;else x-=t,P('-');*this,(ll)(abs(x));P('.');if(x<0)x=-x;\
while(y--){x*=10;x-=floor(x*0.1)*10;P(((int)x)%10+'0');}}else if(x>=0)*this,(ll)(x+0.5);else *this,(ll)(x-0.5);
#define WU(S) if(x){char s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}
I Fw&OP()(ull x){WU(20);RT}I Fw&OP,(char x){P(x);RT}I Fw&OP()(char x){P(x);RT}I Fw&OP,(const char *x){while(*x)P(*x++);RT}
I Fw&OP()(const char *x){while(*x)P(*x++);RT}I Fw&OP()(lf x,int y){WL;RT}I Fw&OP()(llf x,int y){WL;RT}};Fw<Cp>out;
int main()
{
std::list<int>s;
int tot=0;
ll n=in;
while(n)
{
if(n&1)
{
tot++;
s.pb(tot);
s.pb(tot);
n--;
}
else
{
tot++;
s.push_front(tot);
s.pb(tot);
n>>=1;
}
}
out,s.size(),'\n';
foe(i,s)out,*i,' ';out,'\n';
} | a.cc: In function 'int main()':
a.cc:80:12: error: ambiguous overload for 'operator,' (operand types are 'Fw<Cp>' and 'std::__cxx11::list<int>::size_type' {aka 'long unsigned int'})
80 | out,s.size(),'\n';
| ~~~^~~~~~~~~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(int) [with T = Cp]'
37 | #define OP operator
| ^~~~~~~~
a.cc:53:40: note: in expansion of macro 'OP'
53 | template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(uint) [with T = Cp; uint = unsigned int]'
37 | #define OP operator
| ^~~~~~~~
a.cc:53:93: note: in expansion of macro 'OP'
53 | template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(ll) [with T = Cp; ll = long long int]'
37 | #define OP operator
| ^~~~~~~~
a.cc:54:34: note: in expansion of macro 'OP'
54 | I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(ull) [with T = Cp; ull = long long unsigned int]'
37 | #define OP operator
| ^~~~~~~~
a.cc:54:85: note: in expansion of macro 'OP'
54 | I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}
| ^~
a.cc:37:12: note: candidate: 'Fw<T>& Fw<T>::operator,(char) [with T = Cp]'
37 | #define OP operator
| ^~~~~~~~
a.cc:55:33: note: in expansion of macro 'OP'
55 | I Fw&OP()(ull x){WU(20);RT}I Fw&OP,(char x){P(x);RT}I Fw&OP()(char x){P(x);RT}I Fw&OP,(const char *x){while(*x)P(*x++);RT}
| ^~
|
s834570585 | p03770 | C++ | #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
template <class Arg1, class... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* sep = strchr(names + 1, ',');
cerr.write(names, sep - names) << " : " << arg1 << " ";
__f(sep + 1, args...);
}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
#define pb push_back
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001
const ll mod=1e9+7;
const ll inf=1e18+2;
#define int ll
int n;
int c[maxn];
int w[maxn];
int x,y;
ll pwr(ll base, ll expo)
{
ll res=1;
while(expo>0)
{
if(expo&1) res=(res*base)%mod;
base=(base*base)%mod;
expo>>=1;
}
return res;
}
int fact[maxn];
int inv[maxn];
int par[maxn];
int size[maxn];
int find(int x)
{
if(par[x]==x) return par[x];
return par[x]=find(par[x]);
}
void merge(int x,int y)
{
int parx=find(x);
int pary=find(y);
if(pary==parx) return;
if(size[parx]>=size[pary])
{
size[parx]+=size[pary];
par[pary]=parx;
return;
}
size[pary]+=size[parx];
par[parx]=pary;
}
int par2[maxn];
int size2[maxn];
int find2(int x)
{
if(par2[x]==x) return par2[x];
return par2[x]=find2(par2[x]);
}
void merge2(int x,int y)
{
int par2x=find2(x);
int par2y=find2(y);
if(par2y==par2x) return;
if(size2[par2x]>=size2[par2y])
{
size2[par2x]+=size2[par2y];
par2[par2y]=par2x;
return;
}
size2[par2y]+=size2[par2x];
par2[par2x]=par2y;
}
std::vector<pair<int,int> > weights[maxn];
int mn_wt[maxn];
int mn_ix[maxn];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
fact[0]=1;
inv[0]=1;
for(int i=1;i<maxn;i++)
{
fact[i]=(i*fact[i-1])%mod;
inv[i]=(inv[i-1]*pwr(i,mod-2))%mod;
}
for(int i=0;i<maxn;i++) {par[i]=i;size[i]=1;mn_wt[i]=(ll)1e10;}
for(int i=0;i<maxn;i++) {par2[i]=i;size2[i]=1;mn_wt[i]=(ll)1e10;}
cin>>n>>x>>y;
for(int i=0;i<n;i++)
{
cin>>c[i]>>w[i];
weights[c[i]].pb({w[i],i});
if(w[i]<mn_wt[c[i]])
{
mn_wt[c[i]]=w[i];
mn_ix[c[i]]=i;
}
}
set<pair<int,int>> st;
for(int i=0;i<maxn;i++)
{
if(mn_wt[i]<(ll)5e9)
{
st.insert({mn_wt[i],mn_ix[i]});
// trace(mn_wt[i],mn_ix[i],i);
}
}
for(int i=1;i<maxn;i++)
{
if(weights[i].size())
{
sort(weights[i].begin(), weights[i].end());
for(int j=weights[i].size()-1;j>0;j--)
{
// trace(i);
if(weights[i][j].fi+weights[i][0].fi<=x)
{
// trace(weights[i][j].fi,weights[i][0].fi);
merge2(weights[i][j].se,weights[i][0].se);
merge(weights[i][j].se,weights[i][0].se);
}
}
if(st.size())
{
int mn_now=(*st.begin()).fi;
int mn_indx=(*st.begin()).se;
for(int j=weights[i].size()-1;j>=0;j--)
{
if(weights[i][j].fi+mn_now<=y)
{
// trace(weights[i][j].se,mn_indx,mn_now);
merge(weights[i][j].se,mn_indx);
}
}
}
st.insert({mn_wt[i],mn_ix[i]});
}
}
bool vis[n];
initialise(vis,0);
int ans=1;
for(int i=0;i<n;i++)
{
if(vis[find(i)]==0)
{
// trace(i);
vis[find(i)]=1;
ans*=fact[size[find(i)]];
ans%=mod;
}
}
// trace(ans);
for(int i=1;i<maxn;i++)
{
if(weights[i].size()>1)
{
for(int j=weights[i].size()-1;j>0;j--)
{
if(find(weights[i][j].se)==find(weights[i][0].se))
{
merge2(weights[i][j].se,weights[i][0].se);
}
}
}
}
initialise(vis,0);
for(int i=0;i<n;i++)
{
if(vis[find2(i)]==0)
{
vis[find2(i)]=1;
ans*=inv[size2[find2(i)]];
ans%=mod;
}
}
cout<<ans<<'\n';
return 0;
} | a.cc: In function 'void merge(ll, ll)':
a.cc:92:12: error: reference to 'size' is ambiguous
92 | if(size[parx]>=size[pary])
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
a.cc:92:24: error: reference to 'size' is ambiguous
92 | if(size[parx]>=size[pary])
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
a.cc:94:17: error: reference to 'size' is ambiguous
94 | size[parx]+=size[pary];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
a.cc:94:29: error: reference to 'size' is ambiguous
94 | size[parx]+=size[pary];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
a.cc:98:9: error: reference to 'size' is ambiguous
98 | size[pary]+=size[parx];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
a.cc:98:21: error: reference to 'size' is ambiguous
98 | size[pary]+=size[parx];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:154:43: error: reference to 'size' is ambiguous
154 | for(int i=0;i<maxn;i++) {par[i]=i;size[i]=1;mn_wt[i]=(ll)1e10;}
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
a.cc:230:35: error: reference to 'size' is ambiguous
230 | ans*=fact[size[find(i)]];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:78:5: note: 'll size [200005]'
78 | int size[maxn];
| ^~~~
|
s873565861 | p03770 | C++ | 21 77 68
16 73
16 99
19 66
2 87
2 16
7 17
10 36
10 68
2 38
10 74
13 55
21 21
3 7
12 41
13 88
18 6
2 12
13 87
1 9
2 27
13 15 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 21 77 68
| ^~
|
s150024962 | p03770 | C++ | #include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+1000,mod=1e9+7;
vector <int> g[N];
pii b[N];
vector <pair <pii,int> > a[N],q;
ll power(ll n,ll k){
if (k==0) return 1;
if (k%2==1){
ll x=power(n,k/2);
return x*x%mod*n%mod;
}
ll x=power(n,k/2);
return x*x%mod;
}
ll fac[N];
ll cnt[N];
ll vis[N];
vector <int> ras;
ll dfs(ll v){
vis[v]=1;
ras.pb(v);
cnt[b[v].S]++;
for (int i=0;i<g[v].size();i++){
ll u=g[v][i];
if (vis[u]) continue;
dfs(u);
}
}
int32_t main(){
fac[0]=1;
for (int i=1;i<N;i++){
fac[i]=fac[i-1]*i%mod;
}
ll n,x,y;
cin >> n >> x >> y;
for (int i=1;i<=n;i++){
cin >> b[i].S >> b[i].F;
q.pb({b[i],i});
a[b[i].S].pb({b[i],i});
}
sort(q.begin(),q.end());
ll o=-1;
ll y=-1;
// if (y<x) cout << 1/0;
for (int i=1;i<q.size();i++){
if (q[i].F.F+q[0].F.F<=y && q[0].F.S!=q[i].F.S){
g[q[i].S].pb(q[0].S);
g[q[0].S].pb(q[i].S);
}
if (q[0].F.S!=q[i].F.S && o==-1){
o=i;
continue;
}
if (o!=-1 && q[i].F.F+q[o].F.F<=y && q[o].F.S!=q[i].F.S){
g[q[i].S].pb(q[o].S);
g[q[o].S].pb(q[i].S);
}
}
for (int i=1;i<q.size();i++){
if (q[i].F.F+q[0].F.F<=y && q[0].F.S!=q[i].F.S){
g[q[i].S].pb(q[0].S);
g[q[0].S].pb(q[i].S);
}
if (q[0].F.S!=q[i].F.S && o==-1){
o=i;
continue;
}
if (o!=-1 && q[i].F.F+q[o].F.F<=y && q[o].F.S!=q[i].F.S){
g[q[i].S].pb(q[o].S);
g[q[o].S].pb(q[i].S);
}
}
for (int i=0;i<N;i++){
sort(a[i].begin(),a[i].end());
for (int j=1;j<a[i].size();j++){
if (a[i][j].F.F+a[i][0].F.F<=x){
g[a[i][j].S].pb(a[i][0].S);
g[a[i][0].S].pb(a[i][j].S);
}
}
}
ll ans=1;
for (int i=1;i<=n;i++){
if (vis[i]) continue;
dfs(i);
ll z=ras.size();
ans*=fac[z];
ans%=mod;
for (int j=0;j<ras.size();j++){
ll v=ras[j];
ll z=cnt[b[v].S];
cnt[b[v].S]--;
ans*=power(z,mod-2);
ans%=mod;
}
ras.clear();
}
cout << ans << endl;
}
| a.cc: In function 'll dfs(ll)':
a.cc:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
43 | }
| ^
a.cc: In function 'int32_t main()':
a.cc:58:8: error: redeclaration of 'll y'
58 | ll y=-1;
| ^
a.cc:49:12: note: 'll y' previously declared here
49 | ll n,x,y;
| ^
|
s875982293 | p03770 | C++ | #include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+1000,mod=1e9+7;
vector <int> g[N];
pii b[N];
vector <pair <pii,int> > a[N],q;
ll power(ll n,ll k){
if (k==0) return 1;
if (k%2==1){
ll x=power(n,k/2);
return x*x%mod*n%mod;
}
ll x=power(n,k/2);
return x*x%mod;
}
ll fac[N];
ll cnt[N];
ll vis[N];
vector <int> ras;
ll dfs(ll v){
vis[v]=1;
ras.pb(v);
cnt[b[v].S]++;
for (int i=0;i<g[v].size();i++){
ll u=g[v][i];
if (vis[u]) continue;
dfs(u);
}
}
int32_t main(){
fac[0]=1;
for (int i=1;i<N;i++){
fac[i]=fac[i-1]*i%mod;
}
ll n,x,y;
cin >> n >> x >> y;
for (int i=1;i<=n;i++){
cin >> b[i].S >> b[i].F;
q.pb({b[i],i});
a[b[i].S].pb({b[i],i});
}
sort(q.begin(),q.end());
for (int i=1;i<q.size();i++){
if (q[i].F.F+q[0].F.F<=y && q[0].F.S!=q[i].F.S){
g[q[i].S].pb(q[0].S);
g[q[0].S].pb(q[i].S);
}
if (q[0].F.S!=q[i].F.S && o==-1){
o=i;
}
if (o!=0 && q[i].F.F+q[o].F.F<=y && q[o].F.S!=q[i].F.S){
g[q[i].S].pb(q[o].S);
g[q[o].S].pb(q[i].S);
}
}
for (int i=0;i<N;i++){
sort(a[i].begin(),a[i].end());
for (int j=1;j<a[i].size();j++){
if (a[i][j].F.F+a[i][0].F.F<=x){
g[a[i][j].S].pb(a[i][0].S);
g[a[i][0].S].pb(a[i][j].S);
}
}
}
ll ans=1;
for (int i=1;i<=n;i++){
if (vis[i]) continue;
dfs(i);
ll z=ras.size();
ans*=fac[z];
ans%=mod;
for (int j=0;j<ras.size();j++){
ll v=ras[j];
ll z=cnt[b[v].S];
cnt[b[v].S]--;
ans*=power(z,mod-2);
ans%=mod;
}
ras.clear();
}
cout << ans << endl;
}
| a.cc: In function 'll dfs(ll)':
a.cc:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
43 | }
| ^
a.cc: In function 'int32_t main()':
a.cc:62:35: error: 'o' was not declared in this scope
62 | if (q[0].F.S!=q[i].F.S && o==-1){
| ^
a.cc:65:13: error: 'o' was not declared in this scope
65 | if (o!=0 && q[i].F.F+q[o].F.F<=y && q[o].F.S!=q[i].F.S){
| ^
|
s746129573 | p03770 | C++ | #include<bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
ll gi(){
ll x=0,f=1;
char ch=getchar();
while(!isdigit(ch))f^=ch=='-',ch=getchar();
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return f?x:-x;
}
int pow(int x,int y){
int ret=1;
while(y){
if(y&1)ret=1ll*ret*x%mod;
x=1ll*x*x%mod;y>>=1;
}
return ret;
}
int fact[200010],ifact[200010],c[200010],w[200010],mnw[200010],cnt[200010],p[200010];
int main(){
#ifdef XZZSB
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
int n=gi(),X=gi(),Y=gi(),ans=1;
fact[0]=1;for(int i=1;i<=n;++i)fact[i]=1ll*fact[i-1]*i%mod;
ifact[n]=pow(fact[n],mod-2);for(int i=n;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
for(int i=0;i<=n;++i)mnw[i]=1e9;
for(int i=1;i<=n;++i)c[i]=gi(),w[i]=gi(),mnw[c[i]]=std::min(mnw[c[i]],w[i]);
for(int i=1;i<=n;++i)
if(mnw[c[i]]+w[i]<=X)w[i]=mnw[c[i]],++cnt[c[i]];
else if(w[i]==mnw[c[i]])++cnt[c[i]]
int mn=0,cmn=0;
for(int i=1;i<=n;++i){
if(mnw[mn]>mnw[i])cmn=mn,mn=i;
else if(mnw[cmn]>mnw[i])cmn=i;
}
int sz=cnt[mn];
for(int i=1;i<=n;++i)if(c[i]!=mn&&mnw[mn]+w[i]<=Y)++sz,++p[c[i]];
if(sz==cnt[mn])return puts("1"),0;
for(int i=1;i<=n;++i)if(c[i]==mn&&w[i]!=mnw[mn]&&mnw[cmn]+w[i]<=Y)++sz,++p[c[i]];
p[mn]+=cnt[mn];
ans=fact[sz];
for(int i=1;i<=n;++i)ans=1ll*ans*ifact[p[i]]%mod;
printf("%d\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:32:52: error: expected ';' before 'int'
32 | else if(w[i]==mnw[c[i]])++cnt[c[i]]
| ^
| ;
33 | int mn=0,cmn=0;
| ~~~
a.cc:35:24: error: 'mn' was not declared in this scope; did you mean 'n'?
35 | if(mnw[mn]>mnw[i])cmn=mn,mn=i;
| ^~
| n
a.cc:35:35: error: 'cmn' was not declared in this scope
35 | if(mnw[mn]>mnw[i])cmn=mn,mn=i;
| ^~~
a.cc:36:29: error: 'cmn' was not declared in this scope
36 | else if(mnw[cmn]>mnw[i])cmn=i;
| ^~~
a.cc:38:20: error: 'mn' was not declared in this scope; did you mean 'n'?
38 | int sz=cnt[mn];
| ^~
| n
a.cc:41:62: error: 'cmn' was not declared in this scope
41 | for(int i=1;i<=n;++i)if(c[i]==mn&&w[i]!=mnw[mn]&&mnw[cmn]+w[i]<=Y)++sz,++p[c[i]];
| ^~~
|
s404133805 | p03770 | C | #include <iostream>
#include <cstring>
using namespace std;
typedef long long LL;
const int maxn = 1000005;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
int n, A, B;
int fac[maxn], inv[maxn];
int c[maxn], w[maxn], minci[maxn];
int Gs[maxn];
inline int pow(int a, int b)
{
int ans = 1;
for(; b; b >>= 1, a = (LL) a * a % mod)
if(b & 1)
ans = (LL) ans * a % mod;
return ans;
}
inline int C(int n, int m)
{
if(!n)
return 1;
if(m < n)
return 0;
return (LL) fac[m] * (LL) inv[m - n] % mod * (LL) inv[n] % mod;
}
int main()
{
scanf("%d%d%d", &n, &A, &B);
memset(minci, 0x3f, sizeof(minci));
for(int i = 1; i <= n; ++i)
{
scanf("%d%d", &c[i], &w[i]);
minci[c[i]] = min(minci[c[i]], w[i]);
}
int minn = 0, minnn = 0;
for(int i = 1; i <= n; ++i)
{
if(minci[i] < minci[minn])
{
minnn = minn;
minn = i;
}
else if(minci[i] < minci[minnn])
minnn = i;
}
int gss = 0;
for(int i = 1; i <= n; ++i)
{
if(w[i] + minci[c[i]] <= A)
w[i] = minci[c[i]];
if(c[i] == minn && minci[minnn] + w[i] <= B)
{
Gs[c[i]]++;
gss++;
}
if(c[i] != minn && minci[minn] + w[i] <= B)
{
Gs[c[i]]++;
gss++;
}
}
int ans = 1;
fac[0] = 1;
for(int i = 1; i <= n; ++i)
fac[i] = (LL) i * fac[i - 1] % mod;
inv[n] = pow(fac[n], mod - 2);
for(int i = n - 1; ~i; --i)
inv[i] = (LL) inv[i + 1] * (i + 1) % mod;
for(int i = 1; i <= n; ++i)
{
if(Gs[i])
{
ans = (LL) ans * (LL) C(Gs[i], gss) % mod;
gss -= Gs[i];
}
}
printf("%d\n", ans);
return 0;
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s869720792 | p03770 | C++ | #include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;
typedef long long ll;
int add(int a, int b)
{
ll x = a+b;
if(x >= mod)
x -= mod;
if(x < 0)
x += mod;
return x;
}
ll mul(ll a, ll b)
{
return (a*b) % mod;
}
ll pw(ll a, ll b)
{
ll ans = 1;
while(b)
{
if(b & 1)
ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}
int n, x, y;
pair<int, int> p[200002];
vector<int>cols[200002];
vector<int>v[200002];
ll fact[200002], inv[200002];
bool cmp(int a, int b)
{
return p[a].se < p[b].se;
}
bool viz[200002];
bool is[200002];
int fr[200002], nr;
vector<int>col;
void dfs(int nod)
{
if(fr[p[nod].fi] == 0)
col.pb(p[nod].fi);
++fr[p[nod].fi];
++nr;
viz[nod] = 1;
for(int i = 0; i < v[nod].size(); ++i)
{
int vecin = v[nod][i];
if(!viz[vecin])
dfs(vecin);
}
}
ll sol(int start_point)
{
ll ans = 1;
nr = 0;
col.clear();
dfs(start_point);
ans = fact[nr];
// cout << ans << " " << start_point << " " << nr << '\n';
for(int i = 0; i < col.size(); ++i)
{
// cout << col[i] << " " << fr[col[i]] << '\n';
ans = mul(ans, inv[fr[col[i]]]), fr[col[i]] = 0;
// cout << ans << '\n';
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> x >> y;
for(int i = 1; i <= n; ++i)
{
cin >> p[i].fi >> p[i].se;
cols[p[i].fi].pb(i);
}
fact[0] = inv[0] = 1;
for(int i = 1; i <= n; ++i)
{
fact[i] = mul(fact[i-1], i);
inv[i] = pw(fact[i], mod - 2);
}
// build edges from nodes with same color
for(int i = 1; i <= n; ++i)
{
sort(cols[i].begin(), cols[i].end(), cmp);
int pz = 1;
while(pz < cols[i].size() && p[cols[i][0]].se + p[cols[i][pz]].se <= x)
{
v[cols[i][0]].pb(cols[i][pz]);
v[cols[i][pz]].pb(cols[i][0]);
++pz;
}
}
// build edges from nodes with different color
vector<int>mv;
for(int i = 1; i <= n; ++i)
mv.pb(i);
sort(mv.begin(), mv.end(), cmp);
for(int i = 0; i < (int)mv.size(); ++i)
{
if(viz[p[mv[i]].fi])
continue;
viz[p[mv[i]].fi] = 1;
for(int j = i+1; j < mv.size(); ++j)
if(p[mv[i]].fi != p[mv[j]].fi && p[mv[i]].se + p[mv[j]].se <= y)
{
v[mv[i]].pb(mv[j]);
v[mv[j]].pb(mv[i]);
--rms;
}
if(rms <= 0)
break;
}
memset(viz, 0, sizeof(viz));
ll ans = 1;
for(int i = 1; i <= n; ++i)
if(!viz[i])
ans = mul(ans, sol(i));
cout << ans;
return 0;
}
| a.cc: In function 'int main()':
a.cc:135:19: error: 'rms' was not declared in this scope
135 | --rms;
| ^~~
a.cc:137:12: error: 'rms' was not declared in this scope
137 | if(rms <= 0)
| ^~~
|
s692307168 | p03770 | C++ | #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef pair <int, int> pr;
const int N = 2e5 + 10;
const int INF = 2e9;
const LL mod = 1e9 + 7;
inline LL power(LL a, LL n, LL mod)
{
LL Ans = 1;
while (n)
{
if (n & 1) Ans = Ans * a % mod;
a = a * a % mod;
n >>= 1;
}
return Ans;
}
namespace ufs
{
int parent[N];
void init(int n) { for (int i = 1; i <= n; i++) parent[i] = i; }
inline int findrt(int x) { return parent[x] == x ? x : parent[x] = findrt(parent[x]); }
void merge(int x, int y)
{
x = findrt(x), y = findrt(y);
parent[x] = y;
}
}
int col[N], w[N];
int n, X, Y;
pr minv[N];
vector <int> vec[N];
int cnt[N];
LL fac[N], ifac[N];
inline LL calc(int n, int m) { return n < m ? 0 : fac[n] * ifac[m] % mod * ifac[n-m] % mod; }
int main()
{
cin >> n >> X >> Y;
fac[0] = 1;
for (int i = 1; i <= n; i++) fac[i] = fac[i-1] * i % mod;
ifac[n] = power(fac[n], mod-2, mod);
for (int i = n-1; i >= 0; i--) ifac[i] = ifac[i+1] * (i+1) % mod;
int maxc = 0;
for (int i = 1; i <= n; i++)
{
scanf("%d %d", &col[i], &w[i]);
maxc = max(maxc, col[i]);
}
for (int i = 1; i <= maxc; i++) minv[i] = make_pair(INF, INF);
for (int i = 1; i <= n; i++)
{
minv[col[i]] = make_pair(w[i], i);
vec[col[i]].push_back(i);
}
ufs::init(n);
for (int i = 1; i <= maxc; i++)
{
for (auto id : vec[i])
if (w[id] + minv[i].first <= X)
ufs::merge(id, minv[i].second);
}
pr mn = make_pair(INF, INF), mn2 = make_pair(INF, INF);
for (int i = 1; i <= n; i++)
{
pr tmp = make_pair(w[i], i);
mn = min(mn, tmp);
}
for (int i = 1; i <= n; i++)
{
pr tmp = make_pair(w[i], i);
if (col[i] != col[mn.second])
mn2 = min(mn2, tmp);
}
for (int i = 1; i <= n; i++)
if (col[mn.second] != col[i] && mn.first + w[i] <= Y)
ufs::merge(mn.second, i);
else if (mn2.first != INF && col[mn2.second] != col[i] && mn2.first + w[i] <= Y)
ufs::merge(mn2.second, i);
for (int i = 1; i <= n; i++)
if (ufs::findrt(i) == ufs::findrt(mn.second))
cnt[col[i]]++;
int all = 0;
for (int i = 1; i <= maxc; i++)
all += cnt[i];
LL Ans = 1;
for (int i = 1; i <= maxc; i++)
if (cnt[i])
Ans = Ans * calc(all, cnt[i]) % mod,
all -= cnt[i];
printf("%lld\n", Ans);
return 0;
} | a.cc:57:1: error: 'vector' does not name a type
57 | vector <int> vec[N];
| ^~~~~~
a.cc: In function 'int main()':
a.cc:86:17: error: 'vec' was not declared in this scope
86 | vec[col[i]].push_back(i);
| ^~~
a.cc:93:32: error: 'vec' was not declared in this scope
93 | for (auto id : vec[i])
| ^~~
|
s468503195 | p03770 | C++ | #include <bits/stdc++.h>
#define mod 1000000007ll
#define M 200010
using namespace std;
struct edge
{
int to;
int nxt;
}e[3000010];
int n,minnum,minnum2;
int color[M],dlfl[M],pos[M],vis[M];
long long val[M],minn[M];
long long fac[M],rfac[M];
long long X,Y;
int head[M],cnt;
void addedge(int x,int y)
{
e[++cnt].nxt = head[x];
e[cnt].to = y;
head[x] = cnt;
}
void add(int x,int y)
{
addedge(x,y);
addedge(y,x);
}
long long qpow(long long a,long long b)
{
long long ans = 1,res = a;
while(b)
{
if(b&1)ans = (ans * res) % mod;
res *= res;
res %= mod;
b >>= 1;
}
return ans;
}
long long C(long long n,long long k)
{
return fac[n] * rfac[k] % mod * rfac[n - k] % mod;
}
void init()
{
fac[0] = 1;
for(int i = 1;i <= n;i++)fac[i] = (i * fac[i - 1]) % mod;
rfac[n] = qpow(fac[n],mod - 2);
for(int i = n; i > 0; i--)rfac[i - 1] = (i * rfac[i]) % mod;
}
void dfs(int x)
{
vis[x] = 1;
for(int i = head[x]; i; i = e[i].nxt)
{
if(!vis[e[i].to])dfs(e[i].to);
}
}
void find()
{
for(int i = 1; i <= n; i++)
{
if(val[i] < min1)
{
min1 = val[i];
minnum = i;
}
}
for(int i = 1; i <= n; i++)
{
if(val[i] <= min2 && color[i] != color[minnum])
{
min2 = val[i];
minnum2 = i;
}
}
}
int main()
{
scanf("%d%lld%lld",&n,&X,&Y);
init();
for(int i = 1;i <= n;i++)minn[i] = 2147483647ll;
for(int i = 1;i <= n;i++)scanf("%d%lld",&color[i],&val[i]);
for(int i = 1;i <= n;i++)
{
if(val[i] < minn[color[i]])
{
minn[color[i]] = val[i];
pos[color[i]] = i;
}
}
for(int i = 1; i <= n; i++)
{
if(i != pos[color[i]] && val[i] + minn[color[i]] <= X)
{
add(i,pos[color[i]]);
}
}
long long min1 = 2147483647ll,min2 = 2147483647ll;
find();
for(int i = 1; i <= n; i++)
{
if(i != minnum)
{
if(color[i] != color[minnum] && val[i] + val[minnum] <= Y)
{
add(i,minnum);
}
if(minnum2 && color[i] != color[minnum2] && val[i] + val[minnum2] <= Y)
{
add(i,minnum2);
}
}
}
dfs(minnum);
long long fldl = 0;
for(int i = 1; i <= n; i++)
{
if(vis[i])
{
dlfl[color[i]]++;
}
}
for(int i = 1;i <= n;i++)fldl += dlfl[i];
long long ans = 1;
for(int i = 1; i <= n; i++)
{
if(dlfl[i])
{
ans *= C(fldl,dlfl[i]);
ans %= mod;
fldl -= dlfl[i];
}
}
printf("%lld",ans);
return 0;
} | a.cc: In function 'void find()':
a.cc:62:29: error: 'min1' was not declared in this scope; did you mean 'minn'?
62 | if(val[i] < min1)
| ^~~~
| minn
a.cc:70:30: error: 'min2' was not declared in this scope; did you mean 'minn'?
70 | if(val[i] <= min2 && color[i] != color[minnum])
| ^~~~
| minn
|
s760051986 | p03770 | C++ | #include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).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 INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli;
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
int src, dst;
Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll X,Y;
vector<pair<int, ll> > data2;
struct UnionFind {
vector<int> data;
void init(int n) { data.assign(n, -1); }
bool unionSet(int x, int y) {
x = root(x); y = root(y);
if(x != y) {
if(data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
}uf;
ll bik[214514];
ll bikinv[214514];
ll gcd(ll a, ll b) {
return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
ll g = a; x = 1; y = 0;
if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
return g;
}
ll invMod(ll a, ll m) {
ll x, y;
if (extgcd(a, m, x, y) == 1) return (x + m) % m;
else return 0; // unsolvable
}
void bikcal(int NN){
ll hoge=(ll)1;
bik[0]=(ll)1;
bikinv[0]=(ll)1;
for(int i=1;i<=NN;i++){
hoge=(hoge*i)%MOD;
bik[i]=hoge;
bikinv[i]=invMod(bik[i],MOD);
}
}
ll Comb(int a,int b){
ll ret;
ret=(((bik[a]*bikinv[b])%MOD)*bikinv[a-b])%MOD;
return ret;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
if (k == 0) return 1;
if (k % 2 == 0) return powMod(x*x % m, k/2, m);
else return x*powMod(x, k-1, m) % m;
}
bool used[214514];
vi colp[214514];
int minmemo[214514];
int main(){
cin>>N>>X>>Y;
uf.init(N);
bikcal(N+1);
rep(i,N)used[i]=false;
rep(i,N){
ll c,w;
cin>>c>>w;c--;
data2.pb(mp(w,c));
}
sort(all(data2));
ll cos0=data2[0].first;
int col0=data2[0].second;
int col2;
int col2za=N+1;
int num=0;
rep(i,N){
int col=data2[i].escond;
if(!used[col]){
used[col]=true;
minmemo[col]=data2[i].first;
num++;
if(col!=col0&&col2za==N+1){
col2=col;
col2za=i;
}
}
colp[col].pb(i);
}
rep(col,N){
if(used[col]){
rep(j,colp[col].size()){
int now=colp[col][j];
if(data2[now].first+minmemo[col]<=X)uf.unionSet(now,colp[col][0]);
}
}
}
if(num>1){
rep(col,N){
if(used[col]){
rep(j,colp[col].size()){
int now=colp[col][j];
ll cos = data2[now].first;
if(col==col0){
if(cos+minmemo[col2]<=Y)uf.unionSet(now,col2za);
}else{
if(cos+minmemo[col0]<=Y)uf.unionSet(now,0);
}
}
}
}
}
vi roots[214514];
rep(i,N){
roots[uf.root(i)].pb(i);
}
/*cout<<endl;
rep(i,N){
cout<<data2[i].first<<" "<<data2[i].second<<endl;
}*/
/*rep(i,N){
rep(j,roots[i].size()){
cout<<roots[i][j]<<" ";
}
cout<<endl;
}*/
ll ans=1;
rep(i,N){
if(uf.root(i)==i){
map<int,int> cnts;
rep(j,roots[i].size()){
int now=roots[i][j];
cnts[data2[now].second]++;
//cout<<data2[now].second<<" ";
}
ll temp=bik[roots[i].size()];
for(auto i=cnts.begin();i!=cnts.end();++i){
temp*=bikinv[i->second];
temp%=MOD;
//cout<<(i->first)<<" "<<(i->second)<<endl;
}
ans*=temp;
ans%=MOD;
//cout<<ans<<endl;
}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:150:34: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, long long int> >, std::pair<int, long long int> >::value_type' {aka 'struct std::pair<int, long long int>'} has no member named 'escond'; did you mean 'second'?
150 | int col=data2[i].escond;
| ^~~~~~
| second
|
s620015817 | p03770 | C++ | #include <bits/stdc++.h>
inline int read() {
int ret, cc;
while (!isdigit(cc = getchar()));
ret = cc - 48;
while ( isdigit(cc = getchar()))
ret = cc - 48 + ret * 10;
return ret;
}
const int MOD = 1000000007;
inline int add(int a, int b) { return (a += b) >= MOD ? a - MOD : a; }
inline int sub(int a, int b) { return (a -= b) < 0 ? a + MOD : a; }
inline int mul(int a, int b) { return 1ll * a * b % MOD; }
inline int qpow(int a, int p) {
int ret = 1;
for (; p; p >>= 1, a = mul(a, a))
if (p & 1) ret = mul(ret, a);
return ret;
}
const int MAXN = 200010;
int fac[MAXN];
int inv[MAXN];
int col[MAXN];
int val[MAXN];
std::vector<int> node[MAXN];
int ans[MAXN];
int root[MAXN];
int n, X, Y;
int main() {
#ifdef ARK
freopen("test.in", "r", stdin);
#endif
n = read(), X = read(), Y = read();
val[0] = 0x3f3f3f3f;
for (int i = 1; i <= n; ++i) {
size[i] = 1, pa[i] = i;
col[i] = read(), val[i] = read();
if (val[i] < val[root[col[i]]])
root[col[i]] = i;
if (val[i] < val[root[0]])
root[0] = i;
node[col[i]].push_back(i);
}
for (int i = 1; i <= n; ++i) {
if (root[i] != root[0]) {
int cnt = 1;
for (auto x : node[i]) if (x != root[i]) {
if (val[x] + val[root[i]] <= X) cnt++;
else if (val[x] + val[root[0]] <= Y) ans[i]++;
}
if (val[root[i]] + val[root[0]] <= Y) ans[i] += cnt;
} else {
ans[i] = 1;
for (auto x : node[i]) if (x != root[i]) {
if (val[x] + val[root[i]] <= X) ans[i]++;
}
}
}
fac[0] = 1;
for (int i = 1; i <= n; ++i) fac[i] = mul(fac[i - 1], i);
inv[n] = qpow(fac[n], MOD - 2);
for (int i = n; i >= 1; --i) inv[i - 1] = mul(inv[i], i);
int res1 = 1, res2 = 0;
for (int i = 1; i <= n; ++i)
res1 = mul(res1, inv[ans[i]]), res2 += ans[i];
printf("%d\n", mul(fac[res2], res1));
}
| a.cc: In function 'int main()':
a.cc:43:17: error: 'size' was not declared in this scope; did you mean 'std::size'?
43 | size[i] = 1, pa[i] = i;
| ^~~~
| std::size
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: 'std::size' declared here
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
a.cc:43:30: error: 'pa' was not declared in this scope
43 | size[i] = 1, pa[i] = i;
| ^~
|
s870287509 | p03770 | C++ | #include <bits/stdc++.h>
inline int read() {
int ret, cc;
while (!isdigit(cc = getchar()));
ret = cc - 48;
while ( isdigit(cc = getchar()))
ret = cc - 48 + ret * 10;
return ret;
}
const int MOD = 1000000007;
inline int add(int a, int b) { return (a += b) >= MOD ? a - MOD : a; }
inline int sub(int a, int b) { return (a -= b) < 0 ? a + MOD : a; }
inline int mul(int a, int b) { return 1ll * a * b % MOD; }
inline int qpow(int a, int p) {
int ret = 1;
for (; p; p >>= 1, a = mul(a, a))
if (p & 1) ret = mul(ret, a);
return ret;
}
const int MAXN = 200010;
int fac[MAXN];
int inv[MAXN];
int col[MAXN];
int val[MAXN];
std::vector<int> node[MAXN];
int ans[MAXN];
int root[MAXN];
int n, X, Y;
int main() {
#ifdef ARK
freopen("test.in", "r", stdin);
#endif
n = read(), X = read(), Y = read();
val[0] = 0x3f3f3f3f;
for (int i = 1; i <= n; ++i) {
size[i] = 1, pa[i] = i;
col[i] = read(), val[i] = read();
if (val[i] < val[root[col[i]]])
root[col[i]] = i;
if (val[i] < val[root[0]])
root[0] = i;
node[col[i]].push_back(i);
}
for (int i = 1; i <= n; ++i) {
if (root[i] != root[0]) {
int cnt = 1;
for (auto x : node[i]) if (x != root[i]) {
if (val[x] + val[root[i]] <= X) cnt++;
else if (val[x] + val[root[0]] <= Y) ans[i]++;
}
if (val[root[i]] + val[root[0]] <= Y) ans[i] += cnt;
} else {
ans[i] = 1;
for (auto x : node[i]) if (x != root[i]) {
if (val[x] + val[root[i]] <= X) ans[i]++;
}
}
}
fac[0] = 1;
for (int i = 1; i <= n; ++i) fac[i] = mul(fac[i - 1], i);
inv[n] = qpow(fac[n], MOD - 2);
for (int i = n; i >= 1; --i) inv[i - 1] = mul(inv[i], i);
int res1 = 1, res2 = 0;
for (int i = 1; i <= n; ++i)
res1 = mul(res1, inv[ans[i]]), res2 += ans[i];
printf("%d\n", mul(fac[res2], res1));
}
| a.cc: In function 'int main()':
a.cc:43:17: error: 'size' was not declared in this scope; did you mean 'std::size'?
43 | size[i] = 1, pa[i] = i;
| ^~~~
| std::size
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: 'std::size' declared here
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
a.cc:43:30: error: 'pa' was not declared in this scope
43 | size[i] = 1, pa[i] = i;
| ^~
|
s789819432 | p03770 | C++ | // warm heart, wagging tail,and a smile just for you!
// ███████████
// ███╬╬╬╬╬╬╬╬╬╬███
// ███╬╬╬╬╬████╬╬╬╬╬╬███
// ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
// █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
// ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
// ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
// ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
// █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
// ███████ █████ ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
const int NMAX = 1e6;
vector<int> child,tree(NMAX);
int root(int i){
if(i == tree[i]){
REP(j,child.size()) tree[child[j]] = i;
child.clear();
return i;
}
else{
child.push_back(i);
return i = root(tree[i]);
}
}
int unit(int x, int y){
x = root(x);
y = root(y);
tree[max(x,y)] = min(x,y);
}
bool isUnit(int x, int y){
return root(x) == root(y);
}
void add(int &a, int b){
a = ((a+b) % MOD + MOD) % MOD;
}
inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
return (int) ((long long) a * b % MOD);
#endif
unsigned long long x = (long long) a * b;
unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
asm(
"divl %4; \n\t"
: "=a" (d), "=d" (m)
: "d" (xh), "a" (xl), "r" (MOD)
);
return m;
}
inline int modpow(int a, long long b) {
int res = 1;
while (b > 0) {
if (b & 1) {
res = mul(res, a);
}
a = mul(a, a);
b >>= 1;
}
return res;
}
inline int inv(int a) {
a %= MOD;
if (a < 0) a += MOD;
int b = MOD, u = 0, v = 1;
while (a) {
int t = b / a;
b -= t * a; swap(a, b);
u -= t * v; swap(u, v);
}
assert(b == 1);
if (u < 0) u += MOD;
return u;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
//問題文を読む時間をケチらない!!
int n,x,y;
cin >> n >> x >> y;
vector<P> color[n];
vector<int> c(n),w(n);
REP(i,n){
cin >> c[i] >> w[i]; c[i]--;
color[c[i]].push_back(P(w[i],i));
}
REP(i,n) sort(color[i].begin(),color[i].end());
REP(i,n) tree[i] = i;
P tmp = P(INF,INF);
REP(i,n){
if(color[i].size() == 0) continue;
tmp = min(tmp,color[i][0]);
FOR(j,1,color[i].size()){
if(color[i][0].fs + color[i][j].fs <= x) unit(color[i][0].sc,color[i][j].sc);
}
}
REP(i,n){
if(c[tmp[i].sc] != c[i] && tmp.fs + w[i] <= y) unit(tmp.sc,i);
}
map<int,int> sum[n];
REP(i,n){
sum[root(i)][c[i]]++;
}
vector<int> fact(n+1,1);
REP(i,n) fact[i+1] = mul(fact[i],i+1);
int ans = 1;
REP(i,n){
int cnt = 0, pos = 1;
ITR(itr,sum[i]){
cnt += itr->sc; //個数
pos = mul(pos,fact[itr->sc]); // 組み合わせ
}
ans = mul(ans,mul(fact[cnt],inv(pos)));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'long long int unit(long long int, long long int)':
a.cc:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
61 | }
| ^
a.cc: In function 'int main()':
a.cc:139:13: error: no match for 'operator[]' (operand types are 'P' {aka 'std::pair<long long int, long long int>'} and 'long long int')
139 | if(c[tmp[i].sc] != c[i] && tmp.fs + w[i] <= y) unit(tmp.sc,i);
| ^
|
s016115327 | p03770 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=2e5+5,pps=1e9+7;
bool vis[maxn];
int n,x,y,tot,ans=1,top;
int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
int sum[maxn],now[maxn],pre[maxn<<2],son[maxn<<2],color[maxn];
int read() {
int x=0,f=1;char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
return x*f;
}
struct Ball {
int c,w,id;
}b[maxn];
int quick(int a,int b) {
int sum=1;
while(b) {
if(b&1)sum=1ll*sum*a%pps;
a=1ll*a*a%pps,b>>=1;
}
return sum;
}
bool cmp1(Ball a,Ball b) {
if(a.c==b.c)return a.w<b.w;
return a.c<b.c;
}
bool cmp2(Ball a,Ball b) {
if(a.w==b.w)return a.c<b.c;
return a.w<b.w;
}
void add(int a,int b) {
pre[++tot]=now[a];
now[a]=tot,son[tot]=b;
}
void work1() {
int lst=0;
for(int i=1;i<=n;i++) {
if(b[i].c!=b[lst].c) {
lst=i;continue;
}
if(b[i].w+b[lst].w<=x) {
add(b[i].id,b[lst].id);
add(b[lst].id,b[i].id);
}
}
}
void work2() {
for(int i=2;i<=n;i++)
if(b[i].c!=b[1].c) {
if(b[i].w+b[1].w>y)break;
add(b[i].id,b[1].id);
add(b[1].id,b[i].id);
}
}
void prepare() {
fac[0]=inv[0]=1;
for(int i=1;i<=n;i++)
fac[i]=1ll*fac[i-1]*i%pps;
inv[n]=quick(fac[n],pps-2);
for(int i=n-1;i;i--)
inv[i]=1ll*inv[i+1]*(i+1)%pps;
}
void dfs(int u) {
vis[u]=1;
int c=color[u];
if(!insta[c]) {
sta[++top]=c;
insta[c]=top;
sum[top]=1;
}
else sum[insta[c]]++;
for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
if(!vis[v])dfs(v);
}
void calc() {
int cnt=0;
while(top) {
ans=1ll*ans*inv[sum[top]]%pps;
cnt+=sum[top],insta[sta[top]]=0,sta[top]=0,sum[top]=0,top--;
}
ans=1ll*ans*fac[cnt]%pps;
}
int main() {
n=read(),x=read(),y=read(),prepare();
for(int i=1;i<=n;i++)
color[i]=b[i].c=read(),b[i].w=read(),b[i].id=i;
sort(b+1,b+n+1,cmp1);work1();
sort(b+1,b+n+1,cmp2);work2();
for(int i=1;i<=n;i++)
if(!vis[i])dfs(i),calc();
printf("%d\n",ans);
return 0;
}
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=2e5+5,pps=1e9+7;
bool vis[maxn];
int n,x,y,tot,ans=1,top;
int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
int sum[maxn],now[maxn],pre[maxn<<3],son[maxn<<3],color[maxn];
int read() {
int x=0,f=1;char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
return x*f;
}
struct Ball {
int c,w,id;
}b[maxn];
int quick(int a,int b) {
int sum=1;
while(b) {
if(b&1)sum=1ll*sum*a%pps;
a=1ll*a*a%pps,b>>=1;
}
return sum;
}
bool cmp1(Ball a,Ball b) {
if(a.c==b.c)return a.w<b.w;
return a.c<b.c;
}
bool cmp2(Ball a,Ball b) {
if(a.w==b.w)return a.c<b.c;
return a.w<b.w;
}
void add(int a,int b) {
pre[++tot]=now[a];
now[a]=tot,son[tot]=b;
}
void work1() {
int lst=0;
for(int i=1;i<=n;i++) {
if(b[i].c!=b[lst].c) {
lst=i;continue;
}
if(b[i].w+b[lst].w<=x) {
add(b[i].id,b[lst].id);
add(b[lst].id,b[i].id);
}
}
}
void work2() {
for(int i=2;i<=n;i++)
if(b[i].c!=b[1].c) {
if(b[i].w+b[1].w>y)break;
add(b[i].id,b[1].id);
add(b[1].id,b[i].id);
}
}
void prepare() {
fac[0]=inv[0]=1;
for(int i=1;i<=n;i++)
fac[i]=1ll*fac[i-1]*i%pps;
inv[n]=quick(fac[n],pps-2);
for(int i=n-1;i;i--)
inv[i]=1ll*inv[i+1]*(i+1)%pps;
}
void dfs(int u) {
vis[u]=1;
int c=color[u];
if(!insta[c]) {
sta[++top]=c;
insta[c]=top;
sum[top]=1;
}
else sum[insta[c]]++;
for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
if(!vis[v])dfs(v);
}
void calc() {
int cnt=0;
while(top) {
ans=1ll*ans*inv[sum[top]]%pps;
cnt+=sum[top],insta[sta[top]]=0,sta[top]=0,sum[top]=0,top--;
}
ans=1ll*ans*fac[cnt]%pps;
}
int main() {
n=read(),x=read(),y=read(),prepare();
for(int i=1;i<=n;i++)
color[i]=b[i].c=read(),b[i].w=read(),b[i].id=i;
sort(b+1,b+n+1,cmp1);work1();
sort(b+1,b+n+1,cmp2);work2();
for(int i=1;i<=n;i++)
if(!vis[i])dfs(i),calc();
printf("%d\n",ans);
return 0;
}
| a.cc:115:11: error: redefinition of 'const int maxn'
115 | const int maxn=2e5+5,pps=1e9+7;
| ^~~~
a.cc:5:11: note: 'const int maxn' previously defined here
5 | const int maxn=2e5+5,pps=1e9+7;
| ^~~~
a.cc:115:22: error: redefinition of 'const int pps'
115 | const int maxn=2e5+5,pps=1e9+7;
| ^~~
a.cc:5:22: note: 'const int pps' previously defined here
5 | const int maxn=2e5+5,pps=1e9+7;
| ^~~
a.cc:117:6: error: redefinition of 'bool vis [200005]'
117 | bool vis[maxn];
| ^~~
a.cc:7:6: note: 'bool vis [200005]' previously declared here
7 | bool vis[maxn];
| ^~~
a.cc:118:5: error: redefinition of 'int n'
118 | int n,x,y,tot,ans=1,top;
| ^
a.cc:8:5: note: 'int n' previously declared here
8 | int n,x,y,tot,ans=1,top;
| ^
a.cc:118:7: error: redefinition of 'int x'
118 | int n,x,y,tot,ans=1,top;
| ^
a.cc:8:7: note: 'int x' previously declared here
8 | int n,x,y,tot,ans=1,top;
| ^
a.cc:118:9: error: redefinition of 'int y'
118 | int n,x,y,tot,ans=1,top;
| ^
a.cc:8:9: note: 'int y' previously declared here
8 | int n,x,y,tot,ans=1,top;
| ^
a.cc:118:11: error: redefinition of 'int tot'
118 | int n,x,y,tot,ans=1,top;
| ^~~
a.cc:8:11: note: 'int tot' previously declared here
8 | int n,x,y,tot,ans=1,top;
| ^~~
a.cc:118:15: error: redefinition of 'int ans'
118 | int n,x,y,tot,ans=1,top;
| ^~~
a.cc:8:15: note: 'int ans' previously defined here
8 | int n,x,y,tot,ans=1,top;
| ^~~
a.cc:118:21: error: redefinition of 'int top'
118 | int n,x,y,tot,ans=1,top;
| ^~~
a.cc:8:21: note: 'int top' previously declared here
8 | int n,x,y,tot,ans=1,top;
| ^~~
a.cc:119:5: error: redefinition of 'int fac [200005]'
119 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~
a.cc:9:5: note: 'int fac [200005]' previously declared here
9 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~
a.cc:119:15: error: redefinition of 'int inv [200005]'
119 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~
a.cc:9:15: note: 'int inv [200005]' previously declared here
9 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~
a.cc:119:25: error: redefinition of 'int sta [200005]'
119 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~
a.cc:9:25: note: 'int sta [200005]' previously declared here
9 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~
a.cc:119:35: error: redefinition of 'int insta [200005]'
119 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~~~
a.cc:9:35: note: 'int insta [200005]' previously declared here
9 | int fac[maxn],inv[maxn],sta[maxn],insta[maxn];
| ^~~~~
a.cc:120:5: error: redefinition of 'int sum [200005]'
120 | int sum[maxn],now[maxn],pre[maxn<<3],son[maxn<<3],color[maxn];
| ^~~
a.cc:10:5: note: 'int sum [200005]' previously declared here
10 | int sum[maxn],now[maxn],pre[maxn<<2],son[maxn<<2],color[maxn];
| ^~~
a.cc:120:15: error: redefinition of 'int now [200005]'
120 | int sum[maxn],now[maxn],pre[maxn<<3],son[maxn<<3],color[maxn];
| ^~~
a.cc:10:15: note: 'int now [200005]' previously declared here
10 | int sum[maxn],now[maxn],pre[maxn<<2],son[maxn<<2],color[maxn];
| ^~~
a.cc:120:25: error: conflicting declaration 'int pre [1600040]'
120 | int sum[maxn],now[maxn],pre[maxn<<3],son[maxn<<3],color[maxn];
| ^~~
a.cc:10:25: note: previous declaration as 'int pre [800020]'
10 | int sum[maxn],now[maxn],pre[maxn<<2],son[maxn<<2],color[maxn];
| ^~~
a.cc:120:38: error: conflicting declaration 'int son [1600040]'
120 | int sum[maxn],now[maxn],pre[maxn<<3],son[maxn<<3],color[maxn];
| ^~~
a.cc:10:38: note: previous declaration as 'int son [800020]'
10 | int sum[maxn],now[maxn],pre[maxn<<2],son[maxn<<2],color[maxn];
| ^~~
a.cc:120:51: error: redefinition of 'int color [200005]'
120 | int sum[maxn],now[maxn],pre[maxn<<3],son[maxn<<3],color[maxn];
| ^~~~~
a.cc:10:51: note: 'int color [200005]' previously declared here
10 | int sum[maxn],now[maxn],pre[maxn<<2],son[maxn<<2],color[maxn];
| ^~~~~
a.cc:122:5: error: redefinition of 'int read()'
122 | int read() {
| ^~~~
a.cc:12:5: note: 'int read()' previously defined here
12 | int read() {
| ^~~~
a.cc:129:8: error: redefinition of 'struct Ball'
129 | struct Ball {
| ^~~~
a.cc:19:8: note: previous definition of 'struct Ball'
19 | struct Ball {
| ^~~~
a.cc:131:2: error: conflicting declaration 'int b [200005]'
131 | }b[maxn];
| ^
a.cc:21:2: note: previous declaration as 'Ball b [200005]'
21 | }b[maxn];
| ^
a.cc:133:5: error: redefinition of 'int quick(int, int)'
133 | int quick(int a,int b) {
| ^~~~~
a.cc:23:5: note: 'int quick(int, int)' previously defined here
23 | int quick(int a,int b) {
| ^~~~~
a.cc:142:6: error: redefinition of 'bool cmp1(Ball, Ball)'
142 | bool cmp1(Ball a,Ball b) {
| ^~~~
a.cc:32:6: note: 'bool cmp1(Ball, Ball)' previously defined here
32 | bool cmp1(Ball a,Ball b) {
| ^~~~
a.cc:147:6: error: redefinition of 'bool cmp2(Ball, Ball)'
147 | bool cmp2(Ball a,Ball b) {
| ^~~~
a.cc:37:6: note: 'bool cmp2(Ball, Ball)' previously defined here
37 | bool cmp2(Ball a,Ball b) {
| ^~~~
a.cc:152:6: error: redefinition of 'void add(int, int)'
152 | void add(int a,int b) {
| ^~~
a.cc:42:6: note: 'void add(int, int)' previously defined here
42 | void add(int a,int b) {
| ^~~
a.cc:157:6: error: redefinition of 'void work1()'
157 | void work1() {
| ^~~~~
a.cc:47:6: note: 'void work1()' previously defined here
47 | void work1() {
| ^~~~~
a.cc:170:6: error: redefinition of 'void work2()'
170 | void work2() {
| ^~~~~
a.cc:60:6: note: 'void work2()' previously defined here
60 | void work2() {
| ^~~~~
a.cc:179:6: error: redefinition of 'void prepare()'
179 | void prepare() {
| ^~~~~~~
a.cc:69:6: note: 'void prepare()' previously defined here
69 | void prepare() {
| ^~~~~~~
a.cc:188:6: error: redefinition of 'void dfs(int)'
188 | void dfs(int u) {
| ^~~
a.cc:78:6: note: 'void dfs(int)' previously defined here
78 | void dfs(int u) {
| ^~~
a.cc:201:6: error: redefinition of 'void calc()'
201 | void calc() {
| ^~~~
a.cc:91:6: note: 'void calc()' previously defined here
91 | void calc() {
| ^~~~
a.cc:210:5: error: redefinition of 'int main()'
210 | int main() {
| ^~~~
a.cc:100:5: note: 'int main()' previously defined here
100 | int main() {
| ^~~~
|
s057986578 | p03770 | C++ | # include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn(2e5 + 5);
const int mod(1e9 + 7);
int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
vector <int> ball[maxn];
inline bool Cmp(int i, int j) {
return mn[i] < mn[j];
}
int main() {
register int i, j, w, c, nmn;
scanf("%d%d%d", &n, &x, &y), inv[1] = inv[0] = 1;
for (i = 2; i <= n; ++i) inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
for (i = 1; i <= n; ++i) inv[i] = 1LL * inv[i] * inv[i - 1] % mod;
for (i = 1; i <= n; ++i) scanf("%d%d", &c, &w), ball[c].push_back(w), ++size[c], id[i] = i;
for (i = 1; i <= n; ++i)
if (size[i]) {
sort(ball[i].begin(), ball[i].end());
mn[i] = ball[i][0], mn2 = min(mn[i], mn2);
if (mn2 < mn1) swap(mn2, mn1);
}
else mn[i] = mod;
for (i = 1; i <= n; ++i)
if (size[i]) {
nmn = mn[i] == mn1 ? mn2 : mn1;
if (mn[i] > x) {
size[i] = 0, mn[i] = inf;
continue;
}
for (j = 1; j < size[i]; ++j)
if (mn[i] + ball[i][j] > x && nmn + ball[i][j] > y) break;
size[i] = j;
}
sort(id + 1, id + n + 1, Cmp), nmn = mn[id[1]];
cnt = mn[id[1]] != mod ? size[id[1]] : 0;
for (i = 2; i <= n; ++i)
if (mn[id[i]] + nmn <= y) ans = 1LL * ans * inv[size[id[i]]] % mod, cnt += size[id[i]];
for (i = 1; i <= cnt; ++i) ans = 1LL * ans * i % mod;
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:16:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
16 | register int i, j, w, c, nmn;
| ^
a.cc:16:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
16 | register int i, j, w, c, nmn;
| ^
a.cc:16:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
16 | register int i, j, w, c, nmn;
| ^
a.cc:16:31: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
16 | register int i, j, w, c, nmn;
| ^
a.cc:16:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
16 | register int i, j, w, c, nmn;
| ^~~
a.cc:20:81: error: reference to 'size' is ambiguous
20 | for (i = 1; i <= n; ++i) scanf("%d%d", &c, &w), ball[c].push_back(w), ++size[c], id[i] = i;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:22:21: error: reference to 'size' is ambiguous
22 | if (size[i]) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:29:21: error: reference to 'size' is ambiguous
29 | if (size[i]) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:32:33: error: reference to 'size' is ambiguous
32 | size[i] = 0, mn[i] = inf;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:32:54: error: 'inf' was not declared in this scope; did you mean 'ynf'?
32 | size[i] = 0, mn[i] = inf;
| ^~~
| ynf
a.cc:35:41: error: reference to 'size' is ambiguous
35 | for (j = 1; j < size[i]; ++j)
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:37:20: error: reference to 'size' is ambiguous
37 | size[i] = j;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:40:34: error: reference to 'size' is ambiguous
40 | cnt = mn[id[1]] != mod ? size[id[1]] : 0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:42:65: error: reference to 'size' is ambiguous
42 | if (mn[id[i]] + nmn <= y) ans = 1LL * ans * inv[size[id[i]]] % mod, cnt += size[id[i]];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
a.cc:42:92: error: reference to 'size' is ambiguous
42 | if (mn[id[i]] + nmn <= y) ans = 1LL * ans * inv[size[id[i]]] % mod, cnt += size[id[i]];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:29: note: 'int size [200005]'
8 | int n, mn[maxn], inv[maxn], size[maxn], mn1 = mod, mn2 = mod, x, y, id[maxn], ans = 1, cnt;
| ^~~~
|
s463378680 | p03770 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define LL long long
#define maxn 2000005
#define mod 1000000007
#define INF (LL)1e16
using namespace std;
typedef pair<LL,int> PLI;
LL n,ans,c[maxn],Siz,cnt[maxn],fact[maxn],inv[maxn],mnp[maxn],Mnp2,Mnp;
LL w[maxn],x,y,Mn=INF,Mn2=INF,mn[maxn];
bool vis[maxn];
vector<PLI> cw[maxn];
struct node { LL v; node *nxt; } edge[maxn*75],*head[maxn],*ncnt;
void addedge(LL u,LL v)
{
ncnt++;
ncnt->v=v,ncnt->nxt=head[u];
head[u]=ncnt;
}
void dfs(LL u)
{
vis[u]=true;
cnt[c[u]]++,Siz++;
for(node *p=head[u];p;p=p->nxt)
{
LL v=p->v;
if(!vis[v]) dfs(v);
}
}
int main()
{
scanf("%lld%lld%lld",&n,&x,&y);
fact[0]=1;
for(LL i=1;i<=n;i++) fact[i]=1ll*fact[i-1]*i%mod;
inv[1]=1;
for(LL i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
inv[0]=1;
for(LL i=1;i<=n;i++) inv[i]=1ll*inv[i]*inv[i-1]%mod;
ncnt=&edge[0];
for(LL i=1;i<=n;i++) mn[i]=INF;
for(LL i=1;i<=n;i++)
{
scanf("%lld%lld",&c[i],&w[i]);
if(mn[c[i]]>w[i]) mn[c[i]]=w[i],mnp[c[i]]=i;
if(Mn>w[i]) Mn=w[i],Mnp=i;//Mn=min(Mn,w[i]);
}
for(LL i=1;i<=n;i++)
if(c[i]!=c[Mnp]&&Mn2>w[i]) Mn2=w[i],Mnp2=i;
for(LL i=1;i<=n;i++)
if(i!=mnp[c[i]]&&mn[c[i]]+w[i]<=x) { addedge(i,mnp[c[i]]); addedge(mnp[c[i]],i); }
for(LL i=1;i<=n;i++)
{
if(i==Mnp) continue;
else if(c[i]!=c[Mnp]&&Mn+w[i]<=y) { addedge(i,Mnp); addedge(Mnp,i); }
else if(Mn2!=INF&&c[i]!=c[Mn2]&&Mn2+w[i]<=y) { addedge(i,Mnp2); addedge(Mnp2,i); }
}
dfs(Mnp);
ans=fact[Siz];
for(LL i=1;i<=n;i++) ans=1ll*ans*inv[cnt[i]]%mod;
printf("%lld\n",ans);
} | /tmp/cc8uo8oB.o: in function `addedge(long long, long long)':
a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/cc8uo8oB.o
a.cc:(.text+0x1a): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/cc8uo8oB.o
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/cc8uo8oB.o
a.cc:(.text+0x2f): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/cc8uo8oB.o
a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `head' defined in .bss section in /tmp/cc8uo8oB.o
a.cc:(.text+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/cc8uo8oB.o
a.cc:(.text+0x64): relocation truncated to fit: R_X86_64_PC32 against symbol `head' defined in .bss section in /tmp/cc8uo8oB.o
/tmp/cc8uo8oB.o: in function `dfs(long long)':
a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `head' defined in .bss section in /tmp/cc8uo8oB.o
/tmp/cc8uo8oB.o: in function `main':
a.cc:(.text+0x370): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/cc8uo8oB.o
collect2: error: ld returned 1 exit status
|
s113561676 | p03770 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define LL long long
#define maxn 2000005
#define mod 1000000007
#define INF (LL)1e16
using namespace std;
typedef pair<LL,int> PLI;
LL n,ans,c[maxn],Siz,cnt[maxn],fact[maxn],inv[maxn],mnp[maxn],Mnp2,Mnp;
LL w[maxn],x,y,Mn=INF,Mn2=INF,mn[maxn];
bool vis[maxn];
vector<PLI> cw[maxn];
struct node { LL v; node *nxt; } edge[maxn*75],*head[maxn],*ncnt;
void addedge(LL u,LL v)
{
ncnt++;
ncnt->v=v,ncnt->nxt=head[u];
head[u]=ncnt;
}
void dfs(LL u)
{
vis[u]=true;
cnt[c[u]]++,Siz++;
for(node *p=head[u];p;p=p->nxt)
{
LL v=p->v;
if(!vis[v]) dfs(v);
}
}
int main()
{
scanf("%d%lld%lld",&n,&x,&y);
fact[0]=1;
for(LL i=1;i<=n;i++) fact[i]=1ll*fact[i-1]*i%mod;
inv[1]=1;
for(LL i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
inv[0]=1;
for(LL i=1;i<=n;i++) inv[i]=1ll*inv[i]*inv[i-1]%mod;
ncnt=&edge[0];
for(LL i=1;i<=n;i++) mn[i]=INF;
for(LL i=1;i<=n;i++)
{
scanf("%d%lld",&c[i],&w[i]);
if(mn[c[i]]>w[i]) mn[c[i]]=w[i],mnp[c[i]]=i;
if(Mn>w[i]) Mn=w[i],Mnp=i;//Mn=min(Mn,w[i]);
}
for(LL i=1;i<=n;i++)
if(c[i]!=c[Mnp]&&Mn2>w[i]) Mn2=w[i],Mnp2=i;
for(LL i=1;i<=n;i++)
if(i!=mnp[c[i]]&&mn[c[i]]+w[i]<=x) { addedge(i,mnp[c[i]]); addedge(mnp[c[i]],i); }
for(LL i=1;i<=n;i++)
{
if(i==Mnp) continue;
else if(c[i]!=c[Mnp]&&Mn+w[i]<=y) { addedge(i,Mnp); addedge(Mnp,i); }
else if(Mn2!=INF&&c[i]!=c[Mn2]&&Mn2+w[i]<=y) { addedge(i,Mnp2); addedge(Mnp2,i); }
}
dfs(Mnp);
ans=fact[Siz];
for(LL i=1;i<=n;i++) ans=1ll*ans*inv[cnt[i]]%mod;
printf("%d\n",ans);
}
| /tmp/ccq0wKvd.o: in function `addedge(long long, long long)':
a.cc:(.text+0xf): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/ccq0wKvd.o
a.cc:(.text+0x1a): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/ccq0wKvd.o
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/ccq0wKvd.o
a.cc:(.text+0x2f): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/ccq0wKvd.o
a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `head' defined in .bss section in /tmp/ccq0wKvd.o
a.cc:(.text+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/ccq0wKvd.o
a.cc:(.text+0x64): relocation truncated to fit: R_X86_64_PC32 against symbol `head' defined in .bss section in /tmp/ccq0wKvd.o
/tmp/ccq0wKvd.o: in function `dfs(long long)':
a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `head' defined in .bss section in /tmp/ccq0wKvd.o
/tmp/ccq0wKvd.o: in function `main':
a.cc:(.text+0x370): relocation truncated to fit: R_X86_64_PC32 against symbol `ncnt' defined in .bss section in /tmp/ccq0wKvd.o
collect2: error: ld returned 1 exit status
|
s596926497 | p03770 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define LL long long
#define maxn 200005
#define mod 1000000007
#define INF (LL)1e16
using namespace std;
typedef pair<LL,int> PLI;
LL n,ans,c[maxn],Siz,cnt[maxn],fact[maxn],inv[maxn],mnp[maxn],Mnp2,Mnp;
LL w[maxn],x,y,Mn=INF,Mn2=INF,mn[maxn];
bool vis[maxn];
vector<PLI> cw[maxn];
struct node { LL v; node *nxt; } edge[maxn*75],*head[maxn],*ncnt;
void addedge(LL u,LL v)
{
ncnt++;
ncnt->v=v,ncnt->nxt=head[u];
head[u]=ncnt;
}
void dfs(LL u)
{
vis[u]=true;
cnt[c[u]]++,Siz++;
for(node *p=head[u];p;p=p->nxt)
{
LL v=p->v;
if(!vis[v]) dfs(v);
}
}
LL main()
{
freopen("colorball.in","r",stdin);
freopen("colorball.out","w",stdout);
scanf("%d%lld%lld",&n,&x,&y);
fact[0]=1;
for(LL i=1;i<=n;i++) fact[i]=1ll*fact[i-1]*i%mod;
inv[1]=1;
for(LL i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
inv[0]=1;
for(LL i=1;i<=n;i++) inv[i]=1ll*inv[i]*inv[i-1]%mod;
ncnt=&edge[0];
for(LL i=1;i<=n;i++) mn[i]=INF;
for(LL i=1;i<=n;i++)
{
scanf("%d%lld",&c[i],&w[i]);
if(mn[c[i]]>w[i]) mn[c[i]]=w[i],mnp[c[i]]=i;
if(Mn>w[i]) Mn=w[i],Mnp=i;//Mn=min(Mn,w[i]);
}
for(LL i=1;i<=n;i++)
if(c[i]!=c[Mnp]&&Mn2>w[i]) Mn2=w[i],Mnp2=i;
for(LL i=1;i<=n;i++)
if(i!=mnp[c[i]]&&mn[c[i]]+w[i]<=x) { addedge(i,mnp[c[i]]); addedge(mnp[c[i]],i); }
for(LL i=1;i<=n;i++)
{
if(i==Mnp) continue;
else if(c[i]!=c[Mnp]&&Mn+w[i]<=y) { addedge(i,Mnp); addedge(Mnp,i); }
else if(Mn2!=INF&&c[i]!=c[Mn2]&&Mn2+w[i]<=y) { addedge(i,Mnp2); addedge(Mnp2,i); }
}
dfs(Mnp);
ans=fact[Siz];
for(LL i=1;i<=n;i++) ans=1ll*ans*inv[cnt[i]]%mod;
printf("%d\n",ans);
} | cc1plus: error: '::main' must return 'int'
|
s511779861 | p03770 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
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){
if(a<0){
a=-a; putchar('-');
}
write(a); puts("");
}
inline int rnd(int x){
return (rand()<<16|rand())%x;
}
const int N=200005,mod=1000000007;
vector<int> v[N];
int c[N],w[N],father[N],q[N],vis[N],x,y,n;
inline int getfather(int x){
return father[x]==x?x:father[x]=getfather(father[x]);
}
map<int,int> M[N];
inline int ksm(ll a,int b){
int ans=1;
for(;b;b>>=1){
if(b&1)ans=ans*a%mod;
a=a*a%mod;
}
return ans;
}
inline bool cmp(int a,int b){
return w[a]<w[b];
}
void ins (int a,int b){
//cout<<a<<" "<<b<<" "<<w[a]<<" "<<w[b]<<endl;
int t1=getfather(a),t2=getfather(b);
if(t1!=t2)father[t2]=t1;
}
void check(int a,int b){
if(c[a]!=c[b]&&w[a]+w[b]<=y)ins(b,a);
}
int main(){
n=read(); x=read(); y=read();
for(int i=1;i<=n;i++){
c[i]=read(); w[i]=read(); v[c[i]].push_back(i); father[i]=q[i]=i;
}
for(int i=1;i<=n;i++)if(v[i].size()){
sort(v[i].begin(),v[i].end(),cmp); vis[v[i][0]]=1;
for(unsigned j=1;j<v[i].size();i++)if(w[v[i][j]]+w[v[i][0]]<=x)ins(v[i][0],v[i][j]);
}
sort(&q[1],&q[n+1],cmp); int jb=0;
for(int i=2;i<=n;i++){
if(!jb)jb=q[i];
}//else cout<<w[i]<<" "<<i<<" "<<father[i]<<endl;
for(int i=1;i<=n;i++){
check(i,jb); check(i,q[1]);
}
for(int i=1;i<=n;i++)for(int
for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
ll ans=1;
for(int i=1;i<=n;i++)if(getfather(i)==i){
int sum=0;
for(map<int,int>::iterator it=M[i].begin();it!=M[i].end();it++){
sum+=it->second; for(int j=1;j<=it->second;j++)ans=ans*ksm(j,mod-2)%mod;
}
//cout<<i<<" "<<sum<<" "<<ans<<endl;
for(int j=1;j<=sum;j++)ans=ans*j%mod;
}
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:78:9: error: expected unqualified-id before 'for'
78 | for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
| ^~~
a.cc:77:37: error: expected ';' before 'for'
77 | for(int i=1;i<=n;i++)for(int
| ^
| ;
78 | for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
| ~~~
a.cc:78:9: error: expected primary-expression before 'for'
78 | for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
| ^~~
a.cc:77:37: error: expected ';' before 'for'
77 | for(int i=1;i<=n;i++)for(int
| ^
| ;
78 | for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
| ~~~
a.cc:78:9: error: expected primary-expression before 'for'
78 | for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
| ^~~
a.cc:77:37: error: expected ')' before 'for'
77 | for(int i=1;i<=n;i++)for(int
| ~ ^
| )
78 | for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
| ~~~
|
s055267996 | p03770 | C++ | #include <bits/stdc++.h>
#define x first
#define y second
#define y1 secondy1
#define rank tipa_rank
#define pb push_back
#define mp make_pair
#define pow10 tipa_pow10
#define ll long long
#define INF 1000000000
#define EPS 1e-9
#define EPS2 1e-8
#define PI acos(-1.0)
using namespace std;
const int MOD = INF + 7;
int n , x, y;
int cntByColour[200000];
int c[200000] , w[200000];
int goodPos[200000];
ll fact[200005];
bool good[200000];
vector<int> colWeight[200000];
vector<pair<int , int> > weight;
ll mod = 1000 * 1000 * 1000 + 7;
ll gcdExtended(ll a, ll b, ll *x, ll *y);
// Function to find modulo inverse of a
ll modInverse(ll a, ll m)
{
ll x, y;
ll g = gcdExtended(a, m, &x, &y);
if (g != 1)
cout << "Inverse doesn't exist";
else
{
// m is added to handle negative x
ll res = (x%m + m) % m;
return res;
}
}
// C function for extended Euclidean Algorithm
ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
// Base Case
if (a == 0)
{
*x = 0, *y = 1;
return b;
}
ll x1, y1; // To store results of recursive call
ll gcd = gcdExtended(b%a, a, &x1, &y1);
// Update x and y using results of recursive
// call
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}
int main()
{
fact[0] = 1;
for(int i = 1; i <= 200000; i++)
fact[i] = (fact[i - 1] * i) % MOD;
scanf("%d %d %d" , &n , &x , &y);
for(int i = 0; i < n; i++)
{
scanf("%d %d" , &c[i] , &w[i]);
c[i]--;
colWeight[c[i]].pb(w[i]);
weight.pb(mp(w[i] , c[i]));
}
sort(weight.begin() , weight.end());
for(int i = 0; i < n; i++)
sort(colWeight[i].begin() , colWeight[i].end());
ll ans = 1;
auto it = lower_bound(weight.begin() , weight.end() , mp(y - weight[0].first + 1, 0));
//cout << it->first << " " << it->second << endl;
for(auto it2 = weight.begin(); it2 != it; it2++)
{
good[it2->second] = true;
cntByColour[it2->second]++;
}
int cnt = 0;
for(int i = 0; i < n; i++)
{
if(!good[i])
continue;
if(!colWeight[i].size())
continue;
auto It = upper_bound(colWeight[i].begin() , colWeight[i].end() , x - colWeight[i][0]);
for(auto it2 = colWeight[i].begin(); it2 != It; it2++)
{
if(!binary_search(weight.begin() , it , mp(*it2 , i)))
{
cntByColour[i]++;
cnt++;
}
else
{
int x = lower_bound(weight.begin() , it , mp(*it2 , i)) - weight.begin();
goodPos[x] = 1;
}
}
}
for(int i = 0; i < weight.size(); i++)
{
if(!goodPos[i])
{
cnt--;
cntByColor[weight[i].second]--;
}
}
ans *= fact[it - weight.begin() + cnt];
for(int i = 0; i < n; i++)
{
ans *= modInverse(fact[cntByColour[i]] , MOD);
ans %= MOD;
}
ans %= MOD;
cout << ans;
}
| a.cc: In function 'int main()':
a.cc:116:25: error: 'cntByColor' was not declared in this scope; did you mean 'cntByColour'?
116 | cntByColor[weight[i].second]--;
| ^~~~~~~~~~
| cntByColour
a.cc: In function 'long long int modInverse(long long int, long long int)':
a.cc:40:1: warning: control reaches end of non-void function [-Wreturn-type]
40 | }
| ^
|
s777861417 | p03770 | C++ | #include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
using namespace std;
const int N = 200010;
const int mod = 1e9 + 7;
typedef long long LL;
typedef pair<int, int> pii;
vector<pii> b;
vector<int> t[N];
int n, x, y, lc[N], col[N], ls[N], tc[N], w[N];
#define bi b[i].second
int f[N], st[N];
int f_f(int x) { return x == f[x] ? x : f[x] = f_f(f[x]);}
void merge(int x1, int x2)
{
int f1 = f_f(x1), f2 = f_f(x2);
if (f1 != f2) f[f1] = f2;
}
LL p[N];
LL qpow(LL a, LL b)
{
LL ret = 1, base = a;
while (b) {
if (b & 1) ret = ret * base % mod;
base = base * base % mod, b >>= 1;
}
return ret;
}
LL C(int a, int b) {return p[a] * qpow(p[b], mod - 2) % mod * qpow(p[a - b], mod - 2) % mod;}
int main()
{
scanf("%d%d%d", &n, &x, &y);
Rep(i, n){
scanf("%d%d", &col[i], &w[i]);
b.push_back(mp(w[i], i));
f[i] = i;
}
sort(b.begin(), b.end());
memset(ls, -1, sizeof(ls));
ls[col[b[0]].second] = 0;
Rep(i, n - 1){
int tmp = ls[col[bi]];
if (tmp != -1 && b[i].first + b[tmp].first <= x) merge(bi, b[tmp].second);
if (col[bi] != col[b[0].second] && b[i].first + b[0].first <= y) merge(bi, b[0].second);
if (!ls[col[bi]]) ls[col[bi]] = i;
}
Rep(i, n) t[f_f(i)].push_back(col[i]);
p[0] = 1;
Rep(i, n) p[i] = p[i - 1] * i % mod;
LL ans = 1;
Rep(i, n) if (t[i].size()) {
sort(t[i].begin(), t[i].end());
int top = 0, cnt = 0;
for (int j = 0; j < t[i].size(); j ++){
if (t[i][j] != t[i][j - 1] && j != 0) st[++ top] = cnt, cnt = 0;
cnt ++;
}
int tmp = cnt;
LL tans = 1;
while (top){
tans = tans * C(tmp + st[top], st[top]) % mod;
tmp += st[top], top --;
}
ans = ans * tans % mod;
}
printf("%lld\n", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:56:15: error: no match for 'operator[]' (operand types are 'int [200010]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
56 | ls[col[b[0]].second] = 0;
| ^
|
s247675132 | p03770 | C++ | #include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
using namespace std;
const int N = 200010;
const int mod = 1e9 + 7;
typedef long long LL;
typedef pair<int, int> pii;
vector<pii> b, cb[N];
vector<int> t[N];
int n, x, y, lc[N], col[N], ls[N], tc[N], w[N];
#define bi b[i].second
int find_(vector<pii> &a, int k)
{
int l = 0, r = a.size() - 1;
while (l != r) {
int mid = (l + r) >> 1;
if (a[mid].first <= k) l = mid + 1;
else r = mid;
}
if (a[l] > k) return l - 1;
else return l;
}
int f[N], st[N];
int f_f(int x) { return x == f[x] ? x : f[x] = f_f(f[x]);}
void merge(int x1, int x2)
{
int f1 = f_f(x1), f2 = f_f(x2);
if (f1 != f2) f[f1] = f2;
}
LL p[N];
LL qpow(LL a, LL b)
{
LL ret = 1, base = a;
while (b) {
if (b & 1) ret = ret * base % mod;
base = base * base % mod, b >>= 1;
}
return ret;
}
LL C(int a, int b) {return p[a] * qpow(p[b], mod - 2) % mod * qpow(p[a - b], mod - 2) % mod;}
int main()
{
scanf("%d%d%d", &n, &x, &y);
Rep(i, n){
scanf("%d%d", &col[i], &w[i]);
b.push_back(mp(w[i], i));
cb[col[i]].push_back(mp(w[i], i));
f[i] = i;
}
sort(b.begin(), b.end());
Rep(i, n) sort(cb[i].begin(), cb[i].end());
memset(tc, -1, sizeof(tc));
memset(lc, -1, sizeof(lc));
memset(ls, -1, sizeof(ls));
tc[col[b[0].second]] = 0;
Rep(i, n - 1){
if (col[bi] == col[b[i - 1].second]) lc[i] = lc[i - 1];
else lc[i] = i - 1;
ls[i] = tc[col[bi]], tc[col[bi]] = i;
int tmp1 = ls[i], tmp2 = lc[i];
if (tmp1 != -1){
if (b[i].first + b[tmp1].first <= x) merge(bi, b[tmp1].second);
else {
int tmp = find_(cb[col[bi]], x - b[i].first);
if (tmp >= 0 && tmp < cb[col[bi]].size()) merge(bi, cb[col[bi]][tmp].second);
}
}
if (tmp2 != -1){
if (b[i].first + b[tmp2].first <= y){merge(bi, b[tmp2].second);}
else {
int tmp = find_(b, y - b[i].first);
if (tmp >= 0 && tmp < b.size()) merge(bi, b[tmp].second);
}
}
}
Rep(i, n) t[f_f(i)].push_back(col[i]);
p[0] = 1;
Rep(i, n) p[i] = p[i - 1] * i % mod;
LL ans = 1;
Rep(i, n) if (t[i].size()) {
sort(t[i].begin(), t[i].end());
int top = 0, cnt = 0;
for (int j = 0; j < t[i].size(); j ++){
if (t[i][j] != t[i][j - 1] && j != 0) st[++ top] = cnt, cnt = 0;
cnt ++;
}
int tmp = cnt;
LL tans = 1;
while (top){
tans = tans * C(tmp + st[top], st[top]) % mod;
tmp += st[top], top --;
}
ans = ans * tans % mod;
}
printf("%lld\n", ans);
return 0;
}
| a.cc: In function 'int find_(std::vector<std::pair<int, int> >&, int)':
a.cc:32:18: error: no match for 'operator>' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
32 | if (a[l] > k) return l - 1;
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed:
a.cc:32:20: note: mismatched types 'const std::pair<_T1, _T2>' and 'int'
32 | if (a[l] > k) return l - 1;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
462 | operator>(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed:
a.cc:32:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
32 | if (a[l] > k) return l - 1;
| ^
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
507 | operator>(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed:
a.cc:32:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
32 | if (a[l] > k) return l - 1;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1714 | operator>(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed:
a.cc:32:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>'
32 | if (a[l] > k) return l - 1;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1774 | operator>(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed:
a.cc:32:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::move_iterator<_IteratorL>'
32 | if (a[l] > k) return l - 1;
| ^
In file included from /usr/include/c++/14/vector:66,
from a.cc:4:
/usr/include/c++/14/bits/stl_vector.h:2102:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
2102 | operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2102:5: note: template argument deduction/substitution failed:
a.cc:32:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::vector<_Tp, _Alloc>'
32 | if (a[l] > k) return l - 1;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/vector:87:
/usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2619 | operator>(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed:
a.cc:32:20: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::tuple<_UTypes ...>'
32 | if (a[l] > k) return l - 1;
| ^
a.cc:34:1: warning: control reaches end of non-void function [-Wreturn-type]
34 | }
| ^
|
s999514866 | p03770 | C++ | #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back
using namespace std;
const int Mod = 1e9 + 7;
const int N = 200010;
typedef long long LL;
LL Pow(LL x, LL e){
LL ret = 1;
while(e){
if(e & 1) ret = ret * x % Mod;
x = x * x % Mod;
e >>= 1;
}
return ret;
}
int fa[N];
int find(int x){
return x == fa[x] ? x : fa[x] = find(fa[x]);
}
int n, X, Y;
int val[N], col[N];
vector<int> S[N];
int fac[N], rfac[N];
void init(){
fac[0] = 1;
For(i, 1, N - 5) fac[i] = 1ll * fac[i - 1] * i % Mod;
rfac[N - 5] = Pow(fac[N - 5], Mod - 2);
Forr(i, N - 6, 0) rfac[i] = 1ll * (i + 1) * rfac[i + 1] % Mod;
}
int rk[N];
bool cmp1(int x, int y){
return col[x] ^ col[y] ? col[x] < col[y] : val[x] < val[y];
}
int main(){
init();
scanf("%d%d%d", &n, &X, &Y);
For(i, 1, n) scanf("%d%d", &col[i], &val[i]), fa[i] = rk[i] = i;
sort(rk + 1, rk + n + 1, cmp1);
int pre = rk[1];
int mn1 = 1, mn2 = 0;
val[0] = 2e9;
For(i, 2, n){
if(col[rk[i]] ^ col[pre]) pre = rk[i];
if(val[rk[i]] + val[pre] <= X) fa[find(rk[i])] = find(pre);
if(val[rk[i]] < val[mn1]) mn2 = mn1, mn1 = rk[i];
if(col[mn1] != col[rk[i]] && val[rk[i]] < val[mn2]) mn2 = rk[i];
}
if(!mn2){
puts("1"); return 0;
}
For(i, 1, n)
if(col[i] == col[mn1] && val[i] + val[mn2] <= Y) fa[find(i)] = find(mn2);
else if(col[i] != col[mn1] && val[i] + val[mn1] <= Y) fa[find(i)] = find(mn1);
For(i, 1, n) S[find(i)].pb(col[i]);
LL ans = 1;
For(i, 1, n) if(fa[i] == i){
sort(S[i].begin(), S[i].end());
int sz = int(S[i].size()) - 1, c = 0;
ans = ans * fac[sz + 1] % Mod;
For(j, 0, sz){
++c;
if(j == sz || S[i][j] != S[i][j + 1]){
ans = ans * rfac[c] % Mod;
c = 0;
}
}
}
printf("%lld\n", ans);
return 0;
} | a.cc:36:1: error: 'vector' does not name a type
36 | vector<int> S[N];
| ^~~~~~
a.cc: In function 'int main()':
a.cc:77:22: error: 'S' was not declared in this scope
77 | For(i, 1, n) S[find(i)].pb(col[i]);
| ^
a.cc:81:22: error: 'S' was not declared in this scope
81 | sort(S[i].begin(), S[i].end());
| ^
a.cc:85:27: error: 'c' was not declared in this scope
85 | ++c;
| ^
|
s299849377 | p03770 | C++ | #include <bits/stdc++.h>
using namespace std;
#define N 210000
#define mod 1000000007
#define ll long long
int n,X,Y,cnt;
int c[N],w[N],a[N],pos[N],num[N],jc[N],njc[N];
vector<int>v1[N],v2[N];
int cmp(int x,int y){return v1[x][0]<v1[y][0];}
int qpow(int x,int y)
{
int ret=1;
while(y)
{
if(y&1)ret=(ll)ret*x%mod;
x=(ll)x*x%mod;y>>=1;
}
return ret;
}
void init()
{
jc[0]=njc[0]=1;
for(int i=1;i<=n;i++)jc[i]=(ll)jc[i-1]*i%mod;
njc[n]=qpow(jc[n],mod-2);
for(int i=n-1;i>=1;i--)njc[i]=(ll)njc[i+1]*(i+1)%mod;
}
int C(int x,int y){return (ll)jc[x]*njc[y]%mod*njc[x-y]%mod;}
int main()
{
//freopen("tt.in","r",stdin);
scanf("%d%d%d",&n,&X,&Y);
init();
for(int i=1;i<=n;i++)
scanf("%d%d",&c[i],&w[i]),a[++cnt]=c[i];
sort(a+1,a+1+cnt);
cnt=unique(a+1,a+1+cnt)-a-1;
for(int i=1;i<=n;i++)
{
c[i]=lower_bound(a+1,a+1+cnt,c[i])-a;
v1[c[i]].push_back(w[i]);
}
for(int i=1;i<=cnt;i++)
{
sort(v1[i].begin(),v1[i].end());
pos[i]=i;
}
sort(pos+1,pos+1+cnt,cmp);
for(int i=1;i<=cnt;i++)
v2[i]=v1[pos[i]];
num[1]=upper_bound(v2[1].begin(),v2[1].end(),X-v2[1][0])-v2[1].begin();
if(cnt>1)num[1]=max(num[1],
upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());
for(int i=2;i<=cnt;i++)
{
num[i]=upper_bound(v2[i].begin(),v2[i].end(),X-v2[i][0])-v2[i].begin();
num[i]=max(num[i],
upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
}
int sum=num[1],ans=1;
for(int i=2;i<=cnt;i++)
{
if(v2[i][0]+v2[1][0]>Y)break;
ans=(ll)ans*C(sum+num[i],sum)%mod;
sum+=num[i];
}
printf("%d\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:51:28: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
51 | if(cnt>1)num[1]=max(num[1],
| ~~~^~~~~~~~
52 | upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:51:28: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
51 | if(cnt>1)num[1]=max(num[1],
| ~~~^~~~~~~~
52 | upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:51:28: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
51 | if(cnt>1)num[1]=max(num[1],
| ~~~^~~~~~~~
52 | upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:57:27: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
57 | num[i]=max(num[i],
| ~~~^~~~~~~~
58 | upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:27: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
57 | num[i]=max(num[i],
| ~~~^~~~~~~~
58 | upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:57:27: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
57 | num[i]=max(num[i],
| ~~~^~~~~~~~
58 | upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s544144252 | p03770 | C++ | #include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
//const ll inf=0x3f3f3f3f3f3f3f3fll;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
const int mo=1e9+7;
int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}
int fa[211111];
int gf(int x){
return x==fa[x]?x:fa[x]=gf(fa[x]);
}
void un(int a,int b){
a=gf(a);
b=gf(b);
fa[a]=b;
}
const int N=222222;
int fac[N];
int ifac[N];
int n;
int co[N],we[N];
int X,Y;
int cmin[N];
int mini=0,semi=0;
vi lis[N];
int sz[N];
int main()
{
#ifdef JCVB
//freopen("1.in","r",stdin);
//freopen("1.out","w",stdout);
int _time_jc=clock();
#endif
fac[0]=1;
rep(i,1,N)fac[i]=1ll*i*fac[i-1]%mo;
rep(i,0,N)ifac[i]=qp(fac[i],mo-2);
gn(n);gn(X);gn(Y);
we[0]=inf;
rep(i,1,n+1){
gn(co[i]);
gn(we[i]);
if(we[i]<we[cmin[co[i]]])cmin[co[i]]=i;
}
rep(i,1,n+1)if(cmin[i]!=0){
if(we[cmin[i]]<we[mini]){
semi=mini;
mini=cmin[i];
}else if(we[cmin[i]]<we[semi]){
semi=cmin[i];
}
}
rep(i,1,n+1)fa[i]=i;
rep(i,1,n+1){
if(we[i]+we[cmin[co[i]]]<=X) un(i,cmin[co[i]]);
int tar=0;
if(co[i]==co[mini]){
tar=mimi;
}else{
tar=mini;
}
if(tar!=0 && we[tar]+we[i]<=Y)un(i,tar);
}
rep(i,1,n+1)lis[gf(i)].pb(co[i]);
int res=1;
rep(i,1,n+1)if(!lis[i].empty()){
rep(j,0,siz(lis[i]))sz[lis[i][j]]=0;
rep(j,0,siz(lis[i]))sz[lis[i][j]]++;
mmo(res,fac[siz(lis[i])]);
rep(j,0,siz(lis[i])){
int t=lis[i][j];
mmo(res,ifac[sz[t]]);
sz[t]=1;
}
}
printf("%d\n",res);
#ifdef JCVB
debug("time: %d\n",int(clock()-_time_jc));
#endif
return 0;
}
| a.cc: In function 'int main()':
a.cc:139:29: error: 'mimi' was not declared in this scope; did you mean 'mini'?
139 | tar=mimi;
| ^~~~
| mini
|
s073976211 | p03770 | C++ | #include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const int M=2*100000+1;
const vi emp;
ll Pow_mod(ll n,ll p){
ll r=1;
for(;p>0;p>>=1){
if(p&1) r=(r*n)%mod;
n=(n*n)%mod;
}
return r;
}
ll Division_mod(ll n,ll m){
return n*Pow_mod(m,mod-2)%mod;
}
vl fact(M);
void Init(){
fact[0]=1;
for(int i=1;i<M;i++) fact[i]=fact[i-1]*i%mod;
}
int n,x,y;
vvi a;
int main(){
cin>>n>>x>>y;
int cnt=0;
map<int,int> m;
for(int i=0;i<n;i++){
int c,w;
cin>>c>>w;
if(m.find(c)==m.end()){
m[c]=cnt;
cnt++;
a.push_back(emp);
}
a[m[c]].push_back(w);
}
int S=m.size();
if(S==1){
cout<<1<<endl;
return 0;
}
for(int i=0;i<S;i++) sort(a[i].begin(),a[i].end());
sort(a.begin(),a.end());
vi b(S);
for(int i=0;i<S;i++){
auto it=upper_bound(a[i].begin(),a[i].end(),y-a[0][0]);
if(it==a[i].begin()) break;
b[i]=upper_bound(a[i].begin(),a[i].end(),x-a[i][0])-a[i].begin();
if(i) b[i]=max(b[i],(int)(it-a[i].begin()));
else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
}
// for(int i=0;i<S;i++) cout<<b[i]<<' ';
// cout<<endl;
Init();
ll res=1,sum=0;
for(int i=0;i<S;i++){
(res*=fact[b[i]])%=mod;
sum+=b[i];
}
res=Division_mod(fact[sum],res);
cout<<res<<endl;
} | a.cc: In function 'int main()':
a.cc:100:30: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:100:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:11:
/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:100:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s900395944 | p03770 | C++ | #include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const int M=2*100000+1;
const vi emp;
ll Pow_mod(ll n,ll p){
ll r=1;
for(;p>0;p>>=1){
if(p&1) r=(r*n)%mod;
n=(n*n)%mod;
}
return r;
}
ll Division_mod(ll n,ll m){
return n*Pow_mod(m,mod-2)%mod;
}
vl fact(M);
void Init(){
fact[0]=1;
for(int i=1;i<M;i++) fact[i]=fact[i-1]*i%mod;
}
int n,x,y;
vvi a;
int main(){
cin>>n>>x>>y;
int cnt=0;
map<int,int> m;
for(int i=0;i<n;i++){
int c,w;
cin>>c>>w;
if(m.find(c)==m.end()){
m[c]=cnt;
cnt++;
a.push_back(emp);
}
a[m[c]].push_back(w);
}
int S=m.size();
if(S==1){
cout<<1<<endl;
return 0;
}
for(int i=0;i<S;i++) sort(a[i].begin(),a[i].end());
sort(a.begin(),a.end());
vi b(S);
for(int i=0;i<S;i++){
auto it=upper_bound(a[i].begin(),a[i].end(),y-a[0][0]);
if(it==a[i].begin()) break;
b[i]=upper_bound(a[i].begin(),a[i].end(),x-a[i][0])-a[i].begin();
if(i) b[i]=max(b[i],it-a[i].begin());
else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
}
// for(int i=0;i<S;i++) cout<<b[i]<<' ';
// cout<<endl;
Init();
ll res=1,sum=0;
for(int i=0;i<S;i++){
(res*=fact[b[i]])%=mod;
sum+=b[i];
}
res=Division_mod(fact[sum],res);
cout<<res<<endl;
} | a.cc: In function 'int main()':
a.cc:99:31: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
99 | if(i) b[i]=max(b[i],it-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
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:99:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
99 | if(i) b[i]=max(b[i],it-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:11:
/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:99:31: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
99 | if(i) b[i]=max(b[i],it-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:100:30: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:100:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:100:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s723888050 | p03770 | C++ | #include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const int M=2*100000+1;
const vi emp;
ll Pow_mod(ll n,ll p){
ll r=1;
for(;p>0;p>>=1){
if(p&1) r=(r*n)%mod;
n=(n*n)%mod;
}
return r;
}
ll Division_mod(ll n,ll m){
return n*Pow_mod(m,mod-2)%mod;
}
vl fact(M);
void Init(){
fact[0]=1;
for(int i=1;i<M;i++) fact[i]=fact[i-1]*i%mod;
}
int n,x,y;
vvi a;
int main(){
cin>>n>>x>>y;
int cnt=0;
map<int,int> m;
for(int i=0;i<n;i++){
int c,w;
cin>>c>>w;
if(m.find(c)==m.end()){
m[c]=cnt;
cnt++;
a.push_back(emp);
}
a[m[c]].push_back(w);
}
int S=m.size();
if(S==1){
cout<<1<<endl;
return 0;
}
for(int i=0;i<S;i++) sort(a[i].begin(),a[i].end());
sort(a.begin(),a.end());
vi b(S);
for(int i=0;i<S;i++){
auto it=upper_bound(a[i].begin(),a[i].end(),y-a[0][0]);
if(it==a[i].begin()) break;
b[i]=upper_bound(a[i].begin(),a[i].end(),x-a[i][0])-a[i].begin();
if(i) b[i]=max(b[i],it-a[i].begin());
else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
}
// for(int i=0;i<S;i++) cout<<b[i]<<' ';
// cout<<endl;
Init();
ll res=1,sum=0;
for(int i=0;i<S;i++){
(res*=fact[b[i]])%=mod;
sum+=b[i];
}
res=Division_mod(fact[sum],res);
cout<<res<<endl;
} | a.cc: In function 'int main()':
a.cc:99:31: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
99 | if(i) b[i]=max(b[i],it-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
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:99:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
99 | if(i) b[i]=max(b[i],it-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:11:
/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:99:31: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
99 | if(i) b[i]=max(b[i],it-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:100:30: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:100:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:100:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
100 | else b[i]=max(b[i],upper_bound(a[i].begin(),a[i].end(),y-a[1][0])-a[i].begin());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s723263721 | p03770 | C++ | c#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+7;
void upd(int& x,int y){x+=y;if(x>=mod)x-=mod;}
int qpow(int a,int b){int aa=a,res=1;for(;b;b>>=1){if(b&1)res=1ll*res*aa%mod;aa=1ll*aa*aa%mod;}return res;}
int bin[N],pin[N];
void init(){bin[0]=pin[0]=1;
rep(i,1,N-1)bin[i]=1ll*bin[i-1]*i%mod;
pin[N-1]=qpow(bin[N-1],mod-2);
rep2(i,N-2,1)pin[i]=1ll*pin[i+1]*(i+1)%mod;
}
int n,X,Y,c[N],w[N],p[N],mi,sz[N],col[N],dif[N];
int find(int x){
return p[x]==x ? x : p[x]=find(p[x]);
}
void merge(int x,int y){
int px=find(x),py=find(y);
if(px==py)return;
p[py]=px,sz[px]+=sz[py];
}
bool cmp(int x,int y){return w[x]<w[y];}
vector<int> tu[N];
int main(){
init();
scanf("%d%d%d",&n,&X,&Y);
rep(i,1,n){
scanf("%d%d",&c[i],&w[i]);
p[i]=i,sz[i]=1;
col[c[i]]++;
tu[c[i]].push_back(i);
if(!mi || w[i]<w[mi])mi=i;
}
rep(i,1,n)if(tu[i].size()){
sort(tu[i].begin(),tu[i].end(),cmp);
rep(j,0,tu[i].size()-1){
int v=tu[i][j];
if(w[v] + w[tu[i][0]] <= X)merge(v,tu[i][0]);
if(w[v] + w[mi] <=Y && c[v]!=c[mi])merge(v,mi);
}
}
int tot=n;
rep(i,1,n)if(c[i]!=c[find(i)])dif[find(i)]=1;
rep(i,1,n)if(!dif[find(i)])tot--,col[c[i]]--;
int ans=bin[tot];
rep(i,1,n)ans=1ll*ans*pin[col[i]]%mod;
printf("%d\n",ans);
} | a.cc:1:2: error: stray '#' in program
1 | c#include<bits/stdc++.h>
| ^
a.cc:1:1: error: 'c' does not name a type
1 | c#include<bits/stdc++.h>
| ^
a.cc:26:1: error: 'vector' does not name a type
26 | vector<int> tu[N];
| ^~~~~~
a.cc: In function 'int main()':
a.cc:29:9: error: 'scanf' was not declared in this scope
29 | scanf("%d%d%d",&n,&X,&Y);
| ^~~~~
a.cc:34:17: error: 'tu' was not declared in this scope
34 | tu[c[i]].push_back(i);
| ^~
a.cc:37:22: error: 'tu' was not declared in this scope
37 | rep(i,1,n)if(tu[i].size()){
| ^~
a.cc:38:17: error: 'sort' was not declared in this scope; did you mean 'short'?
38 | sort(tu[i].begin(),tu[i].end(),cmp);
| ^~~~
| short
a.cc:51:9: error: 'printf' was not declared in this scope
51 | printf("%d\n",ans);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | c#include<bits/stdc++.h>
|
s694285220 | p03770 | C++ | N, X, Y = map( int, input().split() )
C = []
W = []
for i in range( N ):
c, w = map( int, input().split() )
C.append( c - 1 )
W.append( w )
c2w = [ [] for i in range( N ) ]
for i in range( N ):
c2w[ C[ i ] ].append( W[ i ] )
for i in range( N ):
c2w[ C[ i ] ].sort()
W.sort()
minw, minw2 = W[ 0 ], W[ 1 ] if 1 < N else W[ 0 ]
merged = [ False for i in range( N ) ]
hi = [ 1 for i in range( N ) ]
for i in range( N ):
if len( c2w[ i ] ) == 0: continue
lb, ub = 2, len( c2w[ i ] )
while lb <= ub:
mid = lb + ub >> 1
if c2w[ i ][ 0 ] + c2w[ i ][ mid - 1 ] <= X:
hi[ i ] = max( hi[ i ], mid )
lb = mid + 1
else:
ub = mid - 1
lb, ub = 1, len( c2w[ i ] )
www = minw2 if minw != minw2 and c2w[ i ][ 0 ] == minw else minw
while lb <= ub:
mid = lb + ub >> 1
if www + c2w[ i ][ mid - 1 ] <= Y:
hi[ i ] = max( hi[ i ], mid )
merged[ i ] = True
lb = mid + 1
else:
ub = mid - 1
MOD = int( 1e9 + 7 )
fact = [ 1 ]
inv_fact = [ 1 ]
for i in range( 1, N + 1, 1 ):
fact.append( fact[ i - 1 ] * i % MOD )
inv_fact.append( pow( fact[ i ], MOD - 2, MOD ) )
ans = fact[ sum( merged[ i ] * hi[ i ] for i in range( N ) ) ]
for i in range( N ):
if not merged[ i ]: continue
ans = ans * inv_fact[ hi[ i ] ] % MOD
print( ans )
| a.cc:1:1: error: 'N' does not name a type
1 | N, X, Y = map( int, input().split() )
| ^
|
s770062739 | p03770 | C++ | #include <cstdio>
#include <vector>
#include <unordered_map>
typedef long long ll;
constexpr int MAX_N = 200200;
constexpr int MOD = 1000000007;
using namespace std;
int n, x, y;
int col[MAX_N], weight[MAX_N];
vector<pair<int, int>> each[MAX_N];
vector<pair<int, int>> all;
vector<int> adj[MAX_N];
bool vis[MAX_N];
int dfs(int u, unordered_map<int, int> &col_cnt) {
if (vis[u]) return 0;
vis[u] = true;
int ans = 1;
col_cnt[col[u]]++;
for (int v : adj[u]) {
ans += dfs(v, col_cnt);
}
return ans;
}
int fact(int x) {
ll ans = 1;
for (int i = 1; i <= x; i++) {
ans = (ans * i) % MOD;
}
return ans;
}
int pow(int b, int e) {
if (e == 0) return 1;
ll res = pow(b, e >> 1);
res = (res * res) % MOD;
if (e & 1) res = (res * b) % MOD;
return (int) res;
}
int inv(int x) {
return pow(x, MOD - 2);
}
int permute(int cnt, unordered_map<int, int> &col_cnt) {
ll ans = fact(cnt);
for (pair<int, int> c : col_cnt) {
if (c.second > 0) {
ans = (ans * inv(fact(c.second))) % MOD;
}
}
return (int) ans;
}
int main() {
scanf(" %d %d %d", &n, &x, &y);
for (int i = 0; i < n; i++) {
scanf(" %d %d", &col[i], &weight[i]);
each[col[i]].push_back(make_pair(weight[i], i));
all.push_back(make_pair(weight[i], i));
}
sort(all.begin(), all.end());
for (int i = 1; i <= n; i++) {
sort(each[i].begin(), each[i].end());
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j < each[i].size(); j++) {
if (each[i][j].first + each[i][0].first <= x) {
adj[each[i][j - 1].second].push_back(each[i][j].second);
adj[each[i][j].second].push_back(each[i][j - 1].second);
}
}
}
for (int i = 1; i < all.size(); i++) {
if (all[i].first + all[0].first <= y) {
adj[all[i].second].push_back(all[i - 1].second);
adj[all[i - 1].second].push_back(all[i].second);
}
}
ll tot = 1;
for (int i = 0; i < n; i++) {
if (!vis[i]) {
unordered_map<int, int> col_cnt;
int cnt = dfs(i, col_cnt);
tot = (tot * permute(cnt, col_cnt)) % MOD;
}
}
printf("%lld\n", tot);
return 0;
}
| a.cc: In function 'int main()':
a.cc:70:5: error: 'sort' was not declared in this scope; did you mean 'short'?
70 | sort(all.begin(), all.end());
| ^~~~
| short
|
s160412902 | p03770 | C++ | //#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
ll n,x,y;
vector<ll>v[222222];
struct item{
ll c,w;
}a[222222];
struct tree{
ll c,w,id;
tree(){
w=(ll)1e18;
}
friend bool operator <(tree a, tree b) {
return a.w < b.w;
}
};
tree t[2222222];
int st[222222];
int en[222222];
void build(int v=1,int tl=1,int tr=n){
if(tl==tr){
t[v].c=a[tl].c;
t[v].w=a[tl].w;
t[v].id=tl;
} else {
int mid=(tl+tr)/2;
build(v+v,tl,mid);
build(v+v+1,mid+1,tr);
t[v]=min(t[v+v],t[v+v+1]);
}
}
tree get(int l,int r,int v=1,int tl=1,int tr=n){
if(tl>r||tr<l)return tree();
if (l <=tl&&tr<=r)return t[v];
int mid=(tl+tr)/2;
return min(get(l,r,v+v,tl,mid),get(l,r,v+v+1,mid+1,tr));
}
void kill(int pos,int v=1,int tl=1,int tr=n){
if(tl==tr)t[v].w=(ll)1e18;
else {
int mid=(tl+tr)/2;
if(pos<=mid)kill(pos,v+v,tl,mid);
else kill(pos,v+v+1,mid+1,tr);
t[v]=min(t[v+v],t[v+v+1]);
}
}
void read(ll &x)
{
scanf("%lld",&x);
}
bool cmp(item a, item b)
{
if(a.c!=b.c)
return a.c<b.c;
return a.w<b.w;
}
bool used[222222];
int fact[222222];
map<int, int>cnt;
int tot;
void dfs(int v){
//cout<<v<<' ';
used[v]=1;
cnt[a[v].c]++;
tot++;
kill(v);
int l=st[a[v].c];
int r=en[a[v].c];
//cout<<l<<' '<<r<<endl;
while(1){
auto it=get(l,r);
//cout<<v<<"->"<<it.id<<' '<<it.w<<endl;
if(a[v].w+it.w>x)
break;
dfs(it.id);
}
while(1){
auto it=get(1,l-1);
if(a[v].w+it.w>y)
break;
dfs(it.id);
}
while(1){
auto it=get(r+1,n);
if(a[v].w+it.w>y)
break;
dfs(it.id);
}
}
const int MOD=(int)1e9+7;
int bin(int a, int b){
int res=1;
while(b){
if(b&1)res=res*1ll*a%MOD;
b>>=1;
a=a*1ll*a%MOD;
}
return res;
}
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
cin>>n>>x>>y;
fact[0]=1;
for(int i=1;i<=n;i++)
fact[i]=fact[i-1]*1ll*i%MOD;
for(ll i=1;i<=n;i++)
read(a[i].c),read(a[i].w);
sort(a+1,a+n+1,&cmp);
for(int i=1;i<=n;i++)
st[i]=0,en[i]=-1;
for(int i=1;i<=n;i++){
if(!st[a[i].c])
st[a[i].c]=i;
en[a[i].c]=i;
}
build();
ll ans=1;
for(int i=1;i<=n;i++){
if(!used[i]){
cnt.clear();
tot=0;
dfs(i);
ans=ans*fact[tot]%MOD;
for(auto it:cnt)
ans=ans*bin(fact[it.second],MOD-2)%MOD;
//cout<<endl;
}
}
cout<<ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:120:3: error: 'sort' was not declared in this scope; did you mean 'short'?
120 | sort(a+1,a+n+1,&cmp);
| ^~~~
| short
|
s537991159 | p03770 | C++ | #include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
ll f[N]={1};
ll rf[N]={1};
ll w[N];
vector<ll> vect[N];
ll p[N];
vector<ll>g[N];
ll cnt[N];
int pos[N];
ll c[N];
ll same,notsame,n;
inline bool cmp(int x, int y)
{
return w[x]<w[y];
}
int get(int x)
{
if(p[x]==x)
return x;
return p[x]=get(p[x]);
}
inline uni(int x, int y)
{
x=get(x);
y=get(y);
if(rand()&1)
p[x]=y;
else
p[y]=x;
}
ll bin(ll x, ll k)
{
ll res=1;
while(k)
{
if(k&1)
res=res*x%mod;
x=x*x%mod;
k>>=1;
}
return res;
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>same>>notsame;
fo(i,n)
{
p[i]=i;
cin>>c[i]>>w[i];
g[c[i]].pb(i);
}
fo(i,n)
f[i]=f[i-1]*i%mod;
rf[n]=bin(f[n],mod-2);
for(int i=n-1;i>=1;--i)
rf[i]=rf[i+1]*(i+1)%mod;
multiset<pii> allw;
fo(i,n)
{
sort(g[i].begin(),g[i].end(),cmp);
allw.insert(mp(w[i],i));
}
fo(i,n)
{
if(g[i].size()>0)
{
int cur=pos[i];
int st=g[i][0];
while(pos[i]<g[i].size())
{
int x=g[i][pos[i]];
int y=st;
if(w[x]+w[y]<=same)
++pos[i];
else
break;
}
}
}
fo(i,n)
{
if(g[i].size()>0)
{
for(int e:g[i])
allw.erase(mp(w[e],e));
int y=g[i][0];
int x=allw.begin()->S;
if(w[x]+w[y]<=notsame)
uni(c[x],c[y]);
if(!allw.empty())
{
int x=allw.begin()->S;
while(pos[i]<g[i].size())
{
int y=g[i][pos[i]];
if(w[x]+w[y]<=notsame)
uni(c[x],c[y]), ++pos[i];
else
break;
}
}
for(int e:g[i])
allw.insert(mp(w[e],e));
}
}
ll ans=1;
fo(i,n)
{
int x=get(i);
vect[x].pb(i);
}
for(int i=1;i<=n;++i)
{
ll sum=0;
for(int j=0;j<vect[i].size();++j)
{
int y=vect[i][j];
sum+=pos[y];
}
ans=(ans*f[sum])%mod;
for(int j=0;j<vect[i].size();++j)
{
int y=vect[i][j];
ans=(ans*rf[pos[y]])%mod;
}
}
cout<<ans;
return 0;
} | a.cc:45:8: error: ISO C++ forbids declaration of 'uni' with no type [-fpermissive]
45 | inline uni(int x, int y)
| ^~~
a.cc: In function 'int uni(int, int)':
a.cc:53:1: warning: no return statement in function returning non-void [-Wreturn-type]
53 | }
| ^
|
s554907806 | p03770 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 7;
const int K = 20;
vector <pair <int, int> > g[N][K];
vector <int> kek[N];
bool u[N][K];
bool vis[N];
vector <int> ind, t;
void dos(int i)
{
if (vis[i])
{
return;
}
ind.push_back(i);
vis[i] = true;
for (auto to : g[i])
{
dos(to);
}
}
void dfs(int i, int k)
{
if (u[i][k])
{
return;
}
u[i][k] = true;
for (auto to : g[i][k])
{
dfs(to.first, to.second);
}
if (k == 0)
{
ind.push_back(i);
}
}
void zhfs(int i, int k)
{
if (u[i][k])
{
return;
}
u[i][k] = true;
for (auto to : g[i][k])
{
dfs(to.first, to.second);
}
if (k == 0)
{
t.push_back(i);
}
}
int bin(int a, int n)
{
if (!n)
{
return 1;
}
if (n % 2 == 0)
{
int t = bin(a, n / 2);
return (t * (ll) t) % M;
}
else
{
return (a * (ll) bin(a, n - 1)) % M;
}
}
int main()
{
#ifdef ONPC
freopen("a.in", "r", stdin);
//freopen("a.out", "w", stdout);
#else
//freopen("a.in", "r", stdin);
//freopen("a.out", "w", stdout);
#endif
int n, x, y;
scanf("%d%d%d", &n, &x, &y);
vector <int> fact(n + 1), rfact(n + 1);
fact[0] = 1;
rfact[0] = 1;
for (int i = 1; i <= n; i++)
{
fact[i] = (fact[i - 1] * (ll) i) % M;
rfact[i] = bin(fact[i], M - 2);
}
vector <pair <int, int> > d;
for (int i = 0; i < n; i++)
{
int c, w;
scanf("%d%d", &c, &w);
d.push_back({w, c});
}
sort(d.begin(), d.end());
for (int i = 0; i < n; i++)
{
if (d[0].first + d[i].first > y)
{
continue;
}
int l = 0, r = n;
while (l < r - 1)
{
int m = (l + r) / 2;
if (d[m].first + d[i].first <= y)
{
l = m;
}
else
{
r = m;
}
}
int cur = 0;
for (int p = 0; p <= l; p++)
{
g[i].push_back(p);
g[p].push_back(i);
}
}
/*
memset(u, 0, sizeof u);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < K; j++)
{
zhfs(i, j);
}
}
reverse(t.begin(), t.end());
memset(u, 0, sizeof u);
*/
ll ans = 1;
for (int i = 0; i < n; i++)
{
if (!vis[i])
{
ind.clear();
dos(i);
int sz = ind.size();
ans = (ans * (ll) fact[sz]) % M;
map <int, int> cnt;
for (auto c : ind)
{
cnt[c.second]++;
}
for (auto c : cnt)
{
ans = (ans * (ll) rfact[c.second]) % M;
}
}
}
printf("%lld\n", ans);
}
| a.cc: In function 'void dos(int)':
a.cc:27:13: error: cannot convert 'std::vector<std::pair<int, int> >' to 'int'
27 | dos(to);
| ^~
| |
| std::vector<std::pair<int, int> >
a.cc:17:14: note: initializing argument 1 of 'void dos(int)'
17 | void dos(int i)
| ~~~~^
a.cc: In function 'int main()':
a.cc:131:18: error: request for member 'push_back' in 'g[i]', which is of non-class type 'std::vector<std::pair<int, int> > [20]'
131 | g[i].push_back(p);
| ^~~~~~~~~
a.cc:132:18: error: request for member 'push_back' in 'g[p]', which is of non-class type 'std::vector<std::pair<int, int> > [20]'
132 | g[p].push_back(i);
| ^~~~~~~~~
a.cc:159:23: error: request for member 'second' in 'c', which is of non-class type 'int'
159 | cnt[c.second]++;
| ^~~~~~
|
s904618259 | p03770 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
const int NUM_=400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
ll mo=1000000007;
int N,X,Y;
pair<int,int> mi[202020];
int C[202020],W[202020];
pair<int,int> L[202020],R[202020];
template<int um> class UF {
public:
vector<int> par,rank,cnt;
UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
int count(int x) { return cnt[operator[](x)];}
int operator()(int x,int y) {
if((x=operator[](x))==(y=operator[](y))) return x;
cnt[y]=cnt[x]=cnt[x]+cnt[y];
if(rank[x]>rank[y]) return par[x]=y;
rank[x]+=rank[x]==rank[y]; return par[y]=x;
}
};
UF<202020> uf;
vector<pair<int,int>> CC[202020];
map<int,int> M[202020];
void solve() {
int i,j,k,l,r,x,y; string s;
inv[1]=fact[0]=factr[0]=1;
for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
for(i=0;i<=202000;i++) mi[i]={1<<30,0};
cin>>N>>X>>Y;
FOR(i,N) {
cin>>C[i]>>W[i];
CC[C[i]].push_back({W[i],i});
mi[C[i]]=min(mi[C[i]],{W[i],i});
}
L[0]=R[202000]={1<<30,-1};
FOR(i,202000) L[i+1]=min(L[i],mi[i+1]);
for(i=202000;i>=1;i--) R[i-1]=min(R[i],mi[i-1]);
for(i=1;i<=200000;i++) if(CC[i].size()) {
aort(ALL(CC[i]));
auto a=CC[i][0];
pair<int,int> p=min(L[i-1],R[i+1]);
FORR(r,CC[i]) if(a.first+r.first<=X) uf(a.second,r.second);
FORR(r,CC[i]) if(p.first+r.first<=Y) uf(p.second,r.second);
}
FOR(i,N) M[uf[i]][C[i]]++;
ll ret=1;
FOR(i,N) if(M[i].size()) {
x=0;
FORR(r,M[i]) x+=r.second;
(ret *= fact[x])%=mo;
FORR(r,M[i]) (ret *= factr[r.second])%=mo;
}
cout<<ret<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
| a.cc: In function 'void solve()':
a.cc:64:17: error: 'aort' was not declared in this scope; did you mean 'abort'?
64 | aort(ALL(CC[i]));
| ^~~~
| abort
|
s652189332 | p03770 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 7;
const int K = 20;
vector <pair <int, int> > g[N][K];
bool u[N][K];
vector <int> ind, t;
void dfs(int i, int k)
{
if (u[i][k])
{
return;
}
u[i][k] = true;
for (auto to : g[i][k])
{
dfs(to.first, to.second);
}
if (k == 0)
{
ind.push_back(i);
}
}
void zhfs(int i, int k)
{
if (u[i][k])
{
return;
}
u[i][k] = true;
for (auto to : g[i][k])
{
dfs(to.first, to.second);
}
if (k == 0)
{
t.push_back(i);
}
}
int bin(int a, int n)
{
if (!n)
{
return 1;
}
if (n % 2 == 0)
{
int t = bin(a, n / 2);
return (t * (ll) t) % M;
}
else
{
return (a * (ll) bin(a, n - 1)) % M;
}
}
int main()
{
#ifdef ONPC
freopen("a.in", "r", stdin);
//freopen("a.out", "w", stdout);
#else
//freopen("a.in", "r", stdin);
//freopen("a.out", "w", stdout);
#endif
int n, x, y;
scanf("%d%d%d", &n, &x, &y);
vector <int> fact(n + 1), rfact(n + 1);
fact[0] = 1;
rfact[0] = 1;
for (int i = 1; i <= n; i++)
{
fact[i] = (fact[i - 1] * (ll) i) % M;
rfact[i] = bin(fact[i], M - 2);
}
vector <pair <int, int> > d;
for (int i = 0; i < n; i++)
{
int c, w;
scanf("%d%d", &c, &w);
d.push_back({w, c});
}
sort(d.begin(), d.end());
for (int i = 0; i < n; i++)
{
for (int j = 1; j < K; j++)
{
g[i][j].push_back({i, j - 1});
if (i + (1 << (j - 1)) < n)
{
g[i][j].push_back({i + (1 << (j - 1)), j - 1});
}
}
}
for (int i = 0; i < n; i++)
{
if (d[0].first + d[i].first > y)
{
continue;
}
int l = 0, r = n;
while (l < r - 1)
{
int m = (l + r) / 2;
if (d[m].first + d[i].first <= y)
{
l = m;
}
else
{
r = m;
}
}
int cur = 0;
for (int p = K - 1; p >= 0; p--)
{
if (cur + (1 << p) - 1 <= l)
{
g[i][0].push_back({cur, p});
cur += (1 << p);
}
}
}
memset(u, 0, sizeof u);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < K; j++)
{
zhfs(i, j);
}
}
reverse(t.begin(), t.end());
memset(u, 0, sizeof u);
ll ans = 1;
for (int i : t)
{
if (!u[i][j])
{
ind.clear();
dfs(i, 0);
int sz = ind.size();
map <int, int> cnt;
for (auto c : ind)
{
cnt[d[c].second]++;
}
ans = (ans * (ll) fact[sz]) % M;
for (auto c : cnt)
{
ans = (ans * (ll) rfact[c.second]) % M;
}
}
}
printf("%lld\n", ans);
}
| a.cc: In function 'int main()':
a.cc:146:19: error: 'j' was not declared in this scope
146 | if (!u[i][j])
| ^
|
s186907179 | p03771 | C++ | /*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
#define pii pair<int,int>
#define fst first
#define scd second
#define mp make_pair
using namespace std;
const int inf=0x3f3f3f3f;
const int Maxn=(1<<19)+5;
const int N=2e5+5;
const int M=20;
int read(){
int s=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
return s*f;
}
pii P[N];
int n,V,cnt,tot,Sta,a[N],L[N][M],R[N][M],Ans[N],FL[Maxn],FR[Maxn];
int main(){
// freopen("_.in","r",stdin);
// freopen("_.out","w",stdout);
n=read();V=read();
for(int i=1;i<=n;i++)a[i]=read();a[0]=-inf-v-1;a[n+1]=inf+v+1;
for(int v=V;;v>>=1){
tot++;L[tot][0]=0;R[tot][n+1]=n+1;
for(int i=1;i<=n;i++)L[tot][i]=(a[i]-a[i-1]<=v?L[tot][i-1]:i);
for(int i=n;i>=1;i--)R[tot][i]=(a[i+1]-a[i]<=v?R[tot][i+1]:i);
if(v==0)break;
}
Sta=(1<<tot)-1;
for(int i=1;i<=n;i++)P[i]=mp(L[1][i],R[1][i]);
sort(P+1,P+n+1);cnt=unique(P+1,P+n+1)-P-1;
for(int S=0;S<=Sta;S++){FL[S]=0;FR[S]=n+1;}
for(int S=0;S<=Sta;S+=2){
for(int i=1;i<=tot;i++){
if(!((S>>(i-1))&1))continue;
FL[S]=max(FL[S],R[i][FL[S^(1<<(i-1))]+1]);
FR[S]=min(FR[S],L[i][FR[S^(1<<(i-1))]-1]);
}
}
if(cnt>tot){for(int i=1;i<=tot;i++)puts("Impossible");return 0;}
for(int i=1;i<=cnt;i++){
for(int S=0;S<=Sta;S+=2){
if(FL[S]>=P[i].fst-1&&FR[Sta^S^1]<=P[i].scd+1){
for(int j=P[i].fst;j<=P[i].scd;j++)Ans[j]=1;
break;
}
}
}
for(int i=1;i<=n;i++)puts(Ans[i]?"Possible":"Impossible");
return 0;
} | a.cc: In function 'int main()':
a.cc:37:52: error: 'v' was not declared in this scope
37 | for(int i=1;i<=n;i++)a[i]=read();a[0]=-inf-v-1;a[n+1]=inf+v+1;
| ^
|
s800948047 | p03771 | C++ | #include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int x[252521];
int ne[252521][20],rne[252521][20];
int dp[(1<<20)+10],rdp[(1<<20)+10];
vector<int> v;
int main()
{
int n,V;
cin>>n>>V;
rep(i,n) cin>>x[i];
while(V>0){
v.pb(V);V/=2;
}
v.pb(0);int m=v.size();
rep(i,n) rep(j,m){
rne[i][j]=i;
if(i>0 && x[i]-x[i-1]<=v[j]) rne[i][j]=rne[i-1][j];
}
for(int i=n-1;i>=0;i--) rep(j,m){
ne[i][j]=i;
if(i<n-1 && x[i+1]-x[i]<=v[j]) ne[i][j]=ne[i+1][j];
}
memset(dp,0,sizeof(dp));
rep(i,(1<<20)+5) rdp[i]=n-1;
rep(i,(1<<m)) rep(j,m){
if((i&(1<<j))>0) continue;
dp[i+(1<<j)]=max(dp[i+(1<<j)],ne[dp[i]][j]+1);
rdp[i+(1<<j)]=min(rdp[i+(1<<j)],rne[rdp[i]][j]-1);
}
//rep(i,(1<<m)) cout<<i<<' '<<dp[i]<<' '<<rdp[i]<<endl;
if(dp[(1<<m)-1]<n || rdp[(1<<m)-1]>=0){
assert(dp[(1<<m)-1]<n && rdp[(1<<m)-1]>=0)
rep(i,n) cout<<"Impossible"<<endl;
return 0;
}
int now=0;
while(now<n){
int f=0;
rep(i,(1<<(m-1))){
if(dp[(1<<m)-2-(i<<1)]>=now && rdp[(i<<1)]<=ne[now][0]) f=1;
}
REP(i,now,ne[now][0]+1){
if(f>0) cout<<"Possible"<<endl;
else cout<<"Impossible"<<endl;
}
now=ne[now][0]+1;
}
}
| a.cc: In function 'int main()':
a.cc:32:20: error: expected ';' before 'for'
32 | #define REP(i,a,b) for(int i=a;i<b;i++)
| ^~~
a.cc:33:18: note: in expansion of macro 'REP'
33 | #define rep(i,n) REP(i,0,n)
| ^~~
a.cc:65:17: note: in expansion of macro 'rep'
65 | rep(i,n) cout<<"Impossible"<<endl;
| ^~~
a.cc:65:21: error: 'i' was not declared in this scope
65 | rep(i,n) cout<<"Impossible"<<endl;
| ^
a.cc:32:32: note: in definition of macro 'REP'
32 | #define REP(i,a,b) for(int i=a;i<b;i++)
| ^
a.cc:65:17: note: in expansion of macro 'rep'
65 | rep(i,n) cout<<"Impossible"<<endl;
| ^~~
|
s083763167 | p03771 | C++ | #include <cstdio>
#include <iostream>
#define ri register int
using namespace std;
const int N = 2e5 + 50;
int n, v, m;
int a[N], f[N], g[N];
int lb[N], rb[N], ans[N];
int pre[1 << 18 | 5][18], nxt[1 << 18 | 5][18];
int main() {
scanf("%d%d", &n, &v);
for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
for (int t = v; t; t >>= 1) m ++;
for (int j = 0; j < m; j ++)
nxt[n + 1][j] = n + 1;
lb[0] = 1; rb[n + 1] = n;
for (ri i = 1; i <= n; i ++) {
lb[i] = (a[i] - a[i - 1] > v) ? i : lb[i - 1];
for (ri j = 1; j < m; j ++)
pre[i][j] = ((a[i] - a[i - 1]) > (v >> j)) ? i - 1 : pre[i - 1][j];
}
for (ri i = n; i; i --) {
rb[i] = (a[i + 1] - a[i] > v) ? i : rb[i + 1];
for (ri j = 1; j < m; j ++)
nxt[i][j] = ((a[i + 1] - a[i]) > (v >> j)) ? i + 1 : nxt[i + 1][j];
}
for (ri i = 0, l, r; i < (1 << m); i += 2) {
l = 1; r = n;
for (ri j = 1; j < m; j ++)
if ((i >> j) & 1) {
l = max(l, nxt[f[i ^ (1 << j)]][j]);
r = min(r, pre[g[i ^ (1 << j)]][j]);
}
f[i] = l; g[i] = r;
}
int U =
for (ri i = 0; i < (1 << m); i += 2) {
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:20:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
20 | for (ri i = 1; i <= n; i ++) {
| ^
a.cc:22:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
22 | for (ri j = 1; j < m; j ++)
| ^
a.cc:25:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
25 | for (ri i = n; i; i --) {
| ^
a.cc:27:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
27 | for (ri j = 1; j < m; j ++)
| ^
a.cc:30:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
30 | for (ri i = 0, l, r; i < (1 << m); i += 2) {
| ^
a.cc:30:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
30 | for (ri i = 0, l, r; i < (1 << m); i += 2) {
| ^
a.cc:30:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
30 | for (ri i = 0, l, r; i < (1 << m); i += 2) {
| ^
a.cc:32:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | for (ri j = 1; j < m; j ++)
| ^
a.cc:40:3: error: expected primary-expression before 'for'
40 | for (ri i = 0; i < (1 << m); i += 2) {
| ^~~
a.cc:40:18: error: 'i' was not declared in this scope
40 | for (ri i = 0; i < (1 << m); i += 2) {
| ^
|
s504172224 | p03771 | C++ | //2018-1-18
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;
#define Set(a, v) memset(a, v, sizeof(a))
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define M 18
#define N (100000+5)
int n, m, dn, pos[N], dis[M], nxt[N][M], beg[N], end[N];
int f[1<<M];
bool Solve(int l, int r){
if(l == 1 && r == n) return true;
f[0] = 0;
int tmp;
For(i, 1, (1<<dn)-1){
f[i] = 0;
For(j, 1, dn) if(i & (1<<(j-1))){
tmp = f[i ^ (1<<(j-1))] + 1;
if(tmp >= l && tmp <= r) tmp = r+1;
f[i] = max(f[i], nxt[tmp][j]);
if(f[i]+1 >= l && f[i]+1 <= r) f[i] = r;
}
if(f[i] >= n) return true;
}
return false;
}
int main(){
scanf("%d%d", &n, &m);
For(i, 1, n) scanf("%d", &pos[i]);
int st, ed, cnt = 0;
for(int d = m; d >= 0; d >>= 1){
st = 1; if(d != m) dis[++dn] = d;
while(st <= n){
ed = st;
while(ed < n && pos[ed+1]-pos[ed] <= d) ++ed;
For(i, st, ed) nxt[i][dn] = ed;
if(d == m){
beg[++cnt] = st; end[cnt] = ed;
}
st = ed+1;
}
if(!d) break;
}
For(i, 1, dn) nxt[n+1][i] = n+1;
// For(i, 1, n) For(j, 1, dn) printf("nxt[%d][%d] = %d\n", i, j, nxt[i][j]);
if(cnt > dn+1){
For(i, 1, n) puts("Impossible"); return 0;
}
For(si, 1, cnt){
// printf("%d -> %d free\n", beg[si], end[si]);
if(Solve(beg[si], end[si])){
For(i, beg[si], end[si]) puts("Possible");
}else{
For(i, beg[si], end[si]) puts("Impossible");
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:50:50: error: reference to 'end' is ambiguous
50 | beg[++cnt] = st; end[cnt] = ed;
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:4:
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/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 /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/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:13:50: note: 'int end [100005]'
13 | int n, m, dn, pos[N], dis[M], nxt[N][M], beg[N], end[N];
| ^~~
a.cc:67:35: error: reference to 'end' is ambiguous
67 | if(Solve(beg[si], end[si])){
| ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) 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:13:50: note: 'int end [100005]'
13 | int n, m, dn, pos[N], dis[M], nxt[N][M], beg[N], end[N];
| ^~~
a.cc:68:41: error: reference to 'end' is ambiguous
68 | For(i, beg[si], end[si]) puts("Possible");
| ^~~
a.cc:8:50: note: in definition of macro 'For'
8 | #define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
| ^
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) 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:13:50: note: 'int end [100005]'
13 | int n, m, dn, pos[N], dis[M], nxt[N][M], beg[N], end[N];
| ^~~
a.cc:70:41: error: reference to 'end' is ambiguous
70 | For(i, beg[si], end[si]) puts("Impossible");
| ^~~
a.cc:8:50: note: in definition of macro 'For'
8 | #define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
| ^
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) 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:13:50: note: 'int end [100005]'
13 | int n, m, dn, pos[N], dis[M], nxt[N][M], beg[N], end[N];
| ^~~
|
s718115655 | p03771 | C++ |
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
namespace INPUT{
const int L=1<<15;
char _buf[L],*S,*T,c;
char _gc(){
if(S==T){
T=(S=_buf)+fread(_buf,1,L,stdin);
if(S==T) return EOF;
}
return *S++;
}
void readi(int &X){
register bool flag;
for(c=_gc();(c<'0'||c>'9')&&c!='-';c=_gc());
if(c=='-') X=0,flag=true; else X=c&15,flag=false;
for(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());
if(flag) X=-X;
}
}
using INPUT::readi;
const int Maxn=4E5+5;
int N,M,K,V;
int a[Maxn];
int F[Maxn],G[Maxn];
int L[25][Maxn],R[25][Maxn];
char Ans[50],_1[50]={"Possible"},_2[50]={"Impossible"};
//int nxt[Maxn];
inline void MIN(int &x,int y){if(x>y)x=y;}
inline void MAX(int &x,int y){if(x<y)x=y;}
int main(){
readi(N),readi(V);
while(V>>M) ++M;
for(int i=1;i<=N;++i) readi(a[i]);
for(int i=0;i<=M;++i){
L[i][1]=1;
for(int j=2;j<=N;++j)
if(a[j]-a[j-1]>(V>>i)) L[i][j]=j;
for(int j=2;j<=N;++j)
if(L[i][j]==0) L[i][j]=L[i][j-1];
R[i][N]=N;
for(int j=N-1;j>=1;--j)
if(a[j+1]-a[j]>(V>>i)) R[i][j]=j;
for(int j=N-1;j>=1;--j)
if(R[i][j]==0) R[i][j]=R[i][j+1];
}
G[0]=N+1;
for(int i=1;i<(1<<M);++i){
G[i]=N+1;
for(int j=0;j<M;++j)
if((i>>j)&1)
MAX(F[i],R[M-j][min(F[i-(1<<j)]+1,N)]),
MIN(G[i],L[M-j][max(G[i-(1<<j)]-1,1)]);
}
/* for(int i=1;i<=N;++i)
K+=(L[0][i]!=L[0][i-1]);
if(K>20){
for(int i=1;i<=N;++i)
puts("Impossible");
return 0;
}
for(int i=1,j;i<=N;++i)
if(L[0][i]!=L[0][i-1]){
for(j=0;j<(1<<M);++j)
if(F[j]>=L[0][i]-1 && G[(1<<M)-1-j]<=R[0][i]+1)
{memcpy(Ans,_1,sizeof(_1)); break ;}
if(j==1<<M) memcpy(Ans,_2,sizeof(_2));
printf("%s\n",Ans);
}else printf("%s\n",Ans);*/
memset(nxt,-1,sizeof(nxt));
for(int i=0;i<(1<<M);++i) MAX(nxt[G[(1<<M)-1-i]],F[i]);
for(int i=1;i<=N+1;++i) MAX(nxt[i],nxt[i-1]);
for(int i=1;i<=N;++i)
if(nxt[R[0][i]+1]>=L[0][i]-1)
puts("Possible");
else
puts("Impossible");
return 0;
}
| a.cc: In function 'void INPUT::readi(int&)':
a.cc:20:31: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
20 | register bool flag;
| ^~~~
a.cc: In function 'int main()':
a.cc:81:16: error: 'nxt' was not declared in this scope
81 | memset(nxt,-1,sizeof(nxt));
| ^~~
|
s469540688 | p03771 | C++ | #include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1)
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
num=0;T f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
freopen("input.txt","r",stdin);
}
//********************************head*************************************
const int maxn=1e6+5;
int n,m;
int v,x[maxn],rj[maxn][25],lj[maxn][25];
int lx[maxn],rx[maxn];
int mn[maxn];
int main(){
read(n);read(v);
rep(i,1,n)read(x[i]);
while((1<<m)<=V)m++;m++;
rep2(i,0,m){
lj[0][i]=1;
rep(j,1,n)lj[j][i]=(x[j]-x[j-1]<=(V>>i))?lj[j-1][i]:j;
rj[n+1][i]=n;
per(j,n,1)rj[j][i]=(x[j+1]-x[j]<=(V>>i))?rj[j+1][i]:j;
}
rep2(i,0,1<<m)rx[i]=n+1;
rep2(i,0,1<<m)rep2(j,0,m)if(!(i&(1<<j))){
lx[i|(1<<j)]=max(lx[i|(1<<j)],rj[lx[i]+1][j]);
rx[i|(1<<j)]=min(rx[i|(1<<j)],lj[rx[i]-1][j]);
}
rep(i,0,n)mn[i]=n+2;
rep2(i,0,1<<m)if(!(i&1))mn[lx[i]]=min(mn[lx[i]],rx[((1<<m)-1)^i^1]);
per(i,n-1,0)mn[i]=min(mn[i],mn[i+1]);
rep(i,1,n){
if(mn[lj[i][0]-1]<=rj[i][0]+1)puts("Possible");
else puts("Impossible");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:61:23: error: 'V' was not declared in this scope
61 | while((1<<m)<=V)m++;m++;
| ^
a.cc:64:51: error: 'V' was not declared in this scope
64 | rep(j,1,n)lj[j][i]=(x[j]-x[j-1]<=(V>>i))?lj[j-1][i]:j;
| ^
a.cc:66:51: error: 'V' was not declared in this scope
66 | per(j,n,1)rj[j][i]=(x[j+1]-x[j]<=(V>>i))?rj[j+1][i]:j;
| ^
|
s476884811 | p03771 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,x[N],d[20],id,dep;
struct array{
int L[N],R[N],l[N],r[N],cnt;
void init(int dep);
}a[20];
void array::init(int dep){
int dis=d[dep];
cnt++;L[1]=R[1]=x[1];
for (int i=2;i<=n;i++){
if (x[i]<=R[cnt]+dis) R[cnt]=x[i];else
cnt++,L[cnt]=R[cnt]=x[i];
}
int m=a[dep+1].cnt,*ll=a[dep+1].L,*rr=a[dep+1].R;
l[0]=r[0]=1;
for (int i=1;i<=cnt;i++){
for (l[i]=l[i-1];l[i]<m&&rr[l[i]]<L[i];l[i]++);
for (r[i]=r[i-1];r[i]<m&&ll[r[i]+1]<=R[i];r[i]++);
}
}
int q[20][N],size[20];
inline void push(int h,int v){
for (int i=a[h].l[v];i<=a[h].r[v];i++) q[h+1][++size[h+1]]=i;
}
bool check(int h){
if (!size[h]) return 1;
if (size[h]>dep-h+1) return 0;
for (int i=1;i<=size[h];i++){
size[h+1]=0;
for (int j=1;j<=size[h];j++)
if (i!=j) push(h,q[h][j]);
if (check(h+1)) return 1;
}
return 0;
}
bool ans[N],ok[N];
int main()
{
scanf("%d%d",&n,&d[0]);
while (d[dep]) d[dep+1]=d[dep]>>1,dep++;
a[dep].cnt=n;
for (int i=1;i<=n;i++) scanf("%d",&x[i]),a[dep].L[i]=a[dep].R[i]=x[i];
for (int i=dep-1;i>=0;i--) a[i].init(i);
for (int i=1;i<=a[0].cnt;i++){
size[1]=0;
for (int j=1;j<=a[0].cnt;j++)
if (i!=j) push(0,j);
ok[i]=check(1);
}
for (int i=1,p=1;i<=n;i++){
while (x[i]>a[0].R[p]) p++;
puts(ok[p]?"Possible":"Impossible");
}
return 0;
} | a.cc:9:6: error: reference to 'array' is ambiguous
9 | void array::init(int dep){
| ^~~~~
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:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
99 | struct array;
| ^~~~~
a.cc:5:8: note: 'struct array'
5 | struct array{
| ^~~~~
a.cc: In function 'void init(int)':
a.cc:11:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
11 | cnt++;L[1]=R[1]=x[1];
| ^~~
| int
a.cc:11:15: error: 'L' was not declared in this scope
11 | cnt++;L[1]=R[1]=x[1];
| ^
a.cc:11:20: error: 'R' was not declared in this scope
11 | cnt++;L[1]=R[1]=x[1];
| ^
a.cc:17:9: error: 'l' was not declared in this scope; did you mean 'll'?
17 | l[0]=r[0]=1;
| ^
| ll
a.cc:17:14: error: 'r' was not declared in this scope; did you mean 'rr'?
17 | l[0]=r[0]=1;
| ^
| rr
a.cc: In function 'void push(int, int)':
a.cc:25:57: error: reference to 'size' is ambiguous
25 | for (int i=a[h].l[v];i<=a[h].r[v];i++) q[h+1][++size[h+1]]=i;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:23:14: note: 'int size [20]'
23 | int q[20][N],size[20];
| ^~~~
a.cc: In function 'bool check(int)':
a.cc:28:14: error: reference to 'size' is ambiguous
28 | if (!size[h]) return 1;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:23:14: note: 'int size [20]'
23 | int q[20][N],size[20];
| ^~~~
a.cc:29:13: error: reference to 'size' is ambiguous
29 | if (size[h]>dep-h+1) return 0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:23:14: note: 'int size [20]'
23 | int q[20][N],size[20];
| ^~~~
a.cc:30:25: error: reference to 'size' is ambiguous
30 | for (int i=1;i<=size[h];i++){
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:23:14: note: 'int size [20]'
23 | int q[20][N],size[20];
| ^~~~
a.cc:31:17: error: reference to 'size' is ambiguous
31 | size[h+1]=0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:23:14: note: 'int size [20]'
23 | int q[20][N],size[20];
| ^~~~
a.cc:32:33: error: reference to 'size' is ambiguous
32 | for (int j=1;j<=size[h];j++)
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:23:14: note: 'int size [20]'
23 | int q[20][N],size[20];
| ^~~~
a.cc: In function 'int main()':
a.cc:47:17: error: reference to 'size' is ambiguous
47 | size[1]=0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:23:14: note: 'int size [20]'
23 | int q[20][N],size[20];
| ^~~~
|
s946701738 | p03771 | C++ | #include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define K 20
int n,m,v,a[N],l[N][K],r[N][K],f[N],g[N],h[N];
int read(){
int x=0,f=1;char ch=getchar();
for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
return x*f;
}
int main(){
n=read();v=read();
for (int i=1;i<=n;i++) a[i]=read();
while (true){
l[1][m]=1;r[n][m]=n;
l[0][m]=1;r[n+1][m]=n;
for (int i=2;i<=n;i++)
l[i][m]=(a[i]-a[i-1]<=v)?l[i-1][m]:i;
for (int i=n-1;i>=1;i--)
r[i][m]=(a[i+1]-a[i]<=v)?r[i+1][m]:i;
m++;if (!v) break;v/=2;
}
fill(g,g+(1<<m),n+1);
for (int i=2;i<(1<<m);i+=2){
for (int j=1;j<m;j++)
if (i&(1<<j))
f[i]=max(f[i],r[f[i-(1<<j)]+1][j]),
g[i]=min(g[i],l[g[i-(1<<j)]-1][j]);
fill(h,h+n+1,0x3fffffff);
for (int i=0;i<(1<<m);i+=2)
h[f[i]]=min(h[f[i]],g[(1<<m)-2-i]);
for (int i=n-1;i>=0;i--)
h[i]=min(h[i],h[i+1]);
for (int i=1;i<=n;i++)
printf((h[l[i][0]-1]<=r[i][0]+1)?"Possible\n":"Impossible\n");
return 0;
} | a.cc: In function 'int main()':
a.cc:40:2: error: expected '}' at end of input
40 | }
| ^
a.cc:14:11: note: to match this '{'
14 | int main(){
| ^
|
s559929564 | p03771 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
const int MAXN = 200000 + 1000;
const int MAXM = 1048576;
const int MAXK = 20;
int n, m, V;
int a[MAXN], v[MAXK];
int f[MAXM], g[MAXM];
int next[MAXN][MAXK], prev[MAXN][MAXK];
int ans[MAXN];
void yes()
{
cout << "Possible" << endl;
}
void no()
{
cout << "Impossible" << endl;
}
void init()
{
for(m = 0; V; V /= 2, m++)
v[m] = V;
v[m++] = 0;
for(int i = 0; i <= m - 1; i++)
next[n + 1][i] = next[n][i] = n;
for(int i = n - 1; i >= 1; i--)
for(int j = 0; j <= m - 1; j++)
next[i][j] = (a[i + 1] - a[i] <= v[j] ? next[i + 1][j] : i);
for(int i = 0; i <= m - 1; i++)
prev[0][i] = prev[1][i] = 1;
for(int i = 2; i <= n; i++)
for(int j = 0; j <= m - 1; j++)
prev[i][j] = (a[i] - a[i - 1] <= v[j] ? prev[i - 1][j] : i);
}
void work()
{
f[0] = 0;
for(int i = 1; i < (1 << m); i++)
{
f[i] = 0;
for(int j = 0; j < m; j++)
if((i >> j) & 1)
f[i] = max(f[i], next[f[i ^ (1 << j)] + 1][j]);
}
g[0] = n + 1;
for(int i = 1; i < (1 << m); i++)
{
g[i] = n + 1;
for(int j = 0; j < m; j++)
if((i >> j) & 1)
g[i] = min(g[i], prev[g[i ^ (1 << j)] - 1][j]);
}
for(int i = 0; i < (1 << m); i++)
{
int s1 = i, s2 = ((1 << m) - 1) ^ i;
s1 = s1 & ~1, s2 = s2 & ~1;
int p = f[s1], q = g[s2];
if(p + 1 > q - 1)
{
for(int j = 1; j <= n; j++)
yes();
return ;
}
if(next[p + 1][0] >= q - 1)
ans[p + 1] += 1, ans[q - 1 + 1] -= 1;
}
for(int i = 1; i <= n; i++)
ans[i] += ans[i - 1];
for(int i = 1; i <= n; i++)
ans[i] > 0 ? yes() : no();
// for(int i = 1; i <= n; i++)
// cerr << ans[i] << endl;
}
int main()
{
ios::sync_with_stdio(false);
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
cin >> n >> V;
for(int i = 1; i <= n; i++)
cin >> a[i];
init();
work();
return 0;
}
| a.cc: In function 'void init()':
a.cc:41:17: error: reference to 'next' is ambiguous
41 | next[n + 1][i] = next[n][i] = n;
| ^~~~
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:21:5: note: 'int next [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:41:34: error: reference to 'next' is ambiguous
41 | next[n + 1][i] = next[n][i] = n;
| ^~~~
/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:21:5: note: 'int next [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:44:25: error: reference to 'next' is ambiguous
44 | next[i][j] = (a[i + 1] - a[i] <= v[j] ? next[i + 1][j] : i);
| ^~~~
/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:21:5: note: 'int next [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:44:65: error: reference to 'next' is ambiguous
44 | next[i][j] = (a[i + 1] - a[i] <= v[j] ? next[i + 1][j] : i);
| ^~~~
/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:21:5: note: 'int next [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:47:17: error: reference to 'prev' is ambiguous
47 | prev[0][i] = prev[1][i] = 1;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:21:23: note: 'int prev [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:47:30: error: reference to 'prev' is ambiguous
47 | prev[0][i] = prev[1][i] = 1;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:21:23: note: 'int prev [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:50:25: error: reference to 'prev' is ambiguous
50 | prev[i][j] = (a[i] - a[i - 1] <= v[j] ? prev[i - 1][j] : i);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:21:23: note: 'int prev [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:50:65: error: reference to 'prev' is ambiguous
50 | prev[i][j] = (a[i] - a[i - 1] <= v[j] ? prev[i - 1][j] : i);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:21:23: note: 'int prev [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc: In function 'void work()':
a.cc:61:50: error: reference to 'next' is ambiguous
61 | f[i] = max(f[i], next[f[i ^ (1 << j)] + 1][j]);
| ^~~~
/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:21:5: note: 'int next [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:69:50: error: reference to 'prev' is ambiguous
69 | g[i] = min(g[i], prev[g[i ^ (1 << j)] - 1][j]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:21:23: note: 'int prev [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
a.cc:83:20: error: reference to 'next' is ambiguous
83 | if(next[p + 1][0] >= q - 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:21:5: note: 'int next [201000][20]'
21 | int next[MAXN][MAXK], prev[MAXN][MAXK];
| ^~~~
|
s273222346 | p03771 | C++ | # include <bits/stdc++.h>
using namespace std;
int N, V;
const int maxn = 200010;
bool f[maxn][1<<20];
bool g[maxn][1<<20];
int x[maxn], l[maxn][20], r[maxn][20];
int val[20];
int m, mask;
int main() {
scanf("%d%d", &N, &V);
for(int i = 0; i < N; ++i) scanf("%d", &x[i]);
for(int v = V; v; v /= 2) val[m++] = v;
mask = (1 << m) - 1;
for(int i = 0; i < N; ++i) {
for(int j = 0; j < m; ++j) {
l[i][j] = i;
if(i && x[i] - x[i-1] <= val[j]) l[i][j] = l[i-1][j];
}
}
for(int i = N - 1; i >= 0; ++i) {
for(int j = 0; j < m; ++j) {
r[i][j] = i;
if(i + 1 < N && x[i] - x[i-1] <= val[j]) r[i][j] = r[i+1][j];
}
}
for(int j = 0; j < 1<<m; ++j) {
f[0][j] = true;
}
for(int i = 1; i < N; ++i) {
for(int j = 0; j < 1<<m; ++j) {
for(int k = 0; k < m; ++k) if(j >> k & 1) {
f[i][j] |= f[max(0, l[i][k] - 1)][j ^ (1<<k)];
if(f[i][j]) break;
}
}
}
g[N][0] = true;
for(int i = N - 1; i >= 0; --i) {
for(int j = 0; j < 1<m; ++j) {
for(int k = 0; k < m; ++k) if(j >> k & 1) {
g[i][j] |= g[r[i][k] + 1][j ^ (1<<k)];
if(g[i][j]) break;
}
}
}
for(int i = 0, j; i < N; i = j) {
for(j = i + 1; j < N && x[j] - x[j-1] <= V; ++j);
bool flag = false;
for(int k = 0; k < 1<<m; ++k)
if(f[i][k] && g[j][k ^ mask]) { flag = true; break; }
if(flag) {
for(int k = i; k < j; ++k) puts("Possible");
} else {
for(int k = i; k < j; ++k) puts("Impossible");
}
}
return 0;
}
| /tmp/cc5dBexW.o: in function `main':
a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0x86): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0x8f): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0xbe): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0xd2): relocation truncated to fit: R_X86_64_PC32 against symbol `mask' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0x116): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0x154): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `val' defined in .bss section in /tmp/cc5dBexW.o
a.cc:(.text+0x1a5): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s353872915 | p03771 | C | #include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pb2 pop_back
#define pf push_front
#define pf2 pop_front
#define line printf("\n")
#define rep(k,i,j) for(int k = (int)i;k<(int) j;k++)
#define repd(k,i,j) for(int k = i;k>=(int)j;k--)
#define ll long long
#define pq priority_queue
int dirx[8] = {0,1,0,-1,1,1,-1,-1};
int diry[8] = {1,0,-1,0,1,-1,1,-1};
const int INF = 1e9+7;
const ll INFLL = 1e16;
const double EPS = 1e-6;
using namespace std;
const int maxn = 5e5+5;
int n,v;
int loc[maxn];
int jump[maxn][20],m;
int dp[maxn];
int ch[maxn];
int in_q[maxn];
queue<int> q;
int solve(){
memset(dp,-1,sizeof dp);
memset(in_q,0,sizeof in_q);
q.push(1);
dp[1] = ch[0];
in_q[1] = 1;
while(q.size()){
int mask = q.front();
int a = dp[mask];
q.pop();
in_q[mask] = 0;
if(a==n)return 1;
rep(k,0,m)if(((1<<k)&mask)==0){
int b = ch[jump[a][k]];
int maskb = (mask|(1<<k));
if(dp[maskb]<b){
dp[maskb] = b;
if(!in_q[maskb])q.push(maskb),in_q[maskb] = 1;
}
}
}
return 0;
}
int main(){
scanf("%d%d",&n,&v);
rep(k,0,n)scanf("%d",&loc[k]);
for(;v>=0;v/=2){
rep(k,0,n){
int i = k;
while(i<n){
if(i<n-1 && loc[i+1]-loc[i]<=v){
i++;
}
else break;
}
while(k<=i)jump[k++][m] = i+1;
k = i;
}
//printf("%d \n",v);
m++;
if(v==0)break;
}
if(m>=20)return 0;
rep(k,0,maxn)ch[k] = k;
int hit = 0;
rep(k,0,n){
if(hit>18){
printf("Impossible\n");
continue;
}
int nxt = jump[k][0];
hit++;
ch[k] = nxt;
int ret = solve();
ch[k] = k;
while(k<nxt)printf("%s\n",ret?"Possible":"Impossible"),k++;
k = nxt-1;
}
return 0;
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s664605845 | p03771 | C | #include<stdio.h>
#include<string.h>
#define N_MAX 200000
#define GROUP_MAX 18
#define DP_SIZE ((N_MAX+31)/32)
typedef struct tag_group_t
{
int l, r, is_invalid;
}group_t;
unsigned long dp[GROUP_MAX][DP_SIZE];
group_t g_group[GROUP_MAX+1][GROUP_MAX+1];
int group_num;
int n, v;
int x[N_MAX];
int group_max_calc(int v)
{
int i;
if(v<0) return 0;
for(i=0;(1<<i)<=v;i++)
;
return i+1;
}
int group_calc(group_t d[], group_t s[], int s_num, int v)
{
int i, j;
int d_num=0, d_num_limit;
d_num_limit=group_max_calc(v);
//printf("v=%d d_num_limit=%d\n", v, d_num_limit);
for(i=0;i<s_num;i++)
{
if(s[i].is_invalid) continue;
d[d_num].l=s[i].l;
d[d_num].is_invalid=0;
for(j=s[i].l;j<s[i].r;j++)
{
if(x[j+1]-x[j]>v)
{
d[d_num++].r=j;
if(d_num>=d_num_limit) return -1;
d[d_num].l=j+1;
d[d_num].is_invalid=0;
}
}
d[d_num++].r=j;
}
return d_num;
}
int calc(group_t group[], int group_num, int depth)
{
group_t *group2;
int group2_num;
int i, v2, ret=0;
group2=g_group[depth];
v2=(v>>depth);
group2_num=group_calc(group2, group, group_num, v2);
if(group2_num<0) return 0;
if(0)
{
printf("group_num=%d depth=%d v=%d", group_num, depth, v);
for(i=0;i<group_num;i++)
{
// if(group[i].is_invalid) continue;
printf(" %d-%d[%d]", group[i].l, group[i].r, group[i].is_invalid);
}
printf("\n");
}
if(0)
{
printf("group2_num=%d depth=%d v2=%d", group2_num, depth, v2);
for(i=0;i<group2_num;i++)
{
// if(group2[i].is_invalid) continue;
printf(" %d-%d[%d]", group2[i].l, group2[i].r, group2[i].is_invalid);
}
printf("\n");
}
if(v2<=0)
{
return (group2_num<=1);
}
if(group2_num<=1)
{
return 1;
}
for(i=0;i<group2_num;i++)
{
group2[i].is_invalid=1;
if(calc(group2, group2_num, depth+1)) ret=1;
}
group2[i].is_invalid=0;
}
return 0;
}
int main(void)
{
int i, j, group_num, result;
group_t temp, group[GROUP_MAX];
while(scanf("%d%d", &n, &v)==2)
{
memset(dp, 0, sizeof(dp));
// printf("\nn=%d v=%d\n", n, v);
for(i=0;i<n;i++)
{
scanf("%d", &x[i]);
}
temp.l=0;
temp.r=n-1;
temp.is_invalid=0;
group_num=group_calc(group, &temp, 1, v);
for(i=0;i<group_num;i++)
{
group[i].is_invalid=1;
result=calc(group, group_num, 1);
group[i].is_invalid=0;
for(j=group[i].l;j<=group[i].r;j++)
{
printf("%s\n", result?"Possible":"Impossible");
}
}
}
return 0;
}
| main.c:114:9: error: expected identifier or '(' before 'return'
114 | return 0;
| ^~~~~~
main.c:115:1: error: expected identifier or '(' before '}' token
115 | }
| ^
|
s607357154 | p03771 | C++ | #include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
const int NMAX = 300000;
const int LOGN = 30;
int V[LOGN];
int Lmost[NMAX][LOGN], Rmost[NMAX][LOGN];
int dpL[1<<LOGN], dpR[1<<LOGN];
int arr[NMAX+1];
int dp[NMAX+2];
int main(){
int N; scanf("%d%d",&N,&V[0]);
for(int i=1;i<=N;i++) scanf("%d",arr+i);
int M = 1;
while(V[M-1]){
V[M] = V[M-1]/2;
M++;
}
for(int i=0;i<M;i++){
int v = V[i];
int j = 1;
while(j<=N){
int k = j+1;
while(k<=N && arr[k]-arr[k-1] <= v) k++;
for(int x=j;x<k;x++) Rmost[x][i] = k-1;
j = k;
}
j = N;
while(j>=1){
int k = j-1;
while(k>=1 && arr[k+1]-arr[k] <= v) k--;
for(int x=j;x>k;x--) Lmost[x][i] = k+1;
j = k;
}
}
for(int i=0;i<(1<<M);i++) dpR[i] = N+1;
for(int i=1;i<(1<<M);i++){
for(int j=0;j<M;j++) if(i&(1<<j)){
// use V[j]
int L = dpL[i^(1<<j)];
dpL[i] = max(dpL[i], Rmost[L+1][j]);
int R = dpR[i^(1<<j)];
dpR[i] = min(dpR[i], Lmost[R-1][j]);
}
}
for(int i=0;i<=N+1;i++) dp[i] = -1;
for(int i=2;i<(1<<M);i+=2){
int j = ((1<<M)-1)^i^1;
dp[dpR[j]] = max(dp[dpR[j]], dpL[i]);
}
for(int i=1;i<=N+1;i++)
dp[i] = max(dp[i], dp[i-1]);
for(int i=1;i<=N;i++){
int L = Lmost[i][0], R = Rmost[i][0];
int det = dp[R+1];
if(det>=L-1) printf("Possible\n");
else printf("Impossible\n");
}
}
| /tmp/cc4uZpl3.o: in function `main':
a.cc:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x12d): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x147): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x1f9): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x28e): relocation truncated to fit: R_X86_64_PC32 against symbol `dpR' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x38e): relocation truncated to fit: R_X86_64_PC32 against symbol `dpR' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x3d9): relocation truncated to fit: R_X86_64_PC32 against symbol `dpR' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x3fe): relocation truncated to fit: R_X86_64_PC32 against symbol `dpR' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x449): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc4uZpl3.o
a.cc:(.text+0x4b0): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s407075220 | p03771 | C++ | /*
Hanit Banga
*/
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int N = 2e5 + 10, M = log2(N) + 10;
const ll inf = 1e15;
ll x[N];
int v[N] = {0}, dp_lt[2 * N] = {0}, dp_rt[2 * N] = {0}, lt[N][M] = {0}, rt[N][M] = {0};
int main()
{
int n, val;
cin >> n >> val;
x[0] = -inf;
x[n + 1] = inf;
for (int i = 1; i <= n; ++i)
cin >> x[i];
int temp = val, m = 0;
for (int j = 0; temp > 0; ++j, temp /= 2, ++m)
v[j] = temp;
for (int i = 1; i <= n; ++i)
{
for (int j = 0; j <= m; ++j)
{
lt[i][j] = 1;
if (x[i] - x[i - 1] <= v[j])
lt[i][j] += lt[i - 1][j];
}
for (int j = 0; j <= m; ++j)
{
rt[n - i + 1][j] = 1;
if (x[n - i + 2] - x[n - i + 1] <= v[j])
rt[n - i + 1][j] += rt[n - i + 2][j];
}
}
int subsets = (1 << m);
for (int i = 1; i < subsets; ++i)
{
for (int j = 0; j < m; ++j)
{
if (i & (1 << j))
{
temp = dp_lt[i - (1 << j)];
dp_lt[i] = max(dp_lt[i], temp + rt[temp + 1][j + 1]);
temp = dp_rt[i - (1 << j)];
dp_rt[i] = max(dp_rt[i], temp + lt[n - temp][j + 1]);
}
}
}
for (int i = 1; i <= n; ++i)
{
int l = lt[i][0], r = rt[i][0];
l = i + 1 - l;
r = r + i - 1;
if (dp_lt[subsets - 1] >= l - 1 and dp_rt[subsets - 1] >= n - r)
cout << "Possible\n";
else
cout << "Impossible\n";
}
} | a.cc:23:29: error: 'log2' was not declared in this scope
23 | const int N = 2e5 + 10, M = log2(N) + 10;
| ^~~~
a.cc:27:63: error: size of array 'lt' is not an integral constant-expression
27 | int v[N] = {0}, dp_lt[2 * N] = {0}, dp_rt[2 * N] = {0}, lt[N][M] = {0}, rt[N][M] = {0};
| ^
a.cc:27:79: error: size of array 'rt' is not an integral constant-expression
27 | int v[N] = {0}, dp_lt[2 * N] = {0}, dp_rt[2 * N] = {0}, lt[N][M] = {0}, rt[N][M] = {0};
| ^
|
s591089320 | p03771 | C++ | // package atcoder.agc.agc012;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int v = in.nextInt();
int[] x = in.nextInts(n);
int vv = v;
int maxJump = 0;
while (vv >= 1) {
maxJump++;
vv /= 2;
}
maxJump++;
int[][] nextRight = new int[maxJump][n];
for (int d = 0 ; d < maxJump ; d++) {
int canGo = v >>> d;
for (int i = 0 ; i < n ;) {
int j = i+1;
while (j < n && x[j] - x[j-1] <= canGo) {
j++;
}
for (int k = i ; k < j ; k++) {
nextRight[d][k] = j;
}
i = j;
}
}
int[][] nextLeft = new int[maxJump][n];
for (int d = 0 ; d < maxJump ; d++) {
int canGo = v >>> d;
for (int i = n-1 ; i >= 0 ;) {
int j = i-1;
while (j >= 0 && x[j+1] - x[j] <= canGo) {
j--;
}
for (int k = i ; k > j ; k--) {
nextLeft[d][k] = j;
}
i = j;
}
}
int[] dpLeft = new int[1<<maxJump];
for (int i = 0 ; i < (1<<maxJump) ; i++) {
for (int k = 0 ; k < maxJump ; k++) {
if (((i >> k) & 1) == 0) {
int ti = i | (1<<k);
dpLeft[ti] = Math.max(dpLeft[ti], dpLeft[i] == n ? n : nextRight[k][dpLeft[i]]);
}
}
}
int[] dpRight = new int[1<<maxJump];
Arrays.fill(dpRight, n-1);
for (int i = 0 ; i < (1<<maxJump) ; i++) {
for (int k = 0 ; k < maxJump ; k++) {
if (((i >> k) & 1) == 0) {
int ti = i | (1<<k);
dpRight[ti] = Math.min(dpRight[ti], dpRight[i] == -1 ? -1 : nextLeft[k][dpRight[i]]);
}
}
}
for (int i = 0 ; i < n ; i++) {
boolean isOK = false;
int from = nextLeft[0][i] + 1;
int to = nextRight[0][i] - 1;
int fullPtn = (1<<maxJump)-2;
for (int leftPtn = 0 ; leftPtn < (1<<maxJump) ; leftPtn += 2) {
int rightPtn = fullPtn-leftPtn;
int leftPart = dpLeft[leftPtn];
int rightPart = dpRight[rightPtn];
if (from <= leftPart && rightPart <= to) {
isOK = true;
break;
}
}
out.println(isOK ? "Possible" : "Impossible");
}
out.flush();
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
private int[] nextInts(int n) {
int[] ret = new int[n];
for (int i = 0; i < n; i++) {
ret[i] = nextInt();
}
return ret;
}
private int[][] nextIntTable(int n, int m) {
int[][] ret = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ret[i][j] = nextInt();
}
}
return ret;
}
private long[] nextLongs(int n) {
long[] ret = new long[n];
for (int i = 0; i < n; i++) {
ret[i] = nextLong();
}
return ret;
}
private long[][] nextLongTable(int n, int m) {
long[][] ret = new long[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ret[i][j] = nextLong();
}
}
return ret;
}
private double[] nextDoubles(int n) {
double[] ret = new double[n];
for (int i = 0; i < n; i++) {
ret[i] = nextDouble();
}
return ret;
}
private int next() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public char nextChar() {
int c = next();
while (isSpaceChar(c))
c = next();
if ('a' <= c && c <= 'z') {
return (char) c;
}
if ('A' <= c && c <= 'Z') {
return (char) c;
}
throw new InputMismatchException();
}
public String nextToken() {
int c = next();
while (isSpaceChar(c))
c = next();
StringBuilder res = new StringBuilder();
do {
res.append((char) c);
c = next();
} while (!isSpaceChar(c));
return res.toString();
}
public int nextInt() {
int c = next();
while (isSpaceChar(c))
c = next();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = next();
} while (!isSpaceChar(c));
return res * sgn;
}
public long nextLong() {
int c = next();
while (isSpaceChar(c))
c = next();
long sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = next();
} while (!isSpaceChar(c));
return res * sgn;
}
public double nextDouble() {
return Double.valueOf(nextToken());
}
public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static void debug(Object... o) {
System.err.println(Arrays.deepToString(o));
}
}
| a.cc:3:1: error: 'import' does not name a type
3 | import java.io.IOException;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.io.InputStream;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.io.PrintWriter;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.Arrays;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.util.InputMismatchException;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: expected unqualified-id before 'public'
9 | public class Main {
| ^~~~~~
|
s086203422 | p03771 | C++ | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;
struct union_find {
vector<int> v;
union_find(int n) : v(n, -1) {}
int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
void unite(int x, int y) {
x = find(x); y = find(y);
if (x == y) return;
if (-v[x] < -v[y]) swap(x, y);
v[x] += v[y]; v[y] = x;
}
bool root(int x) { return v[x] < 0; }
bool same(int x, int y) { return find(x) == find(y); }
int size(int x) { return -v[find(x)]; }
};
vector<int> f(int N, int M, vector<int> dx) {
vector<vector<int> > nxt(N + 1, vector<int>(M));
rep(j, M) nxt[N][j] = nxt[N - 1][j] = N;
for (int i = N - 2; i >= 0; i--) {
nxt[i] = nxt[i + 1];
for (int j = dx[i]; j < M; j++) nxt[i][j] = i + 1;
}
vector<int> dp(1<<M);
rep(S, 1<<M)
rep(j, M) if (!(S>>j & 1)) {
int _S = S | 1<<j;
dp[_S] = max(dp[_S], nxt[dp[S]][j]);
}
return dp;
}
vector<int> solve() {
int N, V; cin >> N >> V;
vector<int> x(N);
rep(i, N) scanf("%d", &x[i]);
vector<int> dx(N - 1);
rep(i, N - 1) dx[i] = x[i + 1] - x[i];
bool ok = true;
rep(i, N - 1) if (dx[i] > V) ok = false;
if (ok) return vector<int>(N, true);
vector<int> v;
for (int _V = V; _V; _V /= 2) v.pb(_V);
v.pb(0);
int M = v.size();
rep(i, N - 1) {
int k;
for (k = 0; dx[i] <= v[k]; k++);
dx[i] = k;
}
union_find uf(N);
rep(i, N - 1) if (dx[i]) uf.unite(i, i + 1);
vector<int> dp1 = f(N, M, dx);
reverse(dx.begin(), dx.end());
vector<int> dp2 = f(N, M, dx);
vector<bool> ok(N);
rep(S, 1<<(M - 1)) {
int S1 = S<<1, S2 = (((1<<(M - 1)) - 1) - S)<<1;
int i = min(dp1[S1], N - 1), j = max(0, N - 1 - dp2[S2]);
if (uf.same(i, j)) ok[uf.find(i)] = true;
}
vector<int> ans(N);
rep(i, N) ans[i] = ok[uf.find(i)];
return ans;
}
int main() {
vector<int> ans = solve();
for (int z: ans) if (z) printf("Possible\n"); else printf("Impossible\n");
}
| a.cc: In function 'std::vector<int> solve()':
a.cc:94:22: error: conflicting declaration 'std::vector<bool> ok'
94 | vector<bool> ok(N);
| ^~
a.cc:77:14: note: previous declaration as 'bool ok'
77 | bool ok = true;
| ^~
a.cc:98:38: error: invalid types 'bool[int]' for array subscript
98 | if (uf.same(i, j)) ok[uf.find(i)] = true;
| ^
a.cc:101:30: error: invalid types 'bool[int]' for array subscript
101 | rep(i, N) ans[i] = ok[uf.find(i)];
| ^
|
s961367534 | p03771 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n, v;
cin >> n >> v;
int a[n + 2];
for(int i = 0; i < n; i++) cin >> a[i];
if(n == 0 or v == 0)
{
cout << "Impossible" << '\n';
}
if(n == 1 or v == 1)
cout << "Possible" << '\n';
if(n == 3 or v == 2)
{
printf("Possible\nPossible\nPossible\n");
}
if(n == 7 or v == 2)
{
printf("Impossible\nPossible\nPossible\nPossible\nPossible\nPossible\nImpossible\n")
}
if(n == 19 or v == 19)
{
printf("Possible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nImpossible\nImpossible\nImpossible\nImpossible\n")
}
else {
printf("Impossible\n");
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:93: error: expected ';' before '}' token
23 | printf("Impossible\nPossible\nPossible\nPossible\nPossible\nPossible\nImpossible\n")
| ^
| ;
24 | }
| ~
a.cc:27:187: error: expected ';' before '}' token
27 | printf("Possible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nImpossible\nImpossible\nImpossible\nImpossible\n")
| ^
| ;
28 | }
| ~
|
s196028318 | p03772 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N=105,M=1e9+7;
int n,m,a[N],dp[N][N][N];
int main(){
scanf("%d",&n);
m=(n<<1)-1;
for (int i=1;i<=m;i++)scanf("%d",&a[i]);
sort(a+1,a+m+1);
dp[1][1][1]=1;
for (int i=1;i<n;i++)
for (int j=1;j<=m;j++)
for (int k=1;k<=j;k++){
int x=j;y=k;
if (a[n-i]!=a[n-i+1])x++,y++;
if (a[n+i]!=a[n+i-1])x++;
for (int l=1;l<y;l++)(dp[i+1][x-(y-l-1)][l]+=dp[i][j][k])%=M;
(dp[i+1][x][y]+=dp[i][j][k])%=M;
for (int l=y+1;l<=x;l++)(dp[i+1][x-(l-y-1)][y+1]+=dp[i][j][k])%=M;
}
int ans=0;
for (int i=1;i<=m;i++)
for (int j=1;j<=i;j++)(ans+=dp[n][i][j])%=M;
printf("%d\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:41: error: 'y' was not declared in this scope
14 | int x=j;y=k;
| ^
|
s521388463 | p03772 | C++ | //Created Time:2019年12月02日 星期一 20时04分36秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 102
#define mod 1000000007
using namespace std;
int n;
int a[N], f[N][N][N];
int main(){
scanf("%d", &n);
for(int i = 1; i <= n * 2 - 1; ++i)
scanf("%d", a + i);
sort(a + 1, a + n * 2);
f[n][1][0] = 1;
for(int i = n - 1; i; --i)
for(int j = 0; j <= n * 2 - 1; ++j)
for(int k = 0; k + j <= n * 2 - 1; ++k){
int w = f[i + 1][j][k]; if(!w) continue;
bool flag1 = (a[i + 1] != a[i]), flag2 = (a[n * 2 - i] != a[n * 2 - i - 1]);
for(int l = 1; l <= j + flag1; ++l)
(f[i][j + flag1 - l + 1][k + flag2 + (l != 1)] += w) %= mod;
for(int l = 1; l <= k + flag2; ++l)
(f[i][j + flag1 + 1][k + flag2 - l] += w) %= mod;
}
int ans = 0;
for(int i = 0; i <= n * 2 - 1; ++i)
for(int j = 0; j <= n * 2 - 1; ++j)
(ans += f[1][i][j]) %= mod;
cout << ans << endl;
return 0;
}
noip01@ubuntu:~/work/a$ | a.cc:37:7: error: stray '@' in program
37 | noip01@ubuntu:~/work/a$
| ^
a.cc:37:1: error: 'noip01' does not name a type
37 | noip01@ubuntu:~/work/a$
| ^~~~~~
|
s794269474 | p03772 | C++ | #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=105;
const int mod=1e9+7;
int n,a[N],f[N/2][N][N];
int main()
{
scanf("%d",&n);
for(int i=1;<2*n;i++)
scanf("%d",&a[i]);
sort(a+1,a+2*n);
f[n][1][0]=1;
for(int i=n-1;i;i--)
{
int al=(a[i]!=a[i+1]);
int ar=(a[2*n-i]!=a[2*n-i-1]);
for(int l=0;l<2*n;l++)
for(int r=0;r+l<2*n;r++)
if(f[i+1][l][r])
{
for(int dl=1;dl<=l+al;dl++)
f[i][l+al-dl+1][r+ar+(dl>1)]=(f[i][l+al-dl+1][r+ar+(dl>1)]+f[i+1][l][r])%mod;
for(int dr=1;dr<=r+ar;dr++)
f[i][l+al+1][r+ar-dr]=(f[i][l+al+1][r+ar-dr]+f[i+1][l][r])%mod;
}
}
int ans=0;
for(int i=0;i<n*2;i++)
for(int j=0;j<n*2;j++)
ans=(ans+f[1][i][j])%mod;
printf("%d\n",ans);
}
| a.cc: In function 'int main()':
a.cc:12:17: error: expected primary-expression before '<' token
12 | for(int i=1;<2*n;i++)
| ^
|
s962161590 | p03772 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
const int mod=1e9+7;
void inc(int&a,int b){
a+=b;if(a>=mod)a-=mod;
}
int n,ans,a[100],f[100][100][51][51],g[100][100][51][51];bool b[100];
int main(){
scanf("%d",&n);
ref(i,1,2*n-1)scanf("%d",&a[i]);
sort(a+1,a+2*n);
ref(i,1,n-1)if(a[i+1]!=a[i])b[i]=1;b[n]=1;
ref(i,n+1,2*n-1)if(a[i-1]!=a[i])b[i]=1;
f[n][n][1][1]=1;
def(ti,n,2){
//printf("%d\n",f[4][4][1][1]);
ref(L,1,2*n-1)ref(i,ti,2*n-L){
int j=i+L-1;
if(2*n-j<ti)continue;
ref(t,1,n-ti+1)ref(k,1,t)if(f[i][j][t][k]){
//if(i==4&&j==4&&t==1&&k==1)printf("%d\n",ti);
int s=f[i][j][t][k];
ref(K,1,k-1) inc(g[i][j][t-(k-K-1)][K],s);
ref(K,k+1,t) inc(g[i][j][t-(K-k-1)][k+1],s);
inc(g[i][j][t][k],s);
ref(I,(ti-1),i-1) if(b[I]) inc(g[I][j][t-kl+2][1],s);
ref(J,j+1,2*n-ti+1) if(b[J]) inc(g[i][J][k+1][k+1],s);
}
}
ref(i,1,2*n-1)ref(j,1,2*n-1)ref(t,1,n-ti+2)ref(k,1,t)
f[i][j][t][k]=g[i][j][t][k],g[i][j][t][k]=0;
}
ref(i,1,2*n-1)ref(j,i,2*n-1)ref(t,1,n)ref(k,1,t)
inc(ans,f[i][j][t][k]);
printf("%d\n",ans);
} | a.cc: In function 'int main()':
a.cc:29:74: error: 'kl' was not declared in this scope; did you mean 'k'?
29 | ref(I,(ti-1),i-1) if(b[I]) inc(g[I][j][t-kl+2][1],s);
| ^~
| k
|
s945398143 | p03772 | C++ | #include<algorithm>
#include<iostream>
#include<cstdio>
#define MN 100
#define mod 1000000007
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,a[MN+5],f[MN/2+5][MN+5][MN+5],b[MN+5];
inline void R(int&x,int y){x+=y;x>=mod?x-=mod:0;}
int main()
{
n=read();
for(int i=1;i<n<<1;++i) a[i]=read();
sort(a+1,a+n*2);memcpy(b,a,sizeof(b));
int mid=a[n],num=unique(a+1,a+n*2)-a-1;
for(int i=1;i<=num;++i) if(a[i]==mid) f[n][1][0]=1;
for(int i=n-1;i;--i)for(int j=1;j<=num;++j)for(int k=0;k<j;++k) if(f[i+1][j][k])
{
int bignum=j-1-k+(b[n+(n-i)]!=b[n+(n-i)-1]),smallnum=k+(b[i]!=b[i+1]),T=(b[n+(n-i)]!=b[n+(n-i)-1])+(b[i]!=b[i+1]);
for(int l=1;l<=smallnum;++l) R(f[i][j+T-(smallnum-l)][l-1],f[i+1][j][k]);
for(int l=1;l<=bignum;++l) R(f[i][j+T-(bignum-l)][k+1+(b[i]!=b[i+1])],f[i+1][j][k]);
R(f[i][j+T][k+(b[i]!=b[i+1])],f[i+1][j][k]);
}
int ans=0;
for(int i=1;i<=num;++i)for(int j=0;j<num;++j)
// cout<<1<<" "<<i<<" "<<j<<" "<<f[1][i][j]<<endl,
R(ans,f[1][i][j]);
printf("%d\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:20:25: error: 'memcpy' was not declared in this scope
20 | sort(a+1,a+n*2);memcpy(b,a,sizeof(b));
| ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<cstdio>
+++ |+#include <cstring>
4 | #define MN 100
|
s818256301 | p03772 | C++ | #include <stdio.h>
#include <vector>
#include <map>
long long mod = 1000000007; std::map<std::vector<long long>, long long> m;
long long DFS(std::vector<long long> v, std::vector<long long> cc, long long n) {
if (n == 1)
return 1;
long long l, i, j, c, k; std::vector<long long> V;
for (k = i = 0; i != 100; i++)
cc[i] && k++
for (c = 0, l = v.size(), i = 1; i != l; v[i]++, v[i-1]--, i++)
v[i] && (V = v, V[i]--, V[i-1]++, c += (m[V] ? m[V] : (m[V] = DFS(V, n-2))), c %= mod);
if (v[0])
V = v, V[0]--, c += (m[V] ? m[V] : (m[V] = DFS(V, n-2))), c %= mod;
return c*k%mod;
}
int main() {
long long N, NN, n[100] = {}, i;
std::vector<long long> v, cc;
for (scanf("%lld", &N), NN = N = 2*N-1, cc.resize(100); N--; )
scanf("%lld", &i), n[i]++, cc[i]++;
for (i = 0; i != 100; i++)
n[i] && (n[i] > v.size() && (v.resize(n[i]), 1), v[n[i]-1]++);
printf("%lld", DFS(v, cc, NN));
} | a.cc: In function 'long long int DFS(std::vector<long long int>, std::vector<long long int>, long long int)':
a.cc:12:29: error: expected ';' before 'for'
12 | cc[i] && k++
| ^
| ;
13 | for (c = 0, l = v.size(), i = 1; i != l; v[i]++, v[i-1]--, i++)
| ~~~
a.cc:13:71: error: expected ';' before ')' token
13 | for (c = 0, l = v.size(), i = 1; i != l; v[i]++, v[i-1]--, i++)
| ^
| ;
a.cc:16:68: error: could not convert '(n - 2)' from 'long long int' to 'std::vector<long long int>'
16 | V = v, V[0]--, c += (m[V] ? m[V] : (m[V] = DFS(V, n-2))), c %= mod;
| ~^~
| |
| long long int
|
s597896354 | p03773 | C++ | #include <iostream>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
c=a+b;
if(c<24)
cout<<c;
else if(c==24)
couy<<0;
else cout<<c-24;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:9: error: 'couy' was not declared in this scope
14 | couy<<0;
| ^~~~
|
s426058285 | p03773 | Java | import java.io.*;
import java.util.*;
public class Balanced {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int a=sc.nextInt(), b=sc.nextInt();
System.out.println((a+b)%24);
out.close();
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(String s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public int[] nextIntArray(int n) throws IOException {
int[] ans = new int[n];
for (int i = 0; i < n; i++)
ans[i] = nextInt();
return ans;
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public boolean ready() throws IOException {
return br.ready();
}
}
} | Main.java:4: error: class Balanced is public, should be declared in a file named Balanced.java
public class Balanced {
^
1 error
|
s145836479 | p03773 | C++ | #include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int A,B;
cin >> A >> B;
if (A+B<=24) {
cout << A+B << endl;
} else if (A+B>=24) {
cout << 24-A << end;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:30: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
15 | cout << 24-A << 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_t = std |
s998210726 | p03773 | C++ | #include <iostream>
using namespace std;
int main()
{
int A,B;
std::cin >> A;
std::cin >> B;
if(A+B<24){
cout<<A+B;}
else if(A+B=>24){
cout<<(A+B)-24;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:12:13: error: expected primary-expression before '>' token
12 | else if(A+B=>24){
| ^
|
s293477465 | p03773 | C++ | #include <iostream>
using namespace std;
int main()
{
int a,b,c=0;
cin>>a>>b;
c=a+b;
if(c<24)
cout<<c;
else if(c==24)
cout<<12;
else {
c-=24;
cout<<c;
}
return 0; | a.cc: In function 'int main()':
a.cc:17:14: error: expected '}' at end of input
17 | return 0;
| ^
a.cc:5:1: note: to match this '{'
5 | {
| ^
|
s929994092 | p03773 | C++ | #include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace;
int F(long long A, long long B){
int ta = A, tb = B;
int ca = 0, cb = 0;
for(int i = 0; i < 10; i++){
if(ta != 0) ca++;
if(tb != 0) cb++;
ta /= 10;
tb /= 10;
}
return ca > cb ? ca : cb;
}
int main() {
long long N;
cin >> N;
long long ans = 10;
for(long long i = 1; i <= sqrt(N); i++){
if(N % i == 0) {
ans = min(ans, F(i, N/i));
}
}
cout << ans << endl;
}
| a.cc:7:16: error: expected identifier before ';' token
7 | using namespace;
| ^
a.cc: In function 'int main()':
a.cc:22:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
22 | cin >> N;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:26:19: error: 'min' was not declared in this scope; did you mean 'std::min'?
26 | ans = min(ans, F(i, N/i));
| ^~~
| std::min
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
a.cc:29:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
29 | cout << ans << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:29:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
29 | cout << ans << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s861223086 | p03773 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long
signed main()
{
char A,B;
cin >> A >> B;
if(A+B < 24){cout << A+B;}
else{cout << A+B-24;
} | a.cc: In function 'int main()':
a.cc:12:4: error: expected '}' at end of input
12 | }
| ^
a.cc:7:1: note: to match this '{'
7 | {
| ^
|
s114949920 | p03773 | Java |
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.next();
int b = sc.next();
System.out.println((a + b) % 24);
}
} | Main.java:8: error: incompatible types: String cannot be converted to int
int a = sc.next();
^
Main.java:9: error: incompatible types: String cannot be converted to int
int b = sc.next();
^
2 errors
|
s431355398 | p03773 | C++ | //In the name of 'ALLAH'
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a , b ;
cin>>a>>b;
if( a + b => 24 )
{
cout << a+b-24 <<endl;
}
else
{
cout<< a+b <<endl;
}
}
| a.cc: In function 'int main()':
a.cc:9:16: error: expected primary-expression before '>' token
9 | if( a + b => 24 )
| ^
|
s876470752 | p03773 | C++ | #include<bits/stdc++.h>
using namespace std;
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll arr[120];
ll nCr(ll n, ll r)
{
ll C[r+1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (ll i = 1; i <= n; i++)
{
for (ll j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j-1]);
}
return C[r];
}
int main()
{
cout<<nCr(5,2)<<"\\\\\\\\\\\\\\\\\\\\"<<endl;
ll tot=0;
long double ans=0,sum=0,cnt=0;
map<ll,int>N,R;
int n,a,b;
cin>>n>>a>>b;
for(int i=0; i<n; i++){
cin>>arr[i];
N[arr[i]]++;
}
sort(arr,arr+n);
ll last ;
for(int i=n-1; i>=0; i--)
{
sum+=arr[i];
R[arr[i]]++;
cnt++;
if(cnt>b)
break;
if(cnt==a)
{
last = arr[n-1];
ans=sum/cnt;
}
if(cnt>=a)
{
long double cur=(sum/cnt);
if(cnt==a)
{tot+=nCr(N[arr[i]],R[arr[i]]);
}
}
cout<<setprecision(18)<<fixed<<ans<<endl;
cout<<tot<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:64:6: error: expected '}' at end of input
64 | }
| ^
a.cc:28:5: note: to match this '{'
28 | {
| ^
|
s539453970 | p03773 | C | #include<stdio.h>
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
c=a+b;
printf("%d",c); | main.c:4:7: error: expected declaration specifiers or '...' before string constant
4 | scanf("%d",&a);
| ^~~~
main.c:4:12: error: expected declaration specifiers or '...' before '&' token
4 | scanf("%d",&a);
| ^
main.c:5:7: error: expected declaration specifiers or '...' before string constant
5 | scanf("%d",&b);
| ^~~~
main.c:5:12: error: expected declaration specifiers or '...' before '&' token
5 | scanf("%d",&b);
| ^
main.c:7:1: warning: data definition has no type or storage class
7 | c=a+b;
| ^
main.c:7:1: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
main.c:7:3: error: initializer element is not constant
7 | c=a+b;
| ^
main.c:8:8: error: expected declaration specifiers or '...' before string constant
8 | printf("%d",c);
| ^~~~
main.c:8:13: error: expected declaration specifiers or '...' before 'c'
8 | printf("%d",c);
| ^
|
s635900160 | p03773 | C++ | #include <iostream>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
c=a+b;
if(c<24)
{
cout<<c;
}
else
{
d=c-24;
cout<<d;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:19:4: error: 'd' was not declared in this scope
19 | d=c-24;
| ^
|
s639243313 | p03773 | C++ | #include <iostream>
int main() {
int A, B;
cin >> A >> B;
cout << (A + B) % 24 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
5 | cin >> A >> B;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:6:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
6 | cout << (A + B) % 24 << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:6:27: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
6 | cout << (A + B) % 24 << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s332078734 | p03773 | C++ | #incluce <iostream>
int main() {
int A, B;
cin >> A >> B;
cout << (A + B /24) << endl;
} | a.cc:1:2: error: invalid preprocessing directive #incluce; did you mean #include?
1 | #incluce <iostream>
| ^~~~~~~
| include
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
5 | cin >> A >> B;
| ^~~
a.cc:6:3: error: 'cout' was not declared in this scope
6 | cout << (A + B /24) << endl;
| ^~~~
a.cc:6:26: error: 'endl' was not declared in this scope
6 | cout << (A + B /24) << endl;
| ^~~~
|
s055376012 | p03773 | C++ |
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;
int main()
{
long long a,b,c,d,e,f,g,h;
cin>>a>>b;
if (a+b=>24)
{
/* code */
cout<<(a+b)-24;
}
else
cout<<a+b<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:47:9: error: expected primary-expression before '>' token
47 | if (a+b=>24)
| ^
|
s186730935 | p03773 | Java | import java.util.Scanner;
public class A {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
System.out.println((a + b) % 24);
}
} | Main.java:3: error: class A is public, should be declared in a file named A.java
public class A {
^
1 error
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.