submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s297701963
|
p03958
|
C++
|
use std::io;
fn next_vec() -> Vec<i64> {
let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap();
buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}
fn main(){
let v = next_vec();
let k = v[0];
let t = v[1] as usize;
let mut a = next_vec();
a.sort();
let mut left: usize = 0;
let mut right: usize = t - 1;
let mut cnt = 0;
while left < right {
a[left] -= 1;
left = if a[left] == 0 {left + 1} else {left};
a[right] -= 1;
right = if a[right] == 0 {right - 1} else {right};
cnt += 2;
}
cnt += if a[left] > 0 || a[right] > 0 {1} else {0};
println!("{:?}", k - cnt);
}
|
a.cc:1:1: error: 'use' does not name a type
1 | use std::io;
| ^~~
a.cc:3:1: error: 'fn' does not name a type
3 | fn next_vec() -> Vec<i64> {
| ^~
a.cc:9:1: error: 'fn' does not name a type
9 | fn main(){
| ^~
|
s249888160
|
p03958
|
C++
|
#include <algorithm>
#include <iostream>
#define lim 100
using namespace std;
int main (void){
int K, T;
int a[lim]={};
int ans;
cin >> K >> T;
for(int i=0; i<T; i++){
cin >> a[i];
}
sort(a, a + 100);
/*
for(int i=99; i>100-T-5; i--){
cout << a[i];
}
*/
ans = a[lim-1]-1;
for(int i = lim-2; i=>0; i--){
if(ans != 0)
ans -= a[i];
}
if(ans < 0){
ans = 0;
}
printf("%d\n",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:26: error: expected primary-expression before '>' token
24 | for(int i = lim-2; i=>0; i--){
| ^
|
s591829089
|
p03958
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int k,t,ans=0;
cin >> k >> t;
vector<int> a(t);
for(int i=0;i<t;i++){
cin >> a[i];
}
int prev = -1;
while(1){
int x = 0;
for(int i=0;i<t;i++){
if(i == prev) continue;
if(a[x] < a[i]){
x = i;
}
}
if(a[x] <= 0) x = prev;
if(x == prev){
ans++;
}
a[x]--;
prev = x
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:26:25: error: expected ';' before '}' token
26 | prev = x
| ^
| ;
27 | }
| ~
|
s601093402
|
p03958
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int k,t;
cin >> k >> t;
vector<int> a(t);
for(int i=0;i<t;i++){
cin >> a[i];
}
int prev = -1;
while(1){
int x = 0;
for(int i=0;i<t;i++){
if(i == prev) continue;
if(a[x] < a[i]){
x = i;
}
}
if(a[x] <= 0) x = prev;
if(x == prev){
ans++;
}
a[x]--;
prev = x
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:23:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
23 | ans++;
| ^~~
| abs
a.cc:26:25: error: expected ';' before '}' token
26 | prev = x
| ^
| ;
27 | }
| ~
a.cc:28:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | cout << ans << endl;
| ^~~
| abs
|
s970541319
|
p03958
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int k,t;
cin>>k>>t;
vector<int>vec;
for(int i=0;i<t;i++){
int x;cin>>x; vec.push_back(x);
}
int mini=1000000;
do{
int x=0;
for(int i=0;i+1<vec.size();i++){
if(vec[i]==vec[i+1])x++;
}
mini=min(mini,x);
}while(next_permutation(vec.begin(),vec.end());
cout<<mini<<endl;
}
|
a.cc: In function 'int main()':
a.cc:19:47: error: expected ')' before ';' token
19 | }while(next_permutation(vec.begin(),vec.end());
| ~ ^
| )
|
s571907488
|
p03958
|
C++
|
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
int main()
{
int k,t;
cin >> k >> t;
int a[t];
int max = 0;
REP(i,t){cin >> a[i];if(a[i]>max){max = a[i];}}
cout << max(0,max - (k-max) -1 ) << endl;
return 0 ;
}
|
a.cc: In function 'int main()':
a.cc:31:16: error: 'max' cannot be used as a function
31 | cout << max(0,max - (k-max) -1 ) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~
|
s803889377
|
p03958
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
int k,t,ans=INT_MAX,dp[10010][110];
void f(int type, int n, int a[]){
if(n==k){
ans=min(ans,0);
return;
}
bool flag=false;
for(int i=0;i<t;i++){
if(type!=i&&a[i]>0){
a[i]--;
f(i,n+1,a);
a[i]++;
flag= true;
}
}
if(!flag) ans=min(ans,a[type]);
}
int main(){
//int t;
//t=1;
//cin>>t;
//while(t--){
cin>>k>>t;
int a[110];
for(int i=0;i<t;i++) cin>>a[i];
memset(dp,-1,sizeof dp);
for(int i=0;i<t;i++){
a[i]--;
f(i,1,a);
a[i]++;
}
cout<<ans<<endl;
//}
return 0;
}
|
a.cc:7:13: error: 'INT_MAX' was not declared in this scope
7 | int k,t,ans=INT_MAX,dp[10010][110];
| ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <cstring>
+++ |+#include <climits>
5 | using namespace std;
a.cc: In function 'int main()':
a.cc:35:16: error: 'dp' was not declared in this scope
35 | memset(dp,-1,sizeof dp);
| ^~
|
s309040852
|
p03958
|
C++
|
#include<iostream>
#include<algorithm>
using namespace std;
int K,T;
int cake[101];
int main(){
cin>>K>>T;
for(int i = 0; i < T; i++){
cin>>cake[i];
}
sort(cake,cake+T);
if(T == 1){
cout<<cake[0]-1<<endl;
}
else if(cake[T-1] - cake[T-2] > 1){
int sum = 0;
for(int i = 0; i < T-1; i++){
sum += cake[i];
}
if(cake[T-1]-sum-1 > 0)cout<<cake[T-1]-sum-1<<endl;
else {cout<<'0'<<endl;}
}
else cout<<'0'<<endl;
|
a.cc: In function 'int main()':
a.cc:28:24: error: expected '}' at end of input
28 | else cout<<'0'<<endl;
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s709009551
|
p03958
|
C++
|
#include<iostream>
#include<algorithm>
using namespace std;
int K,T;
int cake[101];
int main(){
cin>>K>>T;
for(int i = 0; i < T; i++){
cin>>cake[i];
}
sort(cake,cake+T);
if(T == 1){
cout<<cake[0]-1<<endl;
}
else if(cake[T-1] - cake[T-2] > 1){
int sum = 0;
for(int i = 0; i < T-1; i++){
sum += cake[i];
}
if(cake[T-1]-sum-1 > 0)cout<<cake[T-1]-sum-1<<endl;
else cout<<'0'<<endl;
}
else cout<<'0'<<endl;
|
a.cc: In function 'int main()':
a.cc:28:24: error: expected '}' at end of input
28 | else cout<<'0'<<endl;
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s340331620
|
p03958
|
C
|
#include <stdio.h>
int find_max(int n, b[]){
int w,max=0,max_idx=0;
for(w=0;w<n;w++){
if(b[w]>max){
max=b[w];
max_idx=w;
}
}
return max_idx;
}
int main(void){
// Here your code !
int K,T,i, idx, cnt = 0;
scanf("%d%d",&K,&T);
int a[T];
for(i=0;i<T;i++){
scanf("%d",&a[i]);
}
while(K>0){
// aの中の最大の要素を見つける
idx = find_max(T, a);
// 最大要素をデクリメント
a[idx]--;
// 昨日食べたものと同じだったらカウントをインクリメント
if( pre_idx == idx){
cnt++;
}
pre_idx = idx;
K--;
}
printf("%d",cnt);
return 0;
}
|
main.c:3:21: error: unknown type name 'b'
3 | int find_max(int n, b[]){
| ^
main.c: In function 'main':
main.c:28:15: error: implicit declaration of function 'find_max' [-Wimplicit-function-declaration]
28 | idx = find_max(T, a);
| ^~~~~~~~
main.c:34:13: error: 'pre_idx' undeclared (first use in this function)
34 | if( pre_idx == idx){
| ^~~~~~~
main.c:34:13: note: each undeclared identifier is reported only once for each function it appears in
|
s740062481
|
p03958
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int K, T;
cin >> K >> T;
vector<int> v(T);
for(auto i = 0; i < T; i++)
cin >> v[i];
sort(v.begin(), v.end());
int p(0), q(T-1);
while(true){
// a b a b c a c
// a b a c a a
if(p >= q)
break;
if(v[p] > v[q]){
v[p] -= v[q];
q--;
}
else if(v[p] < v[q]){
v[q] -= v[p];
p++;
}
else{
p++;
q--;
}
}
cout << v[p] - 1 << endl;
reutrn 0;
}
|
a.cc: In function 'int main()':
a.cc:37:5: error: 'reutrn' was not declared in this scope
37 | reutrn 0;
| ^~~~~~
|
s572422745
|
p03958
|
C++
|
int main() {
int K, T; cin >> K >> T;
vector<pair<int, int>> vs;
rep(i, T) {
int x; cin >> x;
vs.push_back({x, i});
}
int last = -1;
int N = vs.size();
while(vs.size() > 1) { // T-1要素すべて消すまで回す。O(K)
sort(all(vs));
for(int i=N-1; i>=N-2; i--) {
if(last != vs[i].second) {
if(vs[i].first > 0) {
last = vs[i].second;
vs[i].first --; // 1個ずつ食べる
if(vs[i].first == 0) {
vs.erase(vs.begin() + i); // T-1回しか実行されない
N = vs.size();
}
break;
}
}
}
}
cout << vs[0].first - 1 << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:3:13: error: 'cin' was not declared in this scope
3 | int K, T; cin >> K >> T;
| ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
4 | vector<pair<int, int>> vs;
| ^~~~~~
a.cc:4:10: error: 'pair' was not declared in this scope
4 | vector<pair<int, int>> vs;
| ^~~~
a.cc:4:15: error: expected primary-expression before 'int'
4 | vector<pair<int, int>> vs;
| ^~~
a.cc:5:7: error: 'i' was not declared in this scope
5 | rep(i, T) {
| ^
a.cc:5:3: error: 'rep' was not declared in this scope
5 | rep(i, T) {
| ^~~
a.cc:11:11: error: 'vs' was not declared in this scope
11 | int N = vs.size();
| ^~
a.cc:13:10: error: 'all' was not declared in this scope
13 | sort(all(vs));
| ^~~
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
13 | sort(all(vs));
| ^~~~
| short
a.cc:30:3: error: 'cout' was not declared in this scope
30 | cout << vs[0].first - 1 << endl;
| ^~~~
a.cc:30:30: error: 'endl' was not declared in this scope
30 | cout << vs[0].first - 1 << endl;
| ^~~~
|
s817816275
|
p03958
|
C++
|
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
int K,T;
priority_queue<int,vector<int>,greater<int>> queue;
int a[100];#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
int K,T;
priority_queue<int,vector<int>,greater<int>> queue;
int a[100];
int min=100000;
int max=-1;
int count = 0;
cin >> K >> T;
for(int i=0;i<T;i++){
cin >> a[i];
if(a[i]>max){
max=a[i];
}
if(a[i]<min){
min=a[i];
}
}
if(T==1){
cout << K-1 << endl;
return 0;
}
for(int i=0;i<T;i++){
a[i]-=min;
if(a[i]!=0){
queue.push(a[i]);
}
}
count=min*T+1;
int count2=0;
for(;queue.size()!=0;){
if(count-min*2>=queue.top()&&count2<=queue.top()){
count+=queue.top()*2-count2;
if(count2>0){
count2=0;
}
queue.pop();
}else{
count++;
if(count2==0){
count2=queue.top()-(count-min*2);
}else{
count2-queue.top();
}
queue.pop();
}
}
cout << count2 << endl;
return 0;
}
int min=100000;
int max=-1;
int count = 0;
cin >> K >> T;
for(int i=0;i<T;i++){
cin >> a[i];
if(a[i]>max){
max=a[i];
}
if(a[i]<min){
min=a[i];
}
}
if(T==1){
cout << K-1 << endl;
return 0;
}
for(int i=0;i<T;i++){
a[i]-=min;
if(a[i]!=0){
queue.push(a[i]);
}
}
count=min*T+1;
int count2=0;
for(;queue.size()!=0;){
if(count-min*2>=queue.top()&&count2<=queue.top()){
count+=queue.top()*2;
if(count2>0){
count2=0;
}
queue.pop();
}else{
if(count2==0){
count2=queue.top()-(count-min*2);
}else{
count2-queue.top();
}
queue.pop();
}
}
cout << count2 << endl;
return 0;
}
|
a.cc:10:14: error: stray '#' in program
10 | int a[100];#include <iostream>
| ^
a.cc: In function 'int main()':
a.cc:10:15: error: 'include' was not declared in this scope
10 | int a[100];#include <iostream>
| ^~~~~~~
a.cc:10:32: error: expected primary-expression before '>' token
10 | int a[100];#include <iostream>
| ^
a.cc:14:1: error: expected primary-expression before 'using'
14 | using namespace std;
| ^~~~~
a.cc:16:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
16 | int main(){
| ^~
a.cc:16:9: note: remove parentheses to default-initialize a variable
16 | int main(){
| ^~
| --
a.cc:16:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:16:11: error: a function-definition is not allowed here before '{' token
16 | int main(){
| ^
|
s308347762
|
p03958
|
C++
|
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
int K,T;
priority_queue<int,vector<int>,greater<int>> queue;
int a[100];
int min=100000;
int max=-1;
int count = 0;
cin >> K >> T;
for(int i=0;i<T;i++){
cin >> a[i];
if(a[i]>max){
max=a[i];
}
if(a[i]<min){
min=a[i];
}
}
if(T==1){
cout << K-1 << endl;
return 0;
}
for(int i=0;i<T;i++){
a[i]-=min;
if(a[i]!=0){
queue.push(a[i]);
}
}
count=min*T+1;
int count2=0;
for(;queue.size()!=0;){
if(count-min*2>=queue.top()&&count2<=queue.top()){
count+=queue.top()*2-count2;
if(count2>0){
count2=0;
}
queue.pop();
}else{
count+=queue,top()*2;
if(count2==0){
count2=queue.top()-(count-min*2);
}else{
count2-queue.top();
}
queue.pop();
}
}
cout << count2 << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:44:12: error: no match for 'operator+=' (operand types are 'int' and 'std::priority_queue<int, std::vector<int>, std::greater<int> >')
44 | count+=queue,top()*2;
| ~~~~~^~~~~~~
a.cc:44:20: error: 'top' was not declared in this scope
44 | count+=queue,top()*2;
| ^~~
|
s571684204
|
p03958
|
C++
|
#include <vector>
#include<string>
#include <iostream>
using namespace std;
int k,t;
int a[111];
int b[111];
int solve() {
for (int i=0; i<t; i++) {
b[i] = a[i];
}
if(t == 1) return b[0];
while (true) {
sort(b, b+t);
reverse(b, b+t);
if(b[1] == 0) return b[0];
b[0] -= b[1];
b[1] = 0;
}
return 0;
}
int main() {
while (cin >> k >> t) {
int mm = -1;
for (int i=0; i<t; i++) {
cin >> a[i];
mm = max(mm, a[i]);
}
cout << solve()-1 << endl;
}
}
|
a.cc: In function 'int solve()':
a.cc:17:9: error: 'sort' was not declared in this scope; did you mean 'short'?
17 | sort(b, b+t);
| ^~~~
| short
a.cc:18:9: error: 'reverse' was not declared in this scope
18 | reverse(b, b+t);
| ^~~~~~~
|
s718857577
|
p03958
|
C++
|
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
int k,t;
cin >> k >> t;
int a[105] ={},b[10005]={};;
for(int i =0; i < t;i++){
cin >> a[i];
}
if(t != 1){
int c = 0,nold = -1;
while(c < k){
// for(int i =0; i < t;i++)cout << a[i];
// cout <<endl;
int n = 0;
for(int i =0; i < t;i++){
if(a[i] != 0){
n = i;
break;
}
}
if(c%2 == 0){
for(int i =0; i < t;i++){
if(a[i] != 0 && a[i] >= a[n] && (nold != i))n = i;
}
}else{
for(int i =0; i < t;i++){
if(a[i] != 0 && a[i] <= a[n] && (nold != i7 ))n = i;
}
}
// cout << n<<endl;
b[c] = n;
a[n]--;
nold = n;
c++;
}
// for(int i =0; i < k;i++)cout << b[i] ;
// cout <<endl;
int cnt = 0;
for(int i =1; i < k;i++)if(b[i-1] == b[i])cnt++;
cout << cnt <<endl;
}else cout << k-1 <<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:37:75: error: 'i7' was not declared in this scope; did you mean 'i'?
37 | if(a[i] != 0 && a[i] <= a[n] && (nold != i7 ))n = i;
| ^~
| i
|
s119704563
|
p03958
|
C
|
#include <stdio.h>
int main(void){
int K=6,T=3,i,max=0,maxi=0,k,count=0;
scanf("%d %d",&K,&T);
int a[T];
int a[3]={1,4,1};
i=0;
while(i<T){
scanf("%d",&a[i]);
i++;
}
while(count!=K){
k=0;
for(k=0;k<T;k++){
if(k==a[maxi]){
k++;
break;
}
if(max<=a[i]){
max=a[i];
maxi=i;
}
}
printf("%d ",a[i]);
a[i]=a[i]-1;
count++;
}
return 0;
}
|
main.c: In function 'main':
main.c:9:9: error: redeclaration of 'a' with no linkage
9 | int a[3]={1,4,1};
| ^
main.c:8:9: note: previous declaration of 'a' with type 'int[T]'
8 | int a[T];
| ^
|
s249733040
|
p03958
|
C
|
#include <stdio.h>
#include<string.h>
int main(void) {
int t,k;
scanf("%d %d", &k,&t);
int a[t + 5];
for( int i= 0; i < t; i++){
scanf("%d", &a[i]);
}
int maxIndex = 0;
int minIndex = 0;
int max = 0;
int min = 0;
for(int i = 0; i< t; i++){
if(a[i] > max){
maxIndex = i;
max = a[i];
}
else if(a[i] =< min){
minIndex = i;
min = a[i];
}
}
for(int i =0; i < k; i++){
if(maxIndex == minIndex){
break;
}
a[maxIndex]--;
a[minIndex]--;
if(a[minIndex] ==0){
minIndex = maxIndex;
}
for(int i = 0; i< t; i++){
if(a[i] > a[maxIndex] && a[i] > 0){
maxIndex = i;
max = a[i];
}
else if(a[i] < a[minIndex] && a[i] > 0){
minIndex = i;
min = a[i];
}
}
}
printf("%d\n", a[maxIndex] -1);
return 0;
}
|
main.c: In function 'main':
main.c:24:31: error: expected expression before '<' token
24 | else if(a[i] =< min){
| ^
|
s221064310
|
p03958
|
C++
|
use std::io::prelude::*;
use std::io;
fn read_to_string() -> String {
let mut buf = String::new();
let mut stdin = io::stdin();
stdin.read_to_string(&mut buf);
buf
}
fn solve(p: Vec<u64>, q: Vec<u64>) -> u64 {
let w = p.len();
let h = q.len();
let mut pq: Vec<_> = p.iter()
.map(|c| (*c, 'p'))
.chain(q.iter()
.map(|c| (*c, 'q')))
.collect();
pq.sort();
let mut a = w as u64 + 1;
let mut b = h as u64 + 1;
pq.iter()
.map({
|e| match *e {
(c, 'p') => {
a -= 1;
b * c
}
(c, 'q') => {
b -= 1;
a * c
}
_ => 0
}
})
.fold(0, std::ops::Add::add)
}
fn main() {
let input = read_to_string();
let mut words = input.split_whitespace();
let w: usize = words.next().unwrap().parse().unwrap();
let h: usize = words.next().unwrap().parse().unwrap();
let p: Vec<u64> = words.by_ref().take(w).map(|i| i.parse().unwrap()).collect();
let q: Vec<u64> = words.by_ref().take(h).map(|i| i.parse().unwrap()).collect();
println!("{}", solve(p, q));
}
|
a.cc:1:1: error: 'use' does not name a type
1 | use std::io::prelude::*;
| ^~~
a.cc:2:1: error: 'use' does not name a type
2 | use std::io;
| ^~~
a.cc:4:1: error: 'fn' does not name a type
4 | fn read_to_string() -> String {
| ^~
a.cc:11:1: error: 'fn' does not name a type
11 | fn solve(p: Vec<u64>, q: Vec<u64>) -> u64 {
| ^~
a.cc:39:1: error: 'fn' does not name a type
39 | fn main() {
| ^~
|
s397029131
|
p03958
|
C++
|
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;
//{{{
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}
void solve() {
int K, T;
cin >> K >> T;
vector<int> a(K);
rep(i, T) cin >> a[i];
sort(all(a));
auto mn = lower_bound(all(a), 1);
auto mx = max_element(rall(a));
while (mn != mx) {
*mn = *mn - 1;
*mx = *mx - 1;
sort(all(a));
mn = lower_bound(all(a), 1);
mx = max_element(rall(a));
}
if (*mx > 0) {
cout << *mx - 1 << endl;
} else {
cout << 0 << endl;
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(12);
solve();
}
|
a.cc: In function 'void solve()':
a.cc:47:15: error: no match for 'operator!=' (operand types are '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >')
47 | while (mn != mx) {
| ~~ ^~ ~~
| | |
| | std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >
| __gnu_cxx::__normal_iterator<int*, std::vector<int> >
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:2:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1305 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1473 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1647 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2213:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
47 | while (mn != mx) {
| ^~
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:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::pair<_T1, _T2>'
47 | while (mn != mx) {
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::reverse_iterator<_Iterator>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
500 | operator!=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::reverse_iterator<_Iterator>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1686 | operator!=(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::move_iterator<_IteratorL>'
47 | while (mn != mx) {
| ^~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1753 | operator!=(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::move_iterator<_IteratorL>'
47 | while (mn != mx) {
| ^~
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
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/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::fpos<_StateT>'
47 | while (mn != mx) {
| ^~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
243 | operator!=(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed:
a.cc:47:18: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::allocator<_CharT>'
47 | while (mn != mx) {
| ^~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> const
|
s462372638
|
p03958
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
int K,T;
cin >> K >> T;
vector<int> a(T);
for(int i=0;i<T;i++){
cin >> a[i];
}
int tempIndex = 0;
int count =0;
sort(a.rbegin(),a.rend());
a[0]--;
for(int i=1;i<K;i++){
int max = 0;
int yesterIndex = tempIndex;
for(int j=0;j<T;j++){
if(max < a[j] && j!=tempIndex){
max = a[j];
tempIndex = j;
}
}
a[tempIndex]--;
if(tempIndex == yesterIndex) count++;
}
cout << count;
return 0;
}
|
a.cc: In function 'int main(int, const char**)':
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(a.rbegin(),a.rend());
| ^~~~
| short
|
s438019645
|
p03958
|
C++
|
#include<iostream>
#include<vector>
#include<math.h>
#include <stdlib.h>
using namespace std;
int main() {
int a, c, ans = 0;
double b;
cin >> a >> b;
for(int i = 0; i < b; i++) {
cin >> c;
if(a / 2 < c) {
if((c - a / 2 <= 1) && (a % 2 == 1)) {
ans += (c - a / 2) * 2 - 1;
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:21:2: error: expected '}' at end of input
21 | }
| ^
a.cc:7:12: note: to match this '{'
7 | int main() {
| ^
|
s968719644
|
p03958
|
Java
|
import java.util.Arrays;
import java.util.Scanner;
public class KCakes {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int k, t;
int[] numberOfEach;
k = sc.nextInt();
t = sc.nextInt();
numberOfEach = new int [t];
for (int i=0; i<t ;++i) {
numberOfEach[i] = sc.nextInt();
}
Arrays.sort(numberOfEach);
int type = t-2;
int max = t-1;
eatThroughDay(max, type, numberOfEach);
System.out.println(numberOfEach[t-1]);
}
private static int eatUp(int type, int[] numberOfEach, int max) {
if (type < 0) {
return 1;
}
if (numberOfEach[max] == 0){
return 0;
}
if (numberOfEach[type] == 0) {
return 1;
}
--numberOfEach[max];
--numberOfEach[type];
return -1;
}
private static void eatThroughDay(int max, int type, int[] numberOfEach) {
int result = -1;
while ((result = eatUp(type, numberOfEach, max) )== -1) {
--type;
if (type < 0) {
++type;
}
if (type == max) {
return;
}
}
if (result==0) {
--max;
if (max < 0) {
return;
}
eatThroughDay(max, type, numberOfEach);
}
if (result==1) {
--type;
boolean isAllZero = true;
if (type < 0) {
++type;
for (int i=type; i<numberOfEach.length-1; ++i){
if (i < 0) {
--numberOfEach[max];
return;
}
if (numberOfEach[i] != 0) {
isAllZero = false;
type = i;
break;
}
}
if (isAllZero) {
--numberOfEach[max];
return;
}
}
if (type == max) {
return;
}
eatThroughDay(max, type, numberOfEach);
}
}
}
|
Main.java:5: error: class KCakes is public, should be declared in a file named KCakes.java
public class KCakes {
^
1 error
|
s090763857
|
p03958
|
C++
|
#include<iostream>
#include<vector>
#include<math.h>
#include <stdlib.h>
using namespace std;
int main() {
int a, c, ans = 0;
double b;
cin >> a >> b;
if(b != 1) {
for(int i = 0; i < b; i++) {
cin >> c;
if(a / 2 + 1 < c) {zzzz
ans += (c - a / 2) * 2 - 1;
}
}
}else {
ans = a;
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:14:26: error: 'zzzz' was not declared in this scope
14 | if(a / 2 + 1 < c) {zzzz
| ^~~~
|
s283547172
|
p03958
|
C
|
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
return *(int *)b-*(int *)a;
}
int main(void){
int k,t,a[100],i,j,n,c=0,f[10000];
scanf("%d %d",&k,&t);
n=k;
for(i=0;i<t;i++)
scanf("%d",&a[i]);
qsort(a,t,sizeof(int),cmp);
while(n){
for(i=0;i<t;i++){
for(j=0;f[j]!=0;j++
;
for(;j<k&&a[i];j+=2){
f[j]=i+1;
a[i]--;
n--;
}
}
}
for(i=1;i<k;i++){
if(f[i-1]==f[i]){
if(i>1&&f[i-1]!=f[i-2]){
int tmp=f[i-1];
f[i-1]=f[i-2];
f[i-2]=tmp;
}
else if(i<t-1&&f[i]!=f[i+1]){
int tmp=f[i];
f[i]=f[i+1];
f[i+1]=tmp;
}
}
}
for(i=1;i<k;i++)
if(f[i-1]==f[i])
c++;
printf("%d\n",c);
return 0;
}
|
main.c: In function 'main':
main.c:15:26: error: expected ')' before ';' token
15 | for(j=0;f[j]!=0;j++
| ~ ^
| )
16 | ;
| ~
main.c:22:5: error: expected expression before '}' token
22 | }
| ^
|
s640634166
|
p03958
|
C++
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 999999999
int main() {
int k, t;
cin >> k >> t;
vector<P>cake(t);
REP(i, t) {
cin >> cake[i].first;
cake[i].second = i;
}
int ans = 0, pre = -1;
while (1) {
sort(cake.begin(), cake.end(),greater<int>());
if (cake[0].first == 0)break;
if (pre == cake[0].second) {
if (cake[1].first)cake[1].first--;
else {
ans += cake[0].first;
}
}
}
cout << ans << endl;
}
|
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = std::greater<int>]':
/usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1777 | if (__comp(__i, __first))
| ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1908 | std::__final_insertion_sort(__first, __last, __comp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = greater<int>]'
4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:48:7: required from here
48 | sort(cake.begin(), cake.end(),greater<int>());
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(std::greater<int>) (std::pair<int, int>&, std::pair<int, int>&)'
158 | { return bool(_M_comp(*__it1, *__it2)); }
| ~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:49,
from /usr/include/c++/14/bitset:52,
from a.cc:2:
/usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = int]'
394 | operator()(const _Tp& __x, const _Tp& __y) const
| ^~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'const int&'
394 | operator()(const _Tp& __x, const _Tp& __y) const
| ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<int, int>; _Iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = std::greater<int>]':
/usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<greater<int> >]'
1757 | while (__comp(__val, __next))
| ~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1785 | std::__unguarded_linear_insert(__i,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
1786 | __gnu_cxx::__ops::__val_comp_iter(__comp));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1908 | std::__final_insertion_sort(__first, __last, __comp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = greater<int>]'
4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:48:7: required from here
48 | sort(cake.begin(), cake.end(),greater<int>());
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(std::greater<int>) (std::pair<int, int>&, std::pair<int, int>&)'
240 | { return bool(_M_comp(__val, *__it)); }
| ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = int]'
394 | operator()(const _Tp& __x, const _Tp& __y) const
| ^~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'const int&'
394 | operator()(const _Tp& __x, const _Tp& __y) const
| ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Value = std::pair<int, int>; _Compare = std::greater<int>]':
/usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Distance = long int; _Tp = pair<int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<int> >]'
140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Distance = long int; _Tp = pair<int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
247 | std::__push_heap(__first, __holeIndex, __topIndex,
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248 | _GLIBCXX_MOVE(__value), __cmp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value),
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357 | __comp);
| ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1593 | std::__make_heap(__first, __middle, __comp);
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1868 | std::__heap_select(__first, __middle, __last, __comp);
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<int> >]'
1884 | std::__partial_sort(__first, __last, __last, __comp);
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
|
s599483544
|
p03958
|
C++
|
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
int K, T;
cin >> K >> T;
if (K == 1) {
cout << 0 << endl;
return;
}
if (T == 1) {
cout << K - 1 << endl;
return;
}
vector<int>a(T);
for (int i = 0; i < T; i++) {
cin >> a[i];
}
int fIndex = 0;
int sIndex = 1;
if (a[0] < a[1]) {
fIndex = 1;
sIndex = 0;
}
for (int i = 0; i < K / 2; i++) {
for (int j = 0; j < a.size(); j++) {
if (a[j] > a[fIndex]) {
sIndex = fIndex;
fIndex = j;
}
else if (a[j] > a[sIndex] && j != fIndex) {
sIndex = j;
}
}
if (a[sIndex] == 0) {
cout<<a[fIndex] - 1;
return;
}
a[fIndex]--;
a[sIndex]--;
}
cout << 0 << endl;
}
|
a.cc: In function 'int main()':
a.cc:13:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
13 | return;
| ^~~~~~
a.cc:17:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
17 | return;
| ^~~~~~
a.cc:46:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
46 | return;
| ^~~~~~
|
s680135803
|
p03958
|
C++
|
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
int K;
cin >> K;
int T;
cin >> T;
int tmp = T;
vector<int> nums;
while(tmp--){
int element;
cin >> element;
nums.push_back(element);
}
priority_queue<int> q;
for(auto b : nums){
q.push(b);
}
while(q.size() > 1){
vector<int> tmp;
for(int i = 0; i < 2; i++){
auto t = q.top();
q.pop();
if(--t > 0)
tmp.push(t);
}
for(auto a : tmp)
q.push(a);
}
if(q.empty())
cout << 0 << endl;
else if(q.size() == 1)
cout << q.top() - 1 << endl;
}
|
a.cc: In function 'int main()':
a.cc:28:37: error: 'class std::vector<int>' has no member named 'push'
28 | tmp.push(t);
| ^~~~
|
s372051060
|
p03958
|
Java
|
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int k = sc.nextInt();
int t = sc.nextInt();
int a[];
int maxa = 0;
int maxi = 0;
a = new int[t];
for(int i = 0; i<t; i++){
a[i] = sc.nextInt();
if(maxa < a[i]){
maxa = a[i];
maxi = i;
}
}
int toai = k - a[maxi];
int answer = 0;
if(maxa =< toai){
System.out.println(answer);
}
else{
answer = k - toai + 1;
System.out.println(answer);
}
}
}
|
Main.java:20: error: > or ',' expected
if(maxa =< toai){
^
1 error
|
s540812215
|
p03958
|
Java
|
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int K = sc.nextInt();
if (K == 1) {
System.out.println(0);
}
int T = sc.nextInt();
int[] a = new int[T];
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
}
int fIndex = 0;
int sIndex = 1;
if (a[0] < a[1]) {
fIndex = 1;
sIndex = 0;
}
for (int i = 0; i < K / 2; i++) {
for (int j = 0; j < a.length; j++) {
if (a[j] > a[fIndex]) {
sIndex = fIndex;
fIndex = j;
} else if (a[j] > a[sIndex] && j != fIndex) {
sIndex = j;
}
}
if (a[sIndex] == 0) {
System.out.println(a[fIndex] - 1);
return;
}
a[fIndex]--;
a[sIndex]--;
}
System.out.println(0);
}
}
|
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
^
1 error
|
s110085015
|
p03958
|
C++
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int K = sc.nextInt();
if (K == 1) {
System.out.println(0);
}
int T = sc.nextInt();
int[] a = new int[T];
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
}
int fIndex = 0;
int sIndex = 1;
if (a[0] < a[1]) {
fIndex = 1;
sIndex = 0;
}
for (int i = 0; i < K / 2; i++) {
for (int j = 0; j < a.length; j++) {
if (a[j] > a[fIndex]) {
sIndex = fIndex;
fIndex = j;
} else if (a[j] > a[sIndex] && j != fIndex) {
sIndex = j;
}
}
if (a[sIndex] == 0) {
System.out.println(a[fIndex] - 1);
return;
}
a[fIndex]--;
a[sIndex]--;
}
System.out.println(0);
}
}
|
a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
3 | public class Main {
| ^~~~~~
|
s669632025
|
p03958
|
Java
|
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int K = sc.nextInt();
if (K == 1) {
System.out.println(0);
}
int T = sc.nextInt();
int[] a = new int[T];
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
}
int fIndex = 0;
int sIndex = 1;
if (a[0] < a[1]) {
fIndex = 1;
sIndex = 0;
}
for (int i = 0; i < K / 2; i++) {
for (int j = 0; j < a.length; j++) {
if (a[j] > a[fIndex]) {
sIndex = fIndex;
fIndex = j;
} else if (a[j] > a[sIndex] && j != fIndex) {
sIndex = j;
}
}
if (a[sIndex] == 0) {
System.out.println(a[fIndex] - 1);
return;
}
a[fIndex]--;
a[sIndex]--;
}
System.out.println(0);
}
}
|
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
^
1 error
|
s771715320
|
p03958
|
Java
|
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int k = sc.nextInt();
int t = sc.nextInt();
int a[];
int maxa = 0;
int maxi = 0;
a = new int[t]
for(int i = 0; i<t; i++){
a[i] = sc.nextInt();
if(maxa < a[i]){
maxa = a[i];
maxi = i;
}
}
int toai = k - a[maxi];
int answer = 0;
if(maxa < toai){
System.out.println(answer);
}
else{
answer = k - toai + 1;
System.out.println(answer);
}
}
}
|
Main.java:10: error: ';' expected
a = new int[t]
^
1 error
|
s756357714
|
p03958
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int k,t;
cin >> k >> t;
vector<int> a(t);
max = -1;
for(int i = 0; i < t; i++){
cin >> a[i];
if(max < a[i])
max = a[i];
}
int ans;
ans = k - ((k - max) * 2 + 1);
if(ans < 0)
ans = 0;
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:10:10: error: overloaded function with no contextual type information
10 | max = -1;
| ^
a.cc:13:17: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
13 | if(max < a[i])
| ^
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]' declared here
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
a.cc:13:8: error: parse error in template argument list
13 | if(max < a[i])
| ^~~~~~~~~~
a.cc:13:18: error: cannot resolve overloaded function 'max' based on conversion to type 'bool'
13 | if(max < a[i])
| ^
a.cc:14:16: error: overloaded function with no contextual type information
14 | max = a[i];
| ^
a.cc:17:17: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator-'
17 | ans = k - ((k - max) * 2 + 1);
| ~~^~~~~
|
s713306727
|
p03958
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int K, T;
cin >> K;
cin >> T;
vector<int> A(T);
int temp;
int temp_Index;
for(int i=0; i < T; i++)
cin >> A[i];
int cont = 0;
vector<int>::iterator maxIt;
size_t max_Index;
for(int t=K; t > 0; t--){
maxIt = max_element(A.begin(), A.end());
max_Index = distance(A.begin(), maxIt);
if(A[max_Index] == 0){
cont = temp;
break;
}
A[max_Index]--;
if(t != K ) A[temp_Index] = temp;
temp = A[max_Index];
temp_Index = max_Index;
A[max_Index] = 0;
}
cout << temp << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:13: error: 'max_element' was not declared in this scope
21 | maxIt = max_element(A.begin(), A.end());
| ^~~~~~~~~~~
|
s427875367
|
p03958
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main(){
int K,T;
vector<int> a;
cin >> K >> T;
int input;
while(cin >> input){
a.push_back(input);
}
std::sort(a.begin(),a.end(),std::greater<int>());
if(T == 1){
cout << K - a[0];
}else{
int sum = 0;
for(int i = 1;i < a.size();i++){
sum += a[i];
}
if(sum > a[0]){
cout << '0';
}else{
cout << a[0] - sum - 1;
}
}
cout << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:13:14: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
13 | std::sort(a.begin(),a.end(),std::greater<int>());
| ^~~~
| qsort
|
s792650995
|
p03958
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
int k, t; cin >> k >> t;
vector<int>A(t);
for (int i = 0; i < t; i++) {
cin >> A[i];
}
sort(A.begin(), A.end(),greater<int>());
while(A.size()>1){
if (A.front() > A.back()) {
A.front() -= A.back();
A.erase(--A.end());
}
else if (A.front()!=1 && A.front() == A.back()) {
A.front()=1;
A.back() = 1;
}else break;
sort(A.begin(), A.end(), greater<int>());
}
cout<<A.front() - 1 << endl;
|
a.cc: In function 'int main()':
a.cc:30:37: error: expected '}' at end of input
30 | cout<<A.front() - 1 << endl;
| ^
a.cc:9:1: note: to match this '{'
9 | {
| ^
|
s738791212
|
p03958
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main(){
int K,T;
vector<int> a;
cin >> K >> T;
int input;
while(cin >> input){
a.push_back(input);
}
sort(a.begin(),a.end(),std::greater<int>());
if(T == 1){
cout << K - a[0];
}else{
int sum = 0;
for(int i = 1;i < a.size();i++){
sum += a[i];
}
if(sum > a[0]){
cout << '0';
}else{
cout << a[0] - sum - 1;
}
}
cout << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:13:9: error: 'sort' was not declared in this scope; did you mean 'short'?
13 | sort(a.begin(),a.end(),std::greater<int>());
| ^~~~
| short
|
s450821613
|
p03958
|
C++
|
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <set>
#include <map>
#include <conio.h>
#define INT long long
#define MOD 1000000007
#define oo 1987654321
using namespace std;
bool cmp(int a, int b){ return a>b; }
int k, t, p[100], ans;
int main()
{
cin>>k>>t;
for(int i = 0, x ; i < t ; i++ )
cin>>p[i];
while( k )
{
sort(p, p+t, cmp);
p[0]--, k--;
if( t-1 == 0 and ans ) ans++;
if( k > 0 )
{
p[t-1]--, k--;
if( t-1 == 0 ) ans++;
}
if( p[t-1] == 0 ) t--;
}
cout<<ans<<endl;
return 0;
}
|
a.cc:10:10: fatal error: conio.h: No such file or directory
10 | #include <conio.h>
| ^~~~~~~~~
compilation terminated.
|
s996308892
|
p03958
|
Java
|
mport java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t = sc.nextInt();
List<Integer> list = new LinkedList<>();
for(int i=0;i<t;i++) {
list.add(sc.nextInt());
}
int days =0;
Collections.sort(list);
if(list.get(t-1)>n-list.get(t-1)){
days = n - list.get(t-1) -1;
}
if(t==1){
days = n-t;
}
System.out.println(days);
}
}
|
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Collections;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.LinkedList;
^
Main.java:3: error: class, interface, enum, or record expected
import java.util.List;
^
Main.java:4: error: class, interface, enum, or record expected
import java.util.Scanner;
^
4 errors
|
s545808707
|
p03958
|
C++
|
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
int main(){
int K,T;
cin>>K>>T;
vector<int> v(T);
int i,j,k;
for(i=0;i<T;i++) cin>>v[i];
priority_queue<pair<int,int>> qu;
for(i=0;i<T;i++) qu.push(make_pair(v[i],i));
int pre=-1;
int res=0;
while(!qu.empty()){
pair<int,int> p=qu.top();
qu.pop();
if(p.second!=pre){
pre=p.second;
p.first--;
if(p.first) qu.push(p);
}
else if(qu.empty()){
res=p.first;
}
else{
pre=qu.top().second;
qu.top().first--;
if(qu.top().first==0) qu.pop();
qu.push(p);
}
}
cout<<res<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:30:34: error: decrement of member 'std::pair<int, int>::first' in read-only object
30 | qu.top().first--;
| ~~~~~~~~~^~~~~
|
s536854565
|
p03958
|
C++
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 999999999
int main() {
int k, t;
cin >> k >> t;
vector<P>cake(t);
REP(i, t) {
cin >> cake[i].first;
cake[i].second = i;
}
int ans = 0, pre = -1;
while (1) {
sort(cake.begin(), cake.end(),greater<int>();
if (cake[0].first == 0)break;
if (pre == cake[0].second) {
if (cake[1].first)cake[1].first--;
else {
ans += cake[0].first;
}
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:48:61: error: expected ')' before ';' token
48 | sort(cake.begin(), cake.end(),greater<int>();
| ~ ^
| )
|
s589437799
|
p03958
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <fstream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[]) {
int K,T;
int tt;
cin>>K>>T;
int max=INT_MIN;
for (int i=0;i<T;i++) {
cin>>tt;
if (tt>max) max=tt;
}
int other=max-(K-max)-1;
if (other<0) other=0;
cout<<other<<endl;
}
|
a.cc: In function 'int main(int, const char**)':
a.cc:20:12: error: 'INT_MIN' was not declared in this scope
20 | int max=INT_MIN;
| ^~~~~~~
a.cc:13:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
12 | #include <math.h>
+++ |+#include <climits>
13 |
|
s786054638
|
p03958
|
C++
|
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define DEBUG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
signed main() {
int K, T; cin >> K >> T;
vector<int> a(T);
rep(i, 0, T)cin >> a[i];
if (T != 1)rep(i, 0, T) {
sort(all(a));
a[T - 1] -= a[T - 2];
a[T - 2] = 0;
}
cout << max(0,a[T - 1] - 1) << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:20: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
24 | cout << max(0,a[T - 1] - 1) << endl;
| ~~~^~~~~~~~~~~~~~~~
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:24:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
24 | cout << max(0,a[T - 1] - 1) << endl;
| ~~~^~~~~~~~~~~~~~~~
/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:24:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
24 | cout << max(0,a[T - 1] - 1) << endl;
| ~~~^~~~~~~~~~~~~~~~
|
s396001540
|
p03958
|
C++
|
#include <iostream>
#include <cfloat>
#include <climits>
#include <list>
#include <algorithm>
using namespace std;
const int intinf = INT_MAX;
const long longinf = LONG_MAX;
const double doubleinf = DBL_MAX;
#define map std::unordered_map;
#define set std::unordered_set;
long long int f(int a, int b, int s, int p, list<int> l) {
if (a == 0)
return p;
long long int cnt = 0;
for (int i = 0; i < l.size(); i++) {
long long int j = 0;
auto t = l;
t.remove(i);
if (i == b)
j = f(a - 1, i, s, p + 1, t);
else j = f(a - 1, i, s, p, t);
cnt = std::min(j, p);
}
return std::min(cnt, p);
}
int main(void) {
int K, T;
cin >> K >> T;
list<int> a;
for (int i = 0; i < T; i++) {
cin >> a.insert;
}
cout << f(K, -1, T, 0, a);
return 0;
}
|
a.cc: In function 'long long int f(int, int, int, int, std::__cxx11::list<int>)':
a.cc:28:23: error: no matching function for call to 'min(long long int&, int&)'
28 | cnt = std::min(j, p);
| ~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:28:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
28 | cnt = std::min(j, p);
| ~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:28:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
28 | cnt = std::min(j, p);
| ~~~~~~~~^~~~~~
a.cc:30:20: error: no matching function for call to 'min(long long int&, int&)'
30 | return std::min(cnt, p);
| ~~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:30:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
30 | return std::min(cnt, p);
| ~~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:30:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
30 | return std::min(cnt, p);
| ~~~~~~~~^~~~~~~~
a.cc: In function 'int main()':
a.cc:38:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '<unresolved overloaded function type>')
38 | cin >> a.insert;
| ~~~ ^~ ~~~~~~~~
| | |
| | <unresolved overloaded function type>
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool&'
170 | operator>>(bool& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]'
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int&'
174 | operator>>(short& __n);
| ~~~~~~~^~~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int&'
177 | operator>>(unsigned short& __n)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]'
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int&'
181 | operator>>(int& __n);
| ~~~~~^~~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int&'
184 | operator>>(unsigned int& __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int&'
188 | operator>>(long& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int&'
192 | operator>>(unsigned long& __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int&'
199 | operator>>(long long& __n)
| ~~~~~~~~~~~^~~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int&'
203 | operator>>(unsigned long long& __n)
| ~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float&'
219 | operator>>(float& __f)
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
223 | operator>>(double& __f)
| ^~~
|
s865376891
|
p03958
|
C++
|
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int k, t,tmp;
cin >> k >> t;
vector<int> a(t);
rep(i, 0, t){
cin >> tmp;
a[i] = tmp;
}
if (t == 1)cout << k - 1 << endl;
else{
sort(a.begin(), a.end()){
rep(i, 0, t-1){
for (; a[i] > 0;){
if (a[i + 1] > 0){
a[i]--;
a[i + 1]--;
}
}
}
}
int ans = 0;
rep(i, 0, t){
ans += a[i];
}
}
ans--;
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:26:41: error: expected ';' before '{' token
26 | sort(a.begin(), a.end()){
| ^
| ;
a.cc:41:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
41 | ans--;
| ^~~
| abs
|
s421752576
|
p03958
|
C++
|
#include <iostream>
#include <cstdio>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int ans;
int n,t,a[100],max;
int main() {
cin >> n >> t;
max = 0;
rep(i,n){
cin >> a[i];
if(max < a[i]) max = a[i];
}
if(max>n-max+1){
ans = max-(n-max)+1;
cout << ans << endl;
}else cout << 0 << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:11:3: error: reference to 'max' is ambiguous
11 | max = 0;
| ^~~
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:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:8:16: note: 'int max'
8 | int n,t,a[100],max;
| ^~~
a.cc:14:8: error: reference to 'max' is ambiguous
14 | if(max < a[i]) max = a[i];
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:8:16: note: 'int max'
8 | int n,t,a[100],max;
| ^~~
a.cc:14:20: error: reference to 'max' is ambiguous
14 | if(max < a[i]) max = a[i];
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:8:16: note: 'int max'
8 | int n,t,a[100],max;
| ^~~
a.cc:16:6: error: reference to 'max' is ambiguous
16 | if(max>n-max+1){
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:8:16: note: 'int max'
8 | int n,t,a[100],max;
| ^~~
a.cc:16:12: error: reference to 'max' is ambiguous
16 | if(max>n-max+1){
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:8:16: note: 'int max'
8 | int n,t,a[100],max;
| ^~~
a.cc:17:11: error: reference to 'max' is ambiguous
17 | ans = max-(n-max)+1;
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:8:16: note: 'int max'
8 | int n,t,a[100],max;
| ^~~
a.cc:17:18: error: reference to 'max' is ambiguous
17 | ans = max-(n-max)+1;
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:8:16: note: 'int max'
8 | int n,t,a[100],max;
| ^~~
|
s354357445
|
p03958
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main() {
long long int K, T;
cin >> K >> T;
vector<long long int>a( T );
priority_queue<pair<long long int, long long int>, vector<long long int, long long int>, greater<pair<long long int, long long int>>>que;
for( size_t i = 0; i < T; i++ ) {
cin >> a[i];
que.push( make_pair( a[i], i ) );
}
long long int prev = -1;
int f = 0;
long long int ans = 0;
while( que.size() ) {
pair<long long int, long long int> now = que.top(); que.pop();
if( now.second == prev ) {
if( que.size() ) {
pair<long long int, long long int> next = que.top(); que.pop();
next.first--;
prev = next.second;
if( next.first != 0 ) {
que.push( next );
}
if( now.first != 0 ) {
que.push( now );
}
} else {
ans = now.first;
break;
}
} else {
now.first--;
if( now.first != 0 ) {
que.push( now );
}
}
}
cout << ans << endl;
}
|
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<long long int, long long int>':
/usr/include/c++/14/bits/stl_vector.h:428:11: required from 'class std::vector<long long int, long long int>'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: required from 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >'
520 | static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
| ^~~~~
a.cc:9:135: required from here
9 | priority_queue<pair<long long int, long long int>, vector<long long int, long long int>, greater<pair<long long int, long long int>>>que;
| ^~~
/usr/include/c++/14/bits/stl_vector.h:87:28: error: 'long long int' is not a class, struct, or union type
87 | rebind<_Tp>::other _Tp_alloc_type;
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:89:9: error: 'long long int' is not a class, struct, or union type
89 | pointer;
| ^~~~~~~
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'class std::vector<long long int, long long int>':
/usr/include/c++/14/bits/stl_queue.h:520:67: required from 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >'
520 | static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
| ^~~~~
a.cc:9:135: required from here
9 | priority_queue<pair<long long int, long long int>, vector<long long int, long long int>, greater<pair<long long int, long long int>>>que;
| ^~~
/usr/include/c++/14/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
518 | using _Base::_M_allocate;
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
519 | using _Base::_M_deallocate;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<long long int, long long int>::_Base'
521 | using _Base::_M_get_Tp_allocator;
| ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >':
a.cc:9:135: required from here
9 | priority_queue<pair<long long int, long long int>, vector<long long int, long long int>, greater<pair<long long int, long long int>>>que;
| ^~~
/usr/include/c++/14/bits/stl_queue.h:520:67: error: static assertion failed: value_type must be the same as the underlying container
520 | static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
| ^~~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: note: 'std::integral_constant<bool, false>::value' evaluates to false
In file included from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = long long int; _Alloc = long long int]':
/usr/include/c++/14/type_traits:1110:25: required by substitution of 'template<class _Tp, class ... _Args> using std::__is_constructible_impl = std::__bool_constant<__is_constructible(_Tp, _Args ...)> [with _Tp = std::vector<long long int, long long int>; _Args = {}]'
1110 | = __bool_constant<__is_constructible(_Tp, _Args...)>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:1124:12: required from 'struct std::is_default_constructible<std::vector<long long int, long long int> >'
1124 | struct is_default_constructible
| ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:183:35: required by substitution of 'template<class ... _Bn> std::__detail::__first_t<std::integral_constant<bool, true>, typename std::enable_if<(bool)(_Bn::value), void>::type ...> std::__detail::__and_fn(int) [with _Bn = {std::is_default_constructible<std::greater<std::pair<long long int, long long int> > >, std::is_default_constructible<std::vector<long long int, long long int> >}]'
183 | __enable_if_t<bool(_Bn::value)>...>;
| ^~~~~
/usr/include/c++/14/type_traits:199:42: required from 'struct std::__and_<std::is_default_constructible<std::greater<std::pair<long long int, long long int> > >, std::is_default_constructible<std::vector<long long int, long long int> > >'
199 | : decltype(__detail::__and_fn<_Bn...>(0))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:551:43: required by substitution of 'template<class _Seq, class _Requires> std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >::priority_queue() [with _Seq = std::vector<long long int, long long int>; _Requires = <missing>]'
551 | template<typename _Seq = _Sequence, typename _Requires = typename
| ^~~~~~~~
a.cc:9:135: required from here
9 | priority_queue<pair<long long int, long long int>, vector<long long int, long long int>, greater<pair<long long int, long long int>>>que;
| ^~~
/usr/include/c++/14/bits/stl_vector.h:136:24: error: 'long long int' is not a class, struct, or union type
136 | _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
| ^~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:12:25: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >::push(std::pair<long long int, long unsigned int>)'
12 | que.push( make_pair( a[i], i ) );
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<long long int, long long int>; _Compare = std::greater<std::pair<long long int, long long int> >; value_type = long long int]'
736 | push(const value_type& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from 'std::pair<long long int, long unsigned int>' to 'const std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >::value_type&' {aka 'const long long int&'}
736 | push(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<long long int, long long int>; _Compare = std::greater<std::pair<long long int, long long int> >; value_type = long long int]'
744 | push(value_type&& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from 'std::pair<long long int, long unsigned int>' to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >::value_type&&' {aka 'long long int&&'}
744 | push(value_type&& __x)
| ~~~~~~~~~~~~~^~~
a.cc:18:62: error: 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >' has no member named 'top'; did you mean 'pop'?
18 | pair<long long int, long long int> now = que.top(); que.pop();
| ^~~
| pop
a.cc:21:79: error: 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<long long int, long long int>, std::greater<std::pair<long long int, long long int> > >' has no member named 'top'; did you mean 'pop'?
21 | pair<long long int, long long int> next = que.top(); que.pop();
| ^~~
|
|
s989455982
|
p03958
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N = 0, day = 0;
cin >> N;
cin >> day;
vector<int> cakes;
int arg = 0;
for(int i = 0; i < N; i++) {
cin >> arg;
cakes.push_back(arg);
}
int max = *max_element(cakes.begin(), cakes.end());
max+=max;
for(int i = 0; i < N; i++) {
max -= cakes[i];
}
if (max > 0)
cout << max-1 << endl;
else
cout << "0" << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:19:16: error: 'max_element' was not declared in this scope
19 | int max = *max_element(cakes.begin(), cakes.end());
| ^~~~~~~~~~~
|
s432261239
|
p03958
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
ll gcd(ll a,ll b){
if(b==0) return a;
else return gcd(b,a%b);
}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
int K;
int T;
int main(){
cin>> K>> T;
vi a(T);
priority_queue<pii,vector<pii>,greater<pii>> que;
rep(i,T){
cin>>a[i];
que.push(pii(a[i],i));
}
sort(ALL(a[i]));
reverse(all(a));
int ans=0;
for(int i=0;i<T;i++){
if(a[i]==0) continue;
for(int j=i+1;j<T;j++){
if(a[j]==0) continue;
if(a[i]>=a[j]){
int t = a[j];
a[i] -= a[i];
a[j] = 0;
}
}
}
rep(i,T) if(a[i]>0){
ans += (a[i]-1);
}
cout << ans << endl;
}
|
a.cc:18:1: error: 'll' does not name a type; did you mean 'all'?
18 | ll gcd(ll a,ll b){
| ^~
| all
a.cc: In function 'int main()':
a.cc:45:17: error: 'i' was not declared in this scope
45 | sort(ALL(a[i]));
| ^
a.cc:11:17: note: in definition of macro 'ALL'
11 | #define ALL(v) (v).begin(),(v).end()
| ^
|
s658407380
|
p03958
|
C++
|
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int ans;
int k;
int t;
int index;
int mm;
int a[105];
int before;
int main()
{
cin>>k>>t;
rep(i,t)cin>>a[i];
before=-1;
rep(kkk,k)
{
mm=0;
rep(i,t)
{
if(mm<a[i]&&before!=i)
{
mm=a[i];
index=i;
}
}
if(mm==0)
{
ans++;
a[index]--;
}
else
{
ans++;
a[index]--;
before=index;
}
}
cout<<ans<<endl;
return 0;
}
|
a.cc:23:5: error: 'int index' redeclared as different kind of entity
23 | int index;
| ^~~~~
In file included from /usr/include/string.h:462,
from /usr/include/c++/14/cstring:43,
from a.cc:10:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
50 | extern const char *index (const char *__s, int __c)
| ^~~~~
a.cc: In function 'int main()':
a.cc:40:39: error: overloaded function with no contextual type information
40 | index=i;
| ^
a.cc:46:26: error: invalid types 'int [105][<unresolved overloaded function type>]' for array subscript
46 | a[index]--;
| ^
a.cc:51:26: error: invalid types 'int [105][<unresolved overloaded function type>]' for array subscript
51 | a[index]--;
| ^
a.cc:52:32: error: cannot resolve overloaded function 'index' based on conversion to type 'int'
52 | before=index;
| ^~~~~
|
s296777781
|
p03958
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
int main(){
int K, T;
cin >> K >> T;
priority_queue<int> a;
for(int i=0;i<T;i++){
int temp;
cin >> temp;
a.push(temp);
}
while(a.size() > 1){
int big = a.top(); a.pop();
int small = a.top(); .a.pop();
a.push(big - small);
}
cout << a.top() << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:30: error: expected primary-expression before '.' token
24 | int small = a.top(); .a.pop();
| ^
|
s166360245
|
p03958
|
C++
|
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int k;
int t;
int index;
int mm;
int a[105];
int before;
int main()
{
cin>>k>>t;
rep(i,t)cin>>a[i];
before=-1;
for(kkk,k)
{
mm=0;
rep(i,t)
{
if(mm<a[i]&&before!=i)
{
mm=a[i];
index=i;
}
}
if(mm==0)
{
ans++;
a[index]--;
}
else
{
ans++;
a[index]--;
before=index;
}
}
cout<<ans<<endl;
return 0;
}
|
a.cc:23:5: error: 'int index' redeclared as different kind of entity
23 | int index;
| ^~~~~
In file included from /usr/include/string.h:462,
from /usr/include/c++/14/cstring:43,
from a.cc:10:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
50 | extern const char *index (const char *__s, int __c)
| ^~~~~
a.cc: In function 'int main()':
a.cc:32:13: error: 'kkk' was not declared in this scope
32 | for(kkk,k)
| ^~~
a.cc:55:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
55 | cout<<ans<<endl;
| ^~~
| abs
a.cc:56:9: error: expected primary-expression before 'return'
56 | return 0;
| ^~~~~~
a.cc:55:25: error: expected ')' before 'return'
55 | cout<<ans<<endl;
| ^
| )
56 | return 0;
| ~~~~~~
a.cc:32:12: note: to match this '('
32 | for(kkk,k)
| ^
|
s330677704
|
p03958
|
C++
|
#include<stdio.h>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
void solve(){
}
int main() {
int k,t;
int a[105];
cin>>k>>t;
for(int i=0;i<t;i++){
cin>>a[i];
}
sort(a,a+t);
int o=0;
for(int i=0;i<t-1;i++){
o+=a[i];
}
cout<<max(0,a[t-1]-1-o)<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
17 | sort(a,a+t);
| ^~~~
| short
|
s478240994
|
p03958
|
C++
|
#include <iostream>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int K, T;
int a[100];
cin >> K >> T;
for(int i=0; i<T; i++) cin >> a[i];
sort(a, a+T);
int rest = 0;
for(int i=0; i<T-1; i++) rest += a[i];
cout << max(0, a[T-1] - rest - 1) << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
12 | sort(a, a+T);
| ^~~~
| short
|
s726169869
|
p03958
|
C++
|
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define OUT(a) cout<<(a)<<endl;
#define ALL(v) (v).begin(), (v).end()
typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
const LL LINF=1ll<<62; const int INF=1ll<<30; const LL MOD=1E9+7;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int k,t,s=0;
cin >> k >> t;
vector<int> v(t);
REP(i,t){
cin >> v[i];
s+=v[i];
}
sort(ALL(v));
int d=sum-v[t-1];
if(d==0) cout << v[t-1];
else{
cout << max(0,v[t-1]-d-1)<<endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:49:11: error: 'sum' was not declared in this scope
49 | int d=sum-v[t-1];
| ^~~
|
s710979719
|
p03959
|
C++
|
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;
//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){ if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}
int main(){
ll n ; cin >> n ;
vll a(n),b(n),h(n,-1) ;
for(auto &i:a) cin >> i ;
for(auto &i:b) cin >> i ;
for(int i=0;i<n;i++) if(i==0||a[i-1]<a[i]) h[i] = a[i] ;
for(int i=n-1;i>=0;i--){
if(i==n-1||b[i]>b[i+1]){
if(h[i]!=-1&&h[i]!=b[i]){
cout << 0 << endl ;
return 0 ;
}
h[i] = b[i] ;
}
}
if(a[n-1!=b[0]){
cout << 0 << endl ;
return 0 ;
}
ll ans = 1 ;
for(int i=0;i<n;i++){
if(h[i]!=-1) continue ;
ans = ans*min(a[i],b[i])%mod ;
}
cout << ans << endl ;
}
|
a.cc: In function 'int main()':
a.cc:52:19: error: expected ']' before ')' token
52 | if(a[n-1!=b[0]){
| ^
| ]
|
s983455419
|
p03959
|
C++
|
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const ll INF=1e18;
const ll inf=1e9;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
const int MAX=510000;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int>t(n),a(n);
rep(i,n) cin >> t[i];
rep(i,n) cin >> a[i];
vector<int>h(n);
h[0]=t[0];
rep(i,n-1){
if(t[i]<t[i+1])h[i+1]=t[i+1];
}
bool ok = true;
if(h[n-1]!=a[n-1])ok=false;
rep(i,n-1){
if(a[n-1-i]<a[n-1-(i+1)] && h[n-1-(i+1)]!=a[n-1-(i+1)])ok=false;
else if(a[n-1-i]<a[n-1-(i+1)])h[n-1-(i+1)]=a[n-1-(i+1)];
}
ll ans = 1;
rep(i,n-1){
}
}
return 0;
}
|
a.cc:48:3: error: expected unqualified-id before 'return'
48 | return 0;
| ^~~~~~
a.cc:49:1: error: expected declaration before '}' token
49 | }
| ^
|
s573748951
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
/******* All Required define Pre-Processors and typedef Constants *******/
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define Dcout(a) cout << setprecision(20) << a << endl
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define fi first
#define se second
using Graph = vector<vector<ll>>;
// const ll INF = (1LL << 60);
const double pi=acos(-1.0);
/******************* debug ********************/
#define debug(var) do{std::cout << #var << " : ";view(var);}while(0)
#define deb cout << "line : " << __LINE__ << " debug" << endl
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){
for(const auto& e : v) cout << e << " ";
cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){
for(const auto& v : vv){ view(v); }}
/****** Template of some basic operations *****/
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
cerr << fixed << setprecision(10);
}
} iosetup;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
os << p.first << " " << p.second;
return os;
}
template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
is >> p.first >> p.second;
return is;
}
template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
for(int i = 0; i < (int) v.size(); i++) {
os << v[i] << (i + 1 != v.size() ? " " : "");
}
return os;
}
template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
for(T &in : v) is >> in;
return is;
}
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T = ll >
vector< T > make_v(size_t a) {
return vector< T >(a);
}
template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}
template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
t = v;
}
template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
for(auto &e : t) fill_v(e, v);
}
template< typename F >
struct FixPoint : F {
FixPoint(F &&f) : F(forward< F >(f)) {}
template< typename... Args >
decltype(auto) operator()(Args &&... args) const {
return F::operator()(*this, forward< Args >(args)...);
}
};
template< typename F >
inline decltype(auto) MFP(F &&f) {
return FixPoint< F >{forward< F >(f)};
}
/*******************************************************/
/******************** Start coding ! *******************/
constexpr int mod = 1000000007;
class mint {
public:
long long x;
constexpr mint(long long x=0) : x((x%mod+mod)%mod) {}
constexpr mint operator-() const {
return mint(-x);
}
constexpr mint& operator+=(const mint& a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
constexpr mint& operator-=(const mint& a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
constexpr mint& operator*=(const mint& a) {
(x *= a.x) %= mod;
return *this;
}
constexpr mint operator+(const mint& a) const {
mint res(*this);
return res+=a;
}
constexpr mint operator-(const mint& a) const {
mint res(*this);
return res-=a;
}
constexpr mint operator*(const mint& a) const {
mint res(*this);
return res*=a;
}
constexpr mint pow(long long t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
constexpr mint inv() const {
return pow(mod-2);
}
constexpr mint& operator/=(const mint& a) {
return (*this) *= a.inv();
}
constexpr mint operator/(const mint& a) const {
mint res(*this);
return res/=a;
}
};
ostream& operator<<(ostream& os, const mint& m){
os << m.x;
return os;
}
int main(){
int n; cin >> n;
vector<ll> t(n),a(n),h(n,-1);
rep(i,n) cin >> t[i];
rep(i,n) cin >> a[i];
if(t[n-1]!=a[0]){
cout << 0 << endl;
return 0;
}
//決定できる高さを書き込む
h[0] = t[0];
h[n-1] = a[n-1];
for(int i=1; i<n; ++i){
//前よりも高くなる時は決定できる
if(t[i-1]<t[i]){
//この時にすでに書き込まれている場合は矛盾
if(h[i]>=0 && h[i]!=t[i]){
cout << 0 << endl;
return 0;
}
h[i] = t[i];
}
}
//上と同様に右からもする
for(int i=n-2; i>=0; --i){
if(a[i]>a[i+1]){
if(h[i]>=0 && h[i]!=a[i]){
cout << 0 << endl;
return 0;
}
h[i] = a[i];
}
}
mint ans = 1;
rep(i,n){
//何でもいい時には小さい方の全通りが試せる
if(h[i]==-1){
ans *= min(t[i],a[i]);
//この判定が難しい↓
//実際の値がある場合はそのチェックもする。
// }else if(h[i]>min(t[i],a[i])){
// cout << 0 << endl;
// return 0;
// }
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:220:2: error: expected '}' at end of input
220 | }
| ^
a.cc:168:11: note: to match this '{'
168 | int main(){
| ^
|
s921103930
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;
template <typename T>
bool chmin(T& x, T y){
if(x > y){
x = y;
return true;
}
return false;
}
template <typename T>
bool chmax(T& x, T y){
if(x < y){
x = y;
return true;
}
return false;
}
auto factoring = [](i64 x){
int sq = sqrt(x) + 1;
vector<int> ret;
if(x == 1){
ret.emplace_back(1);
return ret;
}
for(i64 i = 2; i < sq; ++i)
while(x % i == 0){
ret.emplace_back(i);
x /= i;
}
if(x != 1)
ret.emplace_back(x);
return ret;
};
template <i64 mod = MOD>
struct ModInt{
i64 p;
ModInt() : p(0){}
ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}
ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}
ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}
friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
stream << *x;
return stream;
}
friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
stream >> *x;
return stream;
}
ModInt& operator++(){p = (p + 1) % mod; return *this;}
ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}
bool operator==(const ModInt& y) const{return p == *y;}
bool operator!=(const ModInt& y) const{return p != *y;}
const i64& operator*() const{return p;}
i64& operator*(){return p;}
};
using mint = ModInt<>;
signed main(){
int n;
cin >> n;
vector<int> a(n), b(n);
for(int i = 0; i < n; ++i)
cin >> a[i];
for(int i = 0; i < n; ++i)
cin >> b[i];
if(b.back() == a.front()){
cout << 0 << endl;
return;
}
vector<int> rb(n, 0);
vector<int> lb(n, MOD);
for(int i = 0; i < n; ++i){
if(i == 0 || a[i - 1] != a[i])
rb[i] = a[i];
chmin(lb[i], a[i]);
}
for(int i = n - 1; i >= 0; --i){
if(i == n - 1 || b[i + 1] != b[i]){
if(rb[i] != 0 && rb[i] != b[i]){
cout << 0 << endl;
return 0;
}
rb[i] = b[i];
}
chmin(lb[i], b[i]);
}
mint ans = 1;
for(int i = 0; i < n; ++i){
if(rb[i] == 0)
ans *= lb[i];
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:99:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
99 | return;
| ^~~~~~
|
s287751305
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;
template <typename T>
bool chmin(T& x, T y){
if(x > y){
x = y;
return true;
}
return false;
}
template <typename T>
bool chmax(T& x, T y){
if(x < y){
x = y;
return true;
}
return false;
}
auto factoring = [](i64 x){
int sq = sqrt(x) + 1;
vector<int> ret;
if(x == 1){
ret.emplace_back(1);
return ret;
}
for(i64 i = 2; i < sq; ++i)
while(x % i == 0){
ret.emplace_back(i);
x /= i;
}
if(x != 1)
ret.emplace_back(x);
return ret;
};
template <i64 mod = MOD>
struct ModInt{
i64 p;
ModInt() : p(0){}
ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}
ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}
ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}
friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
stream << *x;
return stream;
}
friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
stream >> *x;
return stream;
}
ModInt& operator++(){p = (p + 1) % mod; return *this;}
ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}
bool operator==(const ModInt& y) const{return p == *y;}
bool operator!=(const ModInt& y) const{return p != *y;}
const i64& operator*() const{return p;}
i64& operator*(){return p;}
};
using mint = ModInt<>;
signed main(){
int n;
cin >> n;
vector<int> a(n), b(n);
for(int i = 0; i < n; ++i)
cin >> a[i];
for(int i = 0; i < n; ++i)
cin >> b[i];
if(a.back() == b.front()){
cout << 0 << endl;
return;
}
vector<int> rb(n, 0);
vector<int> lb(n, MOD);
for(int i = 0; i < n; ++i){
if(i == 0 || a[i - 1] != a[i])
rb[i] = a[i];
chmin(lb[i], a[i]);
}
for(int i = n - 1; i >= 0; --i){
if(i == n - 1 || b[i + 1] != b[i]){
if(rb[i] != 0 && rb[i] != b[i]){
cout << 0 << endl;
return 0;
}
rb[i] = b[i];
}
chmin(lb[i], b[i]);
}
mint ans = 1;
for(int i = 0; i < n; ++i){
if(rb[i] == 0)
ans *= lb[i];
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:99:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
99 | return;
| ^~~~~~
|
s415803264
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
seen[v] = true;
for (auto nv : G[v]) {
if (nv == p) continue;
if (finished[nv]) continue;
if (seen[nv] && !finished[nv]) {
pos = nv;f++;
return;
}
dfs(G, nv, v);
// サイクル検出したならば真っ直ぐに抜けていく
if (pos != -1) {
return;}}
finished[v] = true;
}
mint calc(long long N, long long K) {
mint res = 1;
for (long long n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
int main() {
ll n; cin>>n;
ll a[n]={},b[n]={},c[n]={},d[n]={};
for(ll i=0; i<n; i++){
cin>>a[i];}
rep(i,n) cin>>b[i];
c[0]=a[0];
d[n-1]=b[n-1];
repl(i,1,n){
if(a[i-1]<a[i]){
c[i]=a[i];}}
repl(i,0,n-1){
if(b[n-1-i]<b[n-i]){
d[n-1-i]=b[n-1-i];}}
ll f=0;
rep(i,n){
if(c[i]>0&&d[i]>0&&c[i]!=d[i]){
f++;
break;}
else if(c[i]>0){
a[i]=c[i];}
else if(d[i]>0){
a[i]=d[i];}
else
a[i]=0;}
if(f==1) cout << 0 << endl;
else{
ll ans = 1;
for(ll i=0; i<n; i++){
if(a[i]==0){
ll m = a[i-1];
ll ca = 1;
ll u;
while(1){
i++;
if(a[i]==0){
ca++;
continue;}
else{
u = a[i];
break;}}
ll g = min(m,u);
while(ca){
ans*=g;
ans%=MOD;
ca--;}
}
else continue;}
cout << ans << endl;}
|
a.cc: In function 'int main()':
a.cc:156:22: error: expected '}' at end of input
156 | cout << ans << endl;}
| ^
a.cc:108:12: note: to match this '{'
108 | int main() {
| ^
|
s326666864
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
seen[v] = true;
for (auto nv : G[v]) {
if (nv == p) continue;
if (finished[nv]) continue;
if (seen[nv] && !finished[nv]) {
pos = nv;f++;
return;
}
dfs(G, nv, v);
// サイクル検出したならば真っ直ぐに抜けていく
if (pos != -1) {
return;}}
finished[v] = true;
}
mint calc(long long N, long long K) {
mint res = 1;
for (long long n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
int main() {
ll n; cin>>n;
ll a[n]={},b[n]={},c[n]={},d[n]={};
for(ll i=0; i<n; i++){
cin>>a[i]}
rep(i,n) cin>>b[i];
c[0]=a[0];
d[n-1]=b[n-1];
repl(i,1,n){
if(a[i-1]<a[i]){
c[i]=a[i];}}
repl(i,0,n-1){
if(b[n-1-i]<b[n-i]){
d[n-1-i]=b[n-1-i];}}
ll f=0;
rep(i,n){
if(c[i]>0&&d[i]>0&&c[i]!=d[i]){
f++;
break;}
else if(c[i]>0){
a[i]=c[i];}
else if(d[i]>0){
a[i]=d[i];}
else
a[i]=0;}
if(f==1) cout << 0 << endl;
else{
ll ans = 1;
for(ll i=0; i<n; i++){
if(a[i]==0){
ll m = a[i-1];
ll ca = 1;
ll u;
while(1){
i++;
if(a[i]==0){
ca++;
continue;}
else{
u = a[i];
break;}}
ll g = min(m,u);
while(ca){
ans*=g;
ans%=MOD;
ca--;}
}
else continue;}
cout << ans << endl;}
|
a.cc: In function 'int main()':
a.cc:112:10: error: expected ';' before '}' token
112 | cin>>a[i]}
| ^
| ;
a.cc:156:22: error: expected '}' at end of input
156 | cout << ans << endl;}
| ^
a.cc:108:12: note: to match this '{'
108 | int main() {
| ^
|
s064103592
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
seen[v] = true;
for (auto nv : G[v]) {
if (nv == p) continue;
if (finished[nv]) continue;
if (seen[nv] && !finished[nv]) {
pos = nv;f++;
return;
}
dfs(G, nv, v);
// サイクル検出したならば真っ直ぐに抜けていく
if (pos != -1) {
return;}}
finished[v] = true;
}
mint calc(long long N, long long K) {
mint res = 1;
for (long long n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
int main() {
ll n; cin>>n;
ll a[n]={},b[n]={},c[n]={},d[n]={};
for(ll i=0; i<n; i++){
cin>>a[i];}
rep(i,n) cin>>b[i];
c[0]=a[0];
d[n-1]=b[n-1];
repl(i,1,n){
if(a[i-1]<a[i]){
c[i]=a[i];}}
repl(i,0,n-1){
if(b[n-1-i]<b[n-i]){
d[n-1-i]=b[n-1-i];}}
ll f=0;
rep(i,n){
if(c[i]>0&&d[i]>0&&c[i]!=d[i]){
f++;
break;}
else if(c[i]>0){
a[i]=c[i];}
else if(d[i]>0){
a[i]=d[i];}
else
a[i]=0;}
if(f==1) cout << 0 << endl;
else{
ll ans = 1;
for(ll i=0; i<n; i++){
if(a[i]==0){
ll m = a[i-1];
ll ca = 1;
ll u;
while(1){
i++;
if(a[i]==0){
ca++;
continue;}
else{
u = a[i];
break;}}
ll g = min(m,u);
while(ca){
ans*=g;
ans%=MOD;
ca--;}
}
cout << ans << endl;}
|
a.cc: In function 'int main()':
a.cc:155:22: error: expected '}' at end of input
155 | cout << ans << endl;}
| ^
a.cc:134:5: note: to match this '{'
134 | else{
| ^
a.cc:155:22: error: expected '}' at end of input
155 | cout << ans << endl;}
| ^
a.cc:108:12: note: to match this '{'
108 | int main() {
| ^
|
s931919269
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
seen[v] = true;
for (auto nv : G[v]) {
if (nv == p) continue;
if (finished[nv]) continue;
if (seen[nv] && !finished[nv]) {
pos = nv;f++;
return;
}
dfs(G, nv, v);
// サイクル検出したならば真っ直ぐに抜けていく
if (pos != -1) {
return;}}
finished[v] = true;
}
mint calc(long long N, long long K) {
mint res = 1;
for (long long n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
int main() {
ll n; cin>>n;
ll a[n]={},b[n]={},c[n]={},d[n]={};
for(ll i=0; i<n; i++){
cin>>a[i]}
rep(i,n) cin>>b[i];
c[0]=a[0];
d[n-1]=b[n-1];
repl(i,1,n){
if(a[i-1]<a[i]){
c[i]=a[i];}}
repl(i,0,n-1){
if(b[n-1-i]<b[n-i]){
d[n-1-i]=b[n-1-i];}}
ll f=0;
rep(i,n){
if(c[i]>0&&d[i]>0&&c[i]!=d[i]){
f++;
break;}
else if(c[i]>0){
a[i]=c[i];}
else if(d[i]>0){
a[i]=d[i];}
else
a[i]=0;}
if(f==1) cout << 0 << endl;
else{
ll ans = 1;
for(ll i=0; i<n; i++){
if(a[i]==0){
ll m = a[i-1];
ll ca = 1;
ll u;
while(1){
i++;
if(a[i]==0){
ca++;
continue;}
else{
u = a[i];
break;}}
ll g = min(m,u);
while(ca){
ans*=g;
ans%=MOD;
ca--;}
}
cout << ans << endl;}
|
a.cc: In function 'int main()':
a.cc:112:10: error: expected ';' before '}' token
112 | cin>>a[i]}
| ^
| ;
a.cc:155:22: error: expected '}' at end of input
155 | cout << ans << endl;}
| ^
a.cc:134:5: note: to match this '{'
134 | else{
| ^
a.cc:155:22: error: expected '}' at end of input
155 | cout << ans << endl;}
| ^
a.cc:108:12: note: to match this '{'
108 | int main() {
| ^
|
s988427378
|
p03959
|
C++
|
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
constexpr ll mod = 1000000007LL;
int main(void){
int N; cin >> N;
vector<int> T(N), A(N);
for (auto& ti : T) cin >> ti;
for (auto& ai : A) cin >> ai;
vector<int> d(N, 0);
d[0] = T[0];
d[N - 1] = A[N - 1];
for (int i = 1; i < N; ++i){
if (T[i] > T[i - 1] && d[i] == 0) d[i] = T[i];
else if (T[i] > T[i - 1] && d[i] != T[i]){
cout << 0 << endl;
return
}
}
for (int i = 0; i < N - 1; ++i){
if (A[i] > A[i + 1] && d[i] == 0)
d[i] = A[i];
else if (A[i] > A[i + 1] && d[i] != A[i]){
cout << 0 << endl;
return 0;
}
}
ll res = 1;
for (int i = 0; i < N; ++i)
if (d[i] == 0)
res = (res * min(A[i], T[i])) % mod;
cout << res << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:17: error: expected primary-expression before '}' token
24 | }
| ^
a.cc:23:31: error: expected ';' before '}' token
23 | return
| ^
| ;
24 | }
| ~
|
s285839645
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; } //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
int n;
cin >> n;
ll t[n];
ll a[n];
rep(i,n)cin >> t[i];
rep(i,n)cin >> a[i];
ll mi[n];
ll ma[n];
mi[0]=t[0];
ma[0]=t[0];
if(t[n-1]!=a[0]){
cout << 0 << endl;
return 0;
}
rep(i,n-1){
if(t[i]==t[i+1]){
mi[i+1]=1;
ma[i+1]=t[i];
}
else{
mi[i+1]=t[i+1];
ma[i+1]=t[i+1];
}
}
ll ans=1;
ll p=1000000007;
rep(i,n-1){
int y=n-1-i;
ll mii,maa;
if(a[y]==a[y-1]){
mii=1;
maa=a[y];
}
else{
mii=a[y-1];
maa=a[y-1];
}
if(mii>ma[y-1]||mi[y-1]>maa){
cout << 0 << endl;
return 0;
}
else{
ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
//cout << y-1 << " " << ans << endl;
}
}
cout << ans << endl;
/*ll m=8848;
ll z=3776;
cout << m*m*m%p*z%p << endl;*/
}
|
a.cc: In function 'int main()':
a.cc:54:19: error: no matching function for call to 'max(int, long long int)'
54 | ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:54:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
54 | ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:54:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
54 | ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s513579351
|
p03959
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; } //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
int n;
cin >> n;
ll t[n];
ll a[n];
rep(i,n)cin >> t[i];
rep(i,n)cin >> a[i];
ll mi[n];
ll ma[n];
mi[0]=t[0];
ma[0]=t[0];
rep(i,n-1){
if(t[i]==t[i+1]){
mi[i+1]=1;
ma[i+1]=t[i];
}
else{
mi[i+1]=t[i+1];
ma[i+1]=t[i+1];
}
}
ll ans=1;
ll p=1000000007;
rep(i,n-1){
int y=n-1-i;
ll mii,maa;
if(a[y]==a[y-1]){
mii=1;
maa=a[y];
}
else{
mii=a[y-1];
maa=a[y-1];
}
if(mii>ma[y-1]||mi[y-1]>maa){
cout << 0 << endl;
return 0;
}
else{
ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
//cout << y-1 << " " << ans << endl;
}
}
cout << ans << endl;
/*ll m=8848;
ll z=3776;
cout << m*m*m%p*z%p << endl;*/
}
|
a.cc: In function 'int main()':
a.cc:50:19: error: no matching function for call to 'max(int, long long int)'
50 | ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:50:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
50 | ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:50:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
50 | ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s386776850
|
p03959
|
C++
|
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }
const int mod = 1000000007;
struct mint {
ll x; // using long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
ll INF = 1001001001;
ll LINF = 1001001001001001001ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin>>n;
vl ts(n), as(n);
cin>>ts>>as;
reverse(rng(as));
vl hs(n);
vl us(n);
rep(i, n) {
if (i == 0 || ts[i] > ts[i - 1]) {
hs[i] = ts[i];
}
else {
us[i] = ts[i];
}
}
rep(i, n) {
if (i == 0 || as[i] > as[i - 1]) {
if ((hs[n - i - 1] != 0 && as[i] != hs[n - i - 1]) || (us[n - i - 1] != 0 && as[i] > us[n - i - 1]) {
cout<<0<<endl;
return 0;
}
hs[n - i - 1] = as[i];
}
else {
if (us[n - i - 1] != 0) chmin(us[n - i - 1], as[i]);
else us[n - i - 1] = as[i];
}
}
mint ans = 1;
rep(i, n) {
if (us[i] == 0 || hs[i] != 0) continue;
ans *= us[i];
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:86:112: error: expected ';' before '{' token
86 | if ((hs[n - i - 1] != 0 && as[i] != hs[n - i - 1]) || (us[n - i - 1] != 0 && as[i] > us[n - i - 1]) {
| ^~
| ;
a.cc:90:34: error: expected ')' before ';' token
90 | hs[n - i - 1] = as[i];
| ^
| )
a.cc:86:16: note: to match this '('
86 | if ((hs[n - i - 1] != 0 && as[i] != hs[n - i - 1]) || (us[n - i - 1] != 0 && as[i] > us[n - i - 1]) {
| ^
|
s863289091
|
p03959
|
C++
|
n = int(input())
t = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = [0 for i in range(n)]
ans[0] = t[0]
ans[-1] = a[-1]
if n==1 and a[0]!=t[0]:
print(0)
exit()
for i in range(n-1):
if t[i]<t[i+1]:
ans[i+1] = t[i+1]
for i in range(1,n)[::-1]:
if a[i]<a[i-1]:
if ans[i-1]!=0 and ans[i-1]!=a[i-1]:
print(0)
exit()
ans[i-1] = a[i-1]
res = 1
mod = 10**9+7
for i in range(n):
if ans[i]!=0 and min(t[i],a[i])>ans[i]:
res = 0
fact = min(t[i],a[i])-ans[i]
if ans[i]!=0:
continue
res*=fact
res%=mod
print(res)
|
a.cc:1:1: error: 'n' does not name a type
1 | n = int(input())
| ^
|
s023753632
|
p03959
|
C++
|
#pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto& x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
//------ Believe yourself as a genius!!!!!! ------
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;
ll kaku[ohara];
int main(void) {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
cin >> n;
rep(i, n) cin >> a[i];
rep(i, n) cin >> b[i];
kaku[0] = a[0];
rep(i, n - 1) {
if (a[i] != a[i + 1]) {
kaku[i + 1] = a[i + 1];
}
}
kaku[n - 1] = b[n - 1];
rrep(i, n - 1, 1) {
if (b[i] != b[i - 1]) {
kaku[i - 1] = b[i - 1];
}
}
rep(i, n) {
// cout << kaku[i] << " ";
if (kaku[i] <= a[i] && kaku[i] <= b[i]) continue;
Cout(0);
return 0;
}
ans = 1;
rep(i, 0, n) {
if (kaku[i] != 0) continue;
tmp = min(a[i], b[i]);
ans *= tmp;
ans %= MOD;
}
Cout(ans);
return 0;
}
|
a.cc:92:14: error: macro "rep" passed 3 arguments, but takes just 2
92 | rep(i, 0, n) {
| ^
a.cc:16:9: note: macro "rep" defined here
16 | #define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
| ^~~
a.cc: In function 'int main()':
a.cc:92:3: error: 'rep' was not declared in this scope
92 | rep(i, 0, n) {
| ^~~
|
s624184402
|
p03959
|
C++
|
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;
int main(void) {
ll n;
cin>>n;
vll t(n);
vll a(n);
rep(i,n)cin>>t[i];
rep(i,n)cin>>a[i];
vll mt(n),ma(n);
ll ans=1;
if(t[n-1]!=a[0]){
fin(0);
return 0;
}
mt[0]=1;
ll maxt=t[0];
for(int i=1;i<n;i++){
if(t[i]>maxt){
maxt=t[i];
mt[i]=1;
} else {
mt[i]=maxt;
}
}
ma[n-1]=1;
ll maxa=a[n-1];
for(int i=n-2;i>=0;i--){
if(a[i]>maxa){
maxa=a[i];
ma[i]=1;
} else {
ma[i]=maxa;
}
}
for(int i=0;i<n;i++){
ans=ans*min(mt[i],ma[i])%MOD;
}
for(int i=0;i<n;i++){
if(ma[i]==1&&mt[i]==1&&m[i]!=t[i]){
cout<<0<<endl;
return 0;
}
}
fin(ans);
}
|
a.cc: In function 'int main()':
a.cc:93:32: error: 'm' was not declared in this scope
93 | if(ma[i]==1&&mt[i]==1&&m[i]!=t[i]){
| ^
|
s995029426
|
p03959
|
C++
|
0#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(a) (a).begin(),(a).end()
#define ALLR(a) (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template< int mod >
struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if((x += p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if((x += mod - p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int) (1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while(b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while(n > 0) {
if(n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
friend ostream &operator<<(ostream &os, const ModInt &p) {
return os << p.x;
}
friend istream &operator>>(istream &is, ModInt &a) {
int64_t t;
is >> t;
a = ModInt< mod >(t);
return (is);
}
static int get_mod() { return mod; }
};
using modint = ModInt< MOD >;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
//cout<<fixed<<setprecision(10);
ll res=0,buf=0;
bool judge = true;
ll n;cin>>n;
vector<ll>t(n+1),a(n+1);
rep(i,0,n)cin>>t[i+1];
rep(i,0,n)cin>>a[i];
modint ret=1;
rep(i,0,n){
if(t[i]>t[i+1])judge=false;
if(a[i]<a[i+1])judge=false;
buf=-1;
if(t[i]!=t[i+1])buf=t[i+1];
if(a[i]!=a[i+1]){
if(buf!=-1&&buf!=a[i])judge=false;
buf=a[i];
}
if(buf>t[i+1])judge=false;
if(buf>a[i])judge=false;
if(buf==-1)ret*=min(a[i],t[i+1]);
}
//cout<<t[n-1] spa a[1]<<endl;
if(t[n-1]!=a[1])judge=false;
if(!judge)cout<<0<<endl;
else cout<<ret<<endl;
return 0;
}
|
a.cc:1:2: error: stray '#' in program
1 | 0#include<bits/stdc++.h>
| ^
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 0#include<bits/stdc++.h>
| ^
a.cc:21:11: error: 'pair' does not name a type
21 | using P = pair<ll, ll>;
| ^~~~
a.cc: In function 'll median(ll, ll, ll)':
a.cc:30:41: error: 'max' was not declared in this scope
30 | ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
| ^~~
a.cc:30:54: error: 'min' was not declared in this scope
30 | ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
| ^~~
a.cc: In function 'void ans1(bool)':
a.cc:31:25: error: 'cout' was not declared in this scope
31 | void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
| ^~~~
a.cc:31:48: error: 'cout' was not declared in this scope
31 | void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
| ^~~~
a.cc: In function 'void ans2(bool)':
a.cc:32:25: error: 'cout' was not declared in this scope
32 | void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
| ^~~~
a.cc:32:48: error: 'cout' was not declared in this scope
32 | void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
| ^~~~
a.cc: In function 'void ans3(bool)':
a.cc:33:25: error: 'cout' was not declared in this scope
33 | void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
| ^~~~
a.cc:33:49: error: 'cout' was not declared in this scope
33 | void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
| ^~~~
a.cc: In function 'void ans(bool, T1, T2)':
a.cc:35:33: error: 'cout' was not declared in this scope
35 | void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
| ^~~~
a.cc:35:52: error: 'cout' was not declared in this scope
35 | void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
| ^~~~
a.cc: At global scope:
a.cc:37:6: error: variable or field 'debug' declared void
37 | void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^~~~~
a.cc:37:12: error: 'vector' was not declared in this scope
37 | void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^~~~~~
a.cc:37:19: error: 'vector' was not declared in this scope
37 | void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^~~~~~
a.cc:37:27: error: expected primary-expression before '>>' token
37 | void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^~
a.cc:37:30: error: 'v' was not declared in this scope
37 | void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^
a.cc:37:35: error: expected primary-expression before 'h'
37 | void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^
a.cc:37:40: error: expected primary-expression before 'w'
37 | void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^
a.cc:39:6: error: variable or field 'debug' declared void
39 | void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^~~~~
a.cc:39:12: error: 'vector' was not declared in this scope
39 | void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^~~~~~
a.cc:39:19: error: 'string' was not declared in this scope
39 | void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^~~~~~
a.cc:39:27: error: 'v' was not declared in this scope
39 | void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^
a.cc:39:32: error: expected primary-expression before 'h'
39 | void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^
a.cc:39:37: error: expected primary-expression before 'w'
39 | void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
| ^
a.cc:42:6: error: variable or field 'debug' declared void
42 | void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
| ^~~~~
a.cc:42:12: error: 'vector' was not declared in this scope
42 | void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
| ^~~~~~
a.cc:42:20: error: expected primary-expression before '>' token
42 | void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
| ^
a.cc:42:22: error: 'v' was not declared in this scope
42 | void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
| ^
a.cc:42:27: error: expected primary-expression before 'n'
42 | void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
| ^
a.cc:45:1: error: 'vector' does not name a type
45 | vector<vector<T>>vec(ll x, ll y, T w){
| ^~~~~~
a.cc:48:1: error: 'vector' does not name a type
48 | vector<ll>dx={1,0,-1,0,1,1,-1,-1};
| ^~~~~~
a.cc:49:1: error: 'vector' does not name a type
49 | vector<ll>dy={0,1,0,-1,1,-1,1,-1};
| ^~~~~~
a.cc:51:1: error: 'vector' does not name a type
51 | vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
| ^~~~~~
a.cc:53:13: error: 'size_t' was not declared in this scope
53 | auto make_v(size_t a,Ts... ts){
| ^~~~~~
a.cc:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | 0#include<bits/stdc++.h>
a.cc:53:24: error: expected primary-expression before '...' token
53 | auto make_v(size_t a,Ts... ts){
| ^~~
a.cc:53:30: error: expression list treated as compound expression in initializer [-fpermissive]
53 | auto make_v(size_t a,Ts... ts){
| ^
a.cc:53:31: error: expected ';' before '{' token
53 | auto make_v(size_t a,Ts... ts){
| ^
| ;
a.cc:62:17: error: expected ')' before 'y'
62 | ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
| ~ ^~
| )
a.cc:108:14: error: 'int64_t' has not been declared
108 | ModInt pow(int64_t n) const {
| ^~~~~~~
a.cc:118:10: error: 'ostream' does not name a type
118 | friend ostream &operator<<(ostream &os, const ModInt &p) {
| ^~~~~~~
a.cc:122:10: error: 'istream' does not name a type
122 | friend istream &operator>>(istream &is, ModInt &a) {
| ^~~~~~~
a.cc: In member function 'ModInt<mod> ModInt<mod>::inverse() const':
a.cc:102:7: error: there are no arguments to 'swap' that depend on a template parameter, so a declaration of 'swap' must be available [-fpermissive]
102 | swap(a -= t * b, b);
| ^~~~
a.cc:102:7: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc:103:7: error: there are no arguments to 'swap' that depend on a template parameter, so a declaration of 'swap' must be available [-fpermissive]
103 | swap(u -= t * v, v);
| ^~~~
a.cc: In function 'int main()':
a.cc:133:3: error: 'cin' was not declared in this scope
133 | cin.tie(nullptr);
| ^~~
a.cc:134:3: error: 'ios_base' has not been declared
134 | ios_base::sync_with_stdio(false);
| ^~~~~~~~
a.cc:139:3: error: 'vector' was not declared in this scope
139 | vector<ll>t(n+1),a(n+1);
| ^~~~~~
a.cc:139:12: error: expected primary-expression before '>' token
139 | vector<ll>t(n+1),a(n+1);
| ^
a.cc:139:13: error: 't' was not declared in this scope
139 | vector<ll>t(n+1),a(n+1);
| ^
a.cc:139:20: error: 'a' was not declared in this scope
139 | vector<ll>t(n+1),a(n+1);
| ^
a.cc:142:14: error: conversion from 'int' to non-scalar type 'modint' {aka 'ModInt<1000000007>'} requested
142 | modint ret=1;
| ^
a.cc:154:21: error: 'min' was not declared in this scope; did you mean 'main'?
154 | if(buf==-1)ret*=min(a[i],t[i+1]);
| ^~~
| main
a.cc:159:13: error: 'cout' was not declared in this scope
159 | if(!judge)cout<<0<<endl;
| ^~~~
a.cc:160:8: error: 'cout' was not declared in this scope
160 | else cout<<ret<<endl;
| ^~~~
|
s207048245
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 2000000000
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
#define double float
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
if(a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, T b) {
if(a > b) {
a = b;
return 1;
}
return 0;
}
struct edge {
int to, cost;
};
int main() {
int n;
cin >> n;
vi t(n + 2, 0), a(n + 2, 0);
rep(i, n) cin >> t[i + 1];
rep(i, n) cin >> a[i + 1];
ll ans = 1;
rep(i, n) {
if(t[i] == t[i + 1] && a[i + 2] == a[i + 1]) {
ans *= min(t[i + 1], a[i + 1]);
} else {
if(a[i + 2] == a[i + 1] && t[i + 1] > a[i + 1]) {
ans = 0;
} else if(t[i] == t[i + 1] && a[i + 1] > t[i + 1]) {
ans = 0;
} else if(a[i + 2] != a[i + 1] && t[i] != t[i + 1] && a[i + 1] != t[i + 1])
}
ans %= MOD;
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:55:9: error: expected primary-expression before '}' token
55 | }
| ^
|
s143462580
|
p03959
|
C++
|
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x) cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long
void solve() {
ll ans = 1LL;
int n; cin >> n;
vector<ll> t(n), a(n);
rep(i, n) {
cin >> t[i];
}
rep(i, n) {
cin >> a[i];
}
rep(i, n) {
int h1 = 0, h2 = 0;
if(i == 0 || (i - 1 >= 0 && t[i - 1] < t[i])) {
h1 = t[i];
}
if(i === n - 1 || (i + 1 <= n - 1 && a[i] > a[i + 1])) {
h2 = a[i];
}
if(h1 && h2 && h1 != h2) {
cout << 0 << endl;
return;
} else if(h1) {
continue;
} else if(h2) {
continue;
} else {
ans *= min(a[i], t[i]);
ans %= mod;
}
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
//cout << fixed << setprecision(10);
//init();
solve();
//cout << "finish" << endl;
return 0;
}
|
a.cc: In function 'void solve()':
a.cc:68:16: error: expected primary-expression before '=' token
68 | if(i === n - 1 || (i + 1 <= n - 1 && a[i] > a[i + 1])) {
| ^
|
s579404957
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
int n,t[100000],a[100000],memo[100000],limit[100000],ans=1;
signed main() {
cin >> n;
rep(i,n) memo[i] = -1, limit[i] = INF;
rep(i,n) cin >> t[i], limit[i] = min(limit[i], t[i]);
rep(i,n) cin >> a[i], limit[i] = min(limit[i], a[i]);
memo[0] = t[0];
memo[n-1] = a[n-1];
rep11(i,n) if (t[i] != t[i-1]) memo[i] = t[i];
repm(i,n-1) if (a[i+1] != a[i]) memo[i] = a[i];
rep(i,n) if (memo[i] == -1) ans = (ans*limit[i])%MOD;
rep(i,n) if (memo[i] != -1 && memo[i] != min(a[i], t[i])) {
cout << 0 << endl;
return 0;
}
if (a[0] != t[n-1]) cout << 0 < <endl;;
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:37:37: error: expected primary-expression before '<' token
37 | if (a[0] != t[n-1]) cout << 0 < <endl;;
| ^
|
s602817089
|
p03959
|
C++
|
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_2 100000
#define d9_7 1000000007
int main(void){
ll n;
cin >> n;
vector<ll> t(n);
vector<ll> a(n);
rep(i,n){
cin>>t[i];
}
rep(i,n){
cin>>a[i];
}
ll ans=0;
if(n==1&&a[0]!=t[n-1]){
cout<<0<<endl;
return 0;
}
if(n==2){
if(a[0]==a[1] || t[0]==t[1]){
cout<<1<<endl;
}else{
cout<<0<<endl;
}
return 0;
}
if(a[0]!=t[n-1]){
cout<<0<<endl;
return 0;
}
rep(i,n){
if(i==0){
ans=1;
continue;
}else if(i==n-1){
continue;
}
ll aa=(ll)min(a[i],t[i]);
if(t[i-1]<t[i]||a[i+1]<a[i]){
aa=1;
}
if(i>n/2+1){
if(t[i-1]<t[i]){
if(a[n-1-i]<t[i]){
cout<<"0"<<endl;
return 0;
}
}
}else if(i<n/2){
if(a[i+1]<a[i]){
if(t[n-1-i]<a[i]){
cout<<"0"<<endl;
return 0;
}
}
}
if(t[i-1]<t[i]){
if(t[i]>a[i]){
cout<<"0"<<endl;
return 0;
}
}
if(s[i+1]<s[i]){
if(t[i]<a[i]){
cout<<"0"<<endl;
return 0;
}
}
ans=(aa*ans)%d9_7;
}
cout<<ans%d9_7<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:82:8: error: 's' was not declared in this scope
82 | if(s[i+1]<s[i]){
| ^
|
s451458042
|
p03959
|
C++
|
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_2 100000
#define d9_7 1000000007
int main(void){
ll n;
cin >> n;
vector<ll> t(n);
vector<ll> a(n);
vector<rec> r(n);
rep(i,n){
cin>>t[i];
}
rep(i,n){
cin>>a[i];
}
ll ans=0;
if(n==1){
cout<<1<<endl;
return 0;
}
if(a[0]!=t[n-1]){
cout<<0<<endl;
return 0;
}
rep(i,n){
if(i==0){
ans=1;
continue;
}else if(i==n-1){
continue;
}
ll aa=(ll)min(a[i],t[i]);
if(t[i-1]<t[i]||a[i+1]<a[i]){
aa=1;
}
ans=(aa*ans)%d9_7;
}
cout<<ans%d9_7<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:27:10: error: 'rec' was not declared in this scope; did you mean 'rep'?
27 | vector<rec> r(n);
| ^~~
| rep
a.cc:27:13: error: template argument 1 is invalid
27 | vector<rec> r(n);
| ^
a.cc:27:13: error: template argument 2 is invalid
|
s936083234
|
p03959
|
C
|
#define MAX 100010
#define MOD 1000000007
#define min(a,b) ((a)<(b)?a:b)
#define max(a,b) ((a)>(b)?a:b)
#define MAX 100010
int h[2][MAX];
int a[2][MAX];
int main(){
int i,j,n;
scanf("%d",&n);
for(j=0;j<2;j++){
for(i=0;i<n;i++){
scanf("%d",&(a[j][i]));
}
}
long int s=1;
int m=0;
for(i=0;i<n;i++){
if(m<a[0][i]){
m=a[0][i];
h[0][i]=m;
h[1][i]=m;
}else{
h[0][i]=1;
h[1][i]=m;
}
if(df) printf("%d ",m);
}
if(df) printf("h
|
main.c: In function 'main':
main.c:16:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
16 | scanf("%d",&n);
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 |
main.c:16:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
16 | scanf("%d",&n);
| ^~~~~
main.c:16:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:34:8: error: 'df' undeclared (first use in this function)
34 | if(df) printf("%d ",m);
| ^~
main.c:34:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:34:12: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
34 | if(df) printf("%d ",m);
| ^~~~~~
main.c:34:12: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:34:12: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:34:12: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:36:12: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
36 | if(df) printf("h
| ^~~~~~
main.c:36:12: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:36:19: warning: missing terminating " character
36 | if(df) printf("h
| ^
main.c:36:19: error: missing terminating " character
36 | if(df) printf("h
| ^~
main.c:36:5: error: expected expression at end of input
36 | if(df) printf("h
| ^~
main.c:36:5: error: expected declaration or statement at end of input
|
s670368564
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
long long tot = 1;
for(;exp > 0;exp >>= 1) {
if((exp & 1) == 1) tot = tot * base % mod;
base = base * base % mod;
}
return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
long long tot = 0;
for(;exp > 0;exp >>= 1) {
if((exp & 1) == 1) tot = (tot + base) % mod;
base = (base + base) % mod;
}
return tot;
}
unsigned long long pre[100005], suf[100005], conf[100005];
int main(){
cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n; cin >> n;
for(int i = 0; i < n; ++i)
cin >> pre[i];
for(int i = 0; i < n; ++i)
cin >> suf[i];
unsigned long long prod = 1;
for(int i = 0; i < n; ++i){
conf[i] = -1;
if(i == 0 || pre[i] != pre[i - 1])
conf[i] = pre[i];
}
for(int i = n - 1; i >= 0; --i){
if(i == n - 1 || suf[i] != suf[i + 1]){
if(conf[i] != -1 && conf[i] != suf[i]){
cout << "0\n";
return 0;
}
conf[i] = suf[i];
}
}
if(pref[n - 1] != suf[0]){
cout << "0\n";
return 0;
}
for(int i = 0; i < n; ++i){
if(conf[i] != -1) continue;
prod = slow_mult(prod, min(pre[i], suf[i]));
}
cout << prod << "\n";
return 0;
}
|
a.cc: In function 'int main()':
a.cc:58:8: error: 'pref' was not declared in this scope; did you mean 'pre'?
58 | if(pref[n - 1] != suf[0]){
| ^~~~
| pre
|
s185577264
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long MOD=1000000007LL;
int main(){
int N;
long long ans=1;
cin >> N;
vector<int> T(N);
vector<int> A(N);
for(auto &i:T)cin >> i;
for(auto &i:A)cin >> i;
vector<bool> t(N,false);
vector<bool> a(N,false);
for(int i=0;i<N;i++){
if(i==0)t[i]=true;
else if(T[i-1]<T[i])t[i]=true;
}
for(int i=N-1;i>=0;i--){
if(i==N-1)a[i]=true;
else if(A[i+1]<A[i])a[i]=true;
}
for(int i=0;i<N;i++){
if(t[i] && a[i]){
if(T[i]!=A[i])ans*=0;
}
else if(t[i]){
if(T[i]>A[i])ans*=0;
}
else if(a[i]){
if(T[i]<A[i])ans*=0;
}
else(!t[i] && !a[i]){
ans*=1LL*min(T[i],A[i]);
}
if(ans>=MOD)ans%=MOD;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:37:37: error: expected ';' before '{' token
37 | else(!t[i] && !a[i]){
| ^
| ;
|
s053224683
|
p03959
|
C++
|
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
const int MOD = 1000000007;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
vector<ll> T(N), A(N);
Rep (i, N) {
cin >> T[i];
}
Rep (i, N) {
cin >> A[i];
}
vector<ll> ttmp(N), atmp(N), mt(N);
vector<bool> t(N, false), a(N, false), m(N, false);
ll tmp = 0, ans = 1;
Rep (i, N) {
if (T[i] > tmp) {
ttmp[i] = T[i];
t[i] = true;
tmp = T[i];
} else if (T[i] == tmp) {
ttmp[i] = T[i];
}
}
tmp = 0;
for (ll i = N - 1; i >= 0; i--) {
if (A[i] > tmp) {
atmp[i] = A[i];
a[i] = true;
tmp = A[i];
} else if (A[i] == tmp) {
atmp[i] = A[i];
}
}
Rep (i, N) {
if (!t[i] && !a[i]) mt[i] = min(ttmp[i], atmp[i]);
else if (t[i] && a[i]) {
if (ttmp[i] == atmp[i]) {
mt[i] = 1;
}
else mt[i] = 0;
}
else if (t[i] && !a[i]) {
if (ttmp[i] <= atmp[i]) {
mt[i] = 1;
} else mt[i] = 0;
} else if (!t[i] && a[i]) {
if (atmp[i] <= ttmp[i]) mt[i] = 1;
else mt[i] = 0;
}
}
Rep (i, N) {
ans *= mt[i];
ans %= MOD;
}
cout << ans << "\n";
}#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
const int MOD = 1000000007;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
vector<ll> T(N), A(N);
Rep (i, N) {
cin >> T[i];
}
Rep (i, N) {
cin >> A[i];
}
vector<ll> ttmp(N), atmp(N), mt(N);
vector<bool> t(N, false), a(N, false), m(N, false);
ll tmp = 0, ans = 1;
Rep (i, N) {
if (T[i] > tmp) {
ttmp[i] = T[i];
t[i] = true;
tmp = T[i];
} else if (T[i] == tmp) {
ttmp[i] = T[i];
}
}
tmp = 0;
for (ll i = N - 1; i >= 0; i--) {
if (A[i] > tmp) {
atmp[i] = A[i];
a[i] = true;
tmp = A[i];
} else if (A[i] == tmp) {
atmp[i] = A[i];
}
}
Rep (i, N) {
if (!t[i] && !a[i]) mt[i] = min(ttmp[i], atmp[i]);
else if (t[i] && a[i]) {
if (ttmp[i] == atmp[i]) {
mt[i] = 1;
}
else mt[i] = 0;
}
else if (t[i] && !a[i]) {
if (ttmp[i] <= atmp[i]) {
mt[i] = 1;
} else mt[i] = 0;
} else if (!t[i] && a[i]) {
if (atmp[i] <= ttmp[i]) mt[i] = 1;
else mt[i] = 0;
}
}
Rep (i, N) {
ans *= mt[i];
ans %= MOD;
}
cout << ans << "\n";
}
|
a.cc:82:2: error: stray '#' in program
82 | }#include<iostream>
| ^
a.cc:82:3: error: 'include' does not name a type
82 | }#include<iostream>
| ^~~~~~~
a.cc:99:11: error: redefinition of 'const int MOD'
99 | const int MOD = 1000000007;
| ^~~
a.cc:18:11: note: 'const int MOD' previously defined here
18 | const int MOD = 1000000007;
| ^~~
a.cc:101:5: error: redefinition of 'int main()'
101 | int main(){
| ^~~~
a.cc:20:5: note: 'int main()' previously defined here
20 | int main(){
| ^~~~
|
s780475235
|
p03959
|
C++
|
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll T[100010],A[100010];
int main(){
bool f=true;
cin>>N;
rep(i,N) cin>>T[i];
rep(i,N) cin>>A[i];
ll h[100010];
ll res=1;
fill(h,0);
if(N==1&&T[0]!=A[0]) f=false;
h[0]=T[0];
h[N-1]=A[N-1];
rep(i,N-1){
if(T[i]<T[i+1]){
if(A[i+1]!=0&&h[i+1]!=T[i+1]){
f=false;
break;
}
else h[i+1]=T[i+1];
}
rep(i,N-1){
if(A[i]>A[i+1]){
if(h[i]!=0&&h[i]!=A[i]){
f=false;
break;
}
else h[i]=A[i];
}
}
rep(i,N){
if(h[i]==0){
ll min=std::min(A[i],T[i]);
res=(res*min)%MOD;
}
}
if(f) prin(res);
else prin(0);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:67:2: error: expected '}' at end of input
67 | }
| ^
a.cc:30:11: note: to match this '{'
30 | int main(){
| ^
|
s828372273
|
p03959
|
C++
|
#include "pch.h"
//
/*
ll used[10];
ll maxi;
ll dfs(Graph& graph, ll v, ll deep) {
used[v] = 1;
vector<ll> maxd;
maxd.push_back(deep);
for (int i = 0; i < graph[v].size(); i++) {
if (used[graph[v][i].to] == 0) {
maxd.push_back(dfs(graph, graph[v][i].to, deep + 1));
}
}
sort(all(maxd), greater<ll>());
if (maxd.size() > 2) {
chmax(maxi, maxd[0] - deep + maxd[1] - deep);
}
else {
chmax(maxi, maxd[0] - deep);
}
return maxd[0];
}
*///dfs
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//sortは初期で昇順 greater<hoge>()で降順
//substr 文字列取り出し
//upper_bound ある値より大きい一番左のイテレータを返す、lowerは以上(setに対して使うとO(N)なので、setのメンバ関数を使う
//stoi
struct Edge {//グラフ
ll to, cap, rev;
Edge(ll _to, ll _cap, ll _rev) {
to = _to; cap = _cap; rev = _rev;
}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {//最大フロー求める Ford-fulkerson
G[from].push_back(Edge(to, cap, (ll)G[to].size()));
if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));//最小カットの場合逆辺は0にする
}
ll max_flow_dfs(Graph & G, ll v, ll t, ll f, vector<bool> & used)
{
if (v == t)
return f;
used[v] = true;
for (int i = 0; i < G[v].size(); ++i) {
Edge& e = G[v][i];
if (!used[e.to] && e.cap > 0) {
ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used);
if (d > 0) {
e.cap -= d;
G[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
}
ll max_flow(Graph & G, ll s, ll t)
{
ll flow = 0;
for (;;) {
vector<bool> used(G.size());
REP(i, used.size())used[i] = false;
ll f = max_flow_dfs(G, s, t, INF, used);
if (f == 0) {
return flow;
}
flow += f;
}
}
void BellmanFord(Graph& G, ll s, Array& d, Array &negative) {//O(|E||V|)
d.resize(G.size());
negative.resize(G.size());
REP(i, d.size())d[i] = INF;
REP(i, d.size())negative[i] = false;
d[s] = 0;
REP(k, G.size() - 2) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
}
}
}
}
REP(k, G.size() - 2) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
negative[G[i][j].to] = true;
}
if (negative[i] == true)negative[G[i][j].to] = true;
}
}
}
}
void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
d.resize(G.size());
REP(i, d.size())d[i] = INF;
d[s] = 0;
priority_queue<P, vector<P>, greater<P>> q;
q.push(make_pair(0, s));
while (!q.empty()) {
P a = q.top();
q.pop();
if (d[a.second] < a.first)continue;
REP(i, G[a.second].size()) {
Edge e = G[a.second][i];
if (d[e.to] > d[a.second] + e.cap) {
d[e.to] = d[a.second] + e.cap;
q.push(make_pair(d[e.to], e.to));
}
}
}
}
void WarshallFloyd(Graph& G, Matrix& d) {
d.resize(G.size());
REP(i, d.size())d[i].resize(G.size());
REP(i, d.size()) {
REP(j, d[i].size()) {
d[i][j] = INF;
}
}
REP(i, G.size()) {
d[i][i] = 0;
}
REP(i, G.size()) {
REP(j, G[i].size()) {
d[i][G[i][j].to] = G[i][j].cap;
}
}
REP(i, G.size()) {
REP(j, G.size()) {
REP(k, G.size()) {
chmin(d[j][k], d[j][i] + d[i][k]);
}
}
}
}
class UnionFind {
vector<int> data;
public:
UnionFind(int size) : data(size, -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)];
}
};
//約数求める //約数
void divisor(ll n, vector<ll>& ret) {
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end());
}
//nCrとか
class Combination {
public:
Array fact;
Array inv;
ll mod;
ll mod_inv(ll x) {
ll n = mod - 2;
ll res = 1LL;
while (n > 0) {
if (n & 1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
ll nCr(ll n, ll r) {
return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
}
ll nPr(ll n, ll r) {
return (fact[n] * inv[n - r]) % mod;
}
Combination(ll n, ll _mod) {
mod = _mod;
fact.resize(n + 1);
fact[0] = 1;
REP(i, n) {
fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
}
inv.resize(n + 1);
REP(i, n + 1) {
inv[i] = mod_inv(fact[i]);
}
}
};
bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
if (a.second != b.second) {
return a.second > b.second;
}
else {
return a.first > b.first;
}
}
bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
if (a.first != b.first) {
return a.first > b.first;
}
else {
return a.second > b.second;
}
}
ll gcd(ll m, ll n) {
if (n == 0)return m;
return gcd(n, m % n);
}//gcd
ll lcm(ll m, ll n) {
return m / gcd(m, n) * n;
}
ll h[100010];
ll h2[100010];
int main() {
ll n;
cin >> n;
REP(i, n) {
ll t;
cin >> t;
if (abs(h[i]) < t) {
h[i + 1] = t;
}
else {
h[i + 1] = -t;
}
}
Array t(n);
REP(i, n)cin >> t[i];
sort(all(t));
REP(i, n) {
if (abs(h2[i]) < t[i]) {
h2[i + 1] = t[i];
}
else {
h2[i + 1] = -t[i];
}
}
ll ans = 1;
REP(i, n) {
if (h[i + 1] < 0 && h2[n - i] < 0) {
(ans *= min(abs(h[i + 1]), abs(h2[n - i]))) %= MOD;
}
else if (h[i + 1] > 0 && h2[n - i] > 0) {
if (h[i + 1] != h2[n - i]) ans *= 0;
}
else {
ll con = max(h[i + 1], h2[n - i]);
ll exi = min(h[i + 1], h2[n - i]);
if (con > abs(exi))ans *= 0;
}
}
cout << ans;
return 0;
}
|
a.cc:1:10: fatal error: pch.h: No such file or directory
1 | #include "pch.h"
| ^~~~~~~
compilation terminated.
|
s415776716
|
p03959
|
Java
|
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long mod = 1000000007;
long ans1=1;
long[] t1=new long[n];
long[] a1=new long[n];
long[] ans=new long[n];
for(int i = 0; i<n; i++){
t1[i] = sc.nextLong();
if(i==0){
ans[i]=t1[i];
}else if(t1[i]!=t1[i-1]){
ans[i]=t1[i];
}
}
for(int i = 0; i<n; i++){
a1[i] = sc.nextLong();
if(ans[i]!=0){
if(ti[i]>a1[i]){
System.out.println(0);
return;
}
}
if(i==n-1){
if(ans[i]!=0 && ans[i]!=a1[i]){
System.out.println(0);
return;
}
ans[i]=a1[i];
}
if(i!=0 && a1[i]!=a1[i-1]){
if(ans[i-1]!=0 && ans[i-1]!=a1[i-1]){
System.out.println(0);
return;
}
ans[i-1]=a1[i-1];
if(t1[i-1]<a1[i-1]){
System.out.println(0);
return;
}
}
}
for(int i = 0; i<n; i++){
if(ans[i]==0){
ans1*=Math.min(t1[i],a1[i]);
ans1%=mod;
}
}
System.out.println(ans1);
}
}
|
Main.java:22: error: cannot find symbol
if(ti[i]>a1[i]){
^
symbol: variable ti
location: class Main
1 error
|
s202184426
|
p03959
|
C++
|
/*------------------------------------------------------------------*/
/*------------------------- begin template -------------------------*/
/*------------------------------------------------------------------*/
// ref: tanakh <https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8>
// diff: using Parser
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut parser = Parser::from_str($s);
input_inner!{parser, $($r)*}
};
(parser = $parser:ident, $($r:tt)*) => {
input_inner!{$parser, $($r)*}
};
(new_stdin_parser = $parser:ident, $($r:tt)*) => {
let stdin = std::io::stdin();
let reader = std::io::BufReader::new(stdin.lock());
let mut $parser = Parser::new(reader);
input_inner!{$parser, $($r)*}
};
($($r:tt)*) => {
input!{new_stdin_parser = parser, $($r)*}
};
}
macro_rules! input_inner {
($parser:ident) => {};
($parser:ident, ) => {};
($parser:ident, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($parser, $t);
input_inner!{$parser $($r)*}
};
}
macro_rules! read_value {
($parser:ident, ( $($t:tt),* )) => {
( $(read_value!($parser, $t)),* )
};
($parser:ident, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($parser, $t)).collect::<Vec<_>>()
};
($parser:ident, chars) => {
read_value!($parser, String).chars().collect::<Vec<char>>()
};
($parser:ident, char_) => {
read_value!($parser, String).chars().collect::<Vec<char>>()[0]
};
($parser:ident, usize1) => {
read_value!($parser, usize) - 1
};
($parser:ident, i64_) => {
$parser.fast_i64()
};
($parser:ident, usize_) => {
$parser.fast_i64() as usize
};
($parser:ident, usize1_) => {
($parser.fast_i64() - 1) as usize
};
($parser:ident, $t:ty) => {
$parser.next::<$t>().expect("Parse error")
};
}
use std::io;
use std::io::BufRead;
use std::str;
// ref: tatsuya6502 <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e>
// ref: wariuni <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e#comment-7040a5ae96305e884eb9>
// diff: using std::io::BufRead::fill_buf()
pub struct Parser<R> {
pub reader: R,
buf: Vec<u8>,
pos: usize,
}
impl Parser<io::Empty> {
pub fn from_str(s: &str) -> Parser<io::Empty> {
Parser {
reader: io::empty(),
buf: s.as_bytes().to_vec(),
pos: 0,
}
}
}
impl<R: BufRead> Parser<R> {
pub fn new(reader: R) -> Parser<R> {
Parser {
reader: reader,
buf: vec![],
pos: 0,
}
}
pub fn update_buf(&mut self) {
self.buf.clear();
self.pos = 0;
loop {
let (len, complete) = {
let buf2 = self.reader.fill_buf().unwrap();
self.buf.extend_from_slice(buf2);
let len = buf2.len();
(len, buf2[len - 1] <= 0x20)
};
self.reader.consume(len);
if complete {
break;
}
}
}
pub fn next<T: str::FromStr>(&mut self) -> Result<T, T::Err> {
loop {
let mut begin = self.pos;
while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
begin += 1;
}
let mut end = begin;
while end < self.buf.len() && (self.buf[end] > 0x20) {
end += 1;
}
if begin != self.buf.len() {
self.pos = end;
return unsafe { str::from_utf8_unchecked(&self.buf[begin..end]) }.parse::<T>();
} else {
self.update_buf();
}
}
}
pub fn fast_i64(&mut self) -> i64 {
loop {
let mut begin = self.pos;
while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
begin += 1;
}
if begin == self.buf.len() {
self.update_buf();
continue;
}
let mut res = 0;
let (is_positive, mut end) = match self.buf[begin] {
b'+' => (true, begin + 1),
b'-' => (false, begin + 1),
_ => (true, begin),
};
while end < self.buf.len() && (self.buf[end] > 0x20) {
res = res * 10 + (self.buf[end] as i64 - '0' as i64);
end += 1;
}
if begin != self.buf.len() {
self.pos = end;
return if is_positive { res } else { -res };
} else {
self.update_buf();
}
}
}
}
#[allow(unused_imports)]
use std::cmp::*;
fn main() {
input! {
new_stdin_parser = parser,
}
let res = solve(&mut parser);
print!("{}", res);
}
/*------------------------------------------------------------------*/
/*-------------------------- end template --------------------------*/
/*------------------------------------------------------------------*/
use std::fmt::Write;
fn solve<R: BufRead>(parser: &mut Parser<R>) -> String {
let mut buf = String::new();
input! {
parser = parser,
}
buf
}
|
a.cc:40:10: error: too many decimal points in number
40 | (0..$len).map(|_| read_value!($parser, $t)).collect::<Vec<_>>()
| ^~~~~~~
a.cc:160:2: error: invalid preprocessing directive #[
160 | #[allow(unused_imports)]
| ^
a.cc:7:1: error: 'macro_rules' does not name a type
7 | macro_rules! input {
| ^~~~~~~~~~~
a.cc:26:1: error: 'macro_rules' does not name a type
26 | macro_rules! input_inner {
| ^~~~~~~~~~~
a.cc:35:1: error: 'macro_rules' does not name a type
35 | macro_rules! read_value {
| ^~~~~~~~~~~
a.cc:65:1: error: 'use' does not name a type
65 | use std::io;
| ^~~
a.cc:66:1: error: 'use' does not name a type
66 | use std::io::BufRead;
| ^~~
a.cc:67:1: error: 'use' does not name a type
67 | use std::str;
| ^~~
a.cc:72:1: error: 'pub' does not name a type
72 | pub struct Parser<R> {
| ^~~
a.cc:78:1: error: 'impl' does not name a type
78 | impl Parser<io::Empty> {
| ^~~~
a.cc:88:1: error: 'impl' does not name a type
88 | impl<R: BufRead> Parser<R> {
| ^~~~
a.cc:161:1: error: 'use' does not name a type
161 | use std::cmp::*;
| ^~~
a.cc:163:1: error: 'fn' does not name a type
163 | fn main() {
| ^~
a.cc:175:1: error: 'use' does not name a type
175 | use std::fmt::Write;
| ^~~
a.cc:176:1: error: 'fn' does not name a type
176 | fn solve<R: BufRead>(parser: &mut Parser<R>) -> String {
| ^~
|
s420611245
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define ldouble long double
#define llong long long int
#define print(x) cout << x << endl
#define ternary(condition, x, y) ((condition) ? x : y)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};
int main (int argc, char *argv[]) {
cin.tie(0);
ios::sync_with_stdio(false);
llong n;
cin >> n;
vector<llong> a(n), t(n);
for (int i = 0; i < n; i++) cin >> t[i];
for (int i = 0; i < n; i++) cin >> a[i];
if (a[0] != t[n-1]){
cout << 0 << endl;
} else {
llong ans = 1;
for (int i = 1; i < n-1; i++) {
if (t[i] == t[i - 1] && a[i] == a[i + 1]){
ans *= min(t[i], [i]) % MOD;
} else if (t[i] > t[i - 1] && a[i] == a[i + 1] && a[i] < t[i]){
ans = 0;
} else if (t[i] == t[i - 1] && a[i] > a[i + 1] && a[i] > t[i]){
ans = 0;
} else if (t[i] > t[i - 1] && a[i] > a[i + 1] && a[i] != t[i]){
ans = 0;
}
}
cout << ans << endl;
}
return 0;
}
|
a.cc: In lambda function:
a.cc:33:53: error: expected '{' before ')' token
33 | ans *= min(t[i], [i]) % MOD;
| ^
a.cc: In function 'int main(int, char**)':
a.cc:33:43: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, main(int, char**)::<lambda()>)'
33 | ans *= min(t[i], [i]) % MOD;
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:33:43: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'main(int, char**)::<lambda()>')
33 | ans *= min(t[i], [i]) % MOD;
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:33:43: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
33 | ans *= min(t[i], [i]) % MOD;
| ~~~^~~~~~~~~~~
|
s031660512
|
p03959
|
C++
|
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = [[] for i in range(N)]
for i in range(N):
if i == 0:
h[i].append(T[i])
elif i == N - 1:
h[i].append(A[i])
else:
if T[i] > T[i - 1]:
h[i].append(T[i])
elif A[i] > A[i + 1]:
h[i].append(A[i])
else:
h[i] = [j for j in range(1, min([A[i], T[i]]) + 1)]
cnt = 1
for i in range(N):
cnt *= (len(h[i]) % 1000000007)
if max(A) != max(T):
cnt = 0
print(cnt % 1000000007)
|
a.cc:1:1: error: 'N' does not name a type
1 | N = int(input())
| ^
|
s819282149
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;
const int INF = (int) 2ae9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;
#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};
//------------------------------------------------------
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll mount[n]; //確定したときは山の高さ、不確定のときは(最大値)+INF を入れる
ll t[n], a[n];
rep(i, n) cin >> t[i];
rep(i, n) cin >> a[i];
ll before = -1, cnt = 0;
rep(i, n) {
if (before < t[i]) { //更新
mount[i] = t[i];
before = t[i];
} else {
mount[i] = t[i] + INF;
}
}
before = -1;
for (int i = n - 1; i >= 0; --i) {
if (before < a[i]) { //更新
if (mount[i] > INF) { //まだ未確定
ll m = mount[i] - INF;
if (a[i] <= m) mount[i] = a[i];
else goto finish;
} else {
if (a[i] != mount[i]) goto finish;
}
before = a[i];
} else {
if (mount[i] > INF) { //まだ未確定
ll m = mount[i] - INF;
mount[i] = min(m, a[i]) + INF;
} else {
if (mount[i] > a[i]) goto finish;
}
}
}
cnt = 1;
rep(i, n) {
if (mount[i] < INF) continue;
ll m = mount[i] - INF;
cnt = cnt * m % MOD;
}
finish:
cout << cnt << endl;
return 0;
}
|
a.cc:12:23: error: unable to find numeric literal operator 'operator""ae9'
12 | const int INF = (int) 2ae9;
| ^~~~
|
s554361967
|
p03959
|
C++
|
n=int(input())
s=input().split()
s.insert(0,"0")
s.append("0")
ss=input().split()
ss.insert(0,"0")
s.append("0")
res=1
for i in range(1,n):
if int(s[i-1])!=int(s[i]):
if int(ss[i+1])!=int(ss[i]) and s[i]!=ss[i]:
res*=0
if int(ss[i])<int(s[i]):
res*=0
continue
elif int(ss[i])!=int(ss[i+1]):
if int(s[i])<int(ss[i]):
res*=0
else:
res*=min(int(s[i]),int(ss[i]))
print(res%1000000007)
|
a.cc:1:1: error: 'n' does not name a type
1 | n=int(input())
| ^
|
s007666057
|
p03959
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;
#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)
vector<bool> gen_sosuu(vector<bool> sosuu){
int size = sosuu.size();
REP(i,size){
sosuu[i] = true;
}
sosuu[0] = false;
sosuu[1] = false;
sosuu[2] = true;
FOR(i,2,sqrt(size)+1){
if(sosuu[i] == false) continue;
for(int j = 2; i*j<size;j++){
sosuu[i*j] =false;
}
}
return sosuu;
}
int n;
ll a[100001];
ll b[100001];
ll c[100001];
ll mod = 1e9+7;
int main(){
cin >> n;
REP(i,n){
cin >> a[i];
}
REP(i,n){
cin >> b[i];
}
REP(i,n){
c[i] = min(a[i],b[i]);
}
for(int l = 0;l<n;l++){
int r = l;
while(c[l]==c[r]){
r++;
if(r==n) break;
}
int t = 1;
if(c[l]==b[0]) t = 2;
REP(i,r-l-t) ans = (ans*c[l])%mod;
l = r-1;
}
if(b[0]!=a[n-1]) ans = 0;
cout << ans <<endl;
}
|
a.cc: In function 'int main()':
a.cc:55:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
55 | REP(i,r-l-t) ans = (ans*c[l])%mod;
| ^~~
| abs
a.cc:58:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
58 | if(b[0]!=a[n-1]) ans = 0;
| ^~~
| abs
a.cc:59:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
59 | cout << ans <<endl;
| ^~~
| abs
|
s333712269
|
p03959
|
C++
|
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
int main(){
cin >> n;
REP(i,n)
cin >> t[i];
REP(i,n)
cin >> a[i];
tM[0] = t[0];
tm[0] = t[0] - 1;
FOR(i,1,n) {
if(t[i - 1] < t[i]) {
tM[i] = t[i];
tm[i] = t[i] - 1;
}else {
tM[i] = t[i];tm[i] = 0;
}
}
aM[n - 1] = a[n - 1];
am[n - 1] = a[n - 1] - 1;
REP(i,n - 1) {
if(a[i] > a[i + 1]) {
aM[i] = a[i];
am[i] = a[i] - 1;
}else {
aM[i] = a[i];am[i] = 0;
}
}
ll ans = 1;
REP(i,n) {
(ans *= max(0ll,min(tM[i],aM[i]) - max(tm[i],am[i]))) %= 1000000007;
//cout << max(0ll,min(tM[i],aM[i]) - max(tm[i],am[i])) << endl;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:25:9: error: reference to 'tm' is ambiguous
25 | tm[0] = t[0] - 1;
| ^~
In file included from /usr/include/time.h:39,
from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
a.cc:30:25: error: reference to 'tm' is ambiguous
30 | tm[i] = t[i] - 1;
| ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
a.cc:32:38: error: reference to 'tm' is ambiguous
32 | tM[i] = t[i];tm[i] = 0;
| ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
a.cc:50:56: error: reference to 'tm' is ambiguous
50 | (ans *= max(0ll,min(tM[i],aM[i]) - max(tm[i],am[i]))) %= 1000000007;
| ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
|
s363463795
|
p03959
|
C++
|
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
int main(){
cin >> n;
REP(i,n)
cin >> t[i];
REP(i,n)
cin >> a[i];
tM[0] = t[0];
tm[0] = t[0] - 1;
FOR(i,1,n) {
if(t[i - 1] < t[i]) {
tM[i] = t[i];
tm[i] = t[i] - 1;
}else {
tM[i] = t[i];tm[i] = 0;
}
}
aM[n - 1] = a[n - 1];
am[n - 1] = a[n - 1] - 1;
REP(i,n - 1) {
if(a[i] > a[i + 1]) {
aM[i] = a[i];
am[i] = a[i] - 1;
}else {
aM[i] = a[i];am[i] = 0;
}
}
ll ans = 1;
REP(i,n) {
(ans *= max(0ll,min(tM[i],aM[i]) - max(tm[i],am[i]))) %= 1000000007;
//cout << max(0ll,min(tM[i],aM[i]) - max(tm[i],am[i])) << endl;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:25:9: error: reference to 'tm' is ambiguous
25 | tm[0] = t[0] - 1;
| ^~
In file included from /usr/include/time.h:39,
from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
a.cc:30:25: error: reference to 'tm' is ambiguous
30 | tm[i] = t[i] - 1;
| ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
a.cc:32:38: error: reference to 'tm' is ambiguous
32 | tM[i] = t[i];tm[i] = 0;
| ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
a.cc:50:56: error: reference to 'tm' is ambiguous
50 | (ans *= max(0ll,min(tM[i],aM[i]) - max(tm[i],am[i]))) %= 1000000007;
| ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
7 | struct tm
| ^~
a.cc:16:37: note: 'll tm [100010]'
16 | ll n,t[100010],a[100010],tM[100010],tm[100010],aM[100010],am[100010];
| ^~
|
s582826776
|
p03959
|
C++
|
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(int i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n, t[100010],a[100010],v[100010],ans=1, fl[100010];
bool b=1;
int main() {
cin >> n;
rep(i, n) { cin >> t[i];
if ((i > 0 && t[i] != t[i - 1])||i==0)fl[i] = 1;
v[i] = t[i];
}
rep(i, n)cin >> a[i];
for (int i = n - 2; i >= 0; i--) {
if (a[i]<a[i + 1]) = 0;
}
for(int i=n-1;i>=0;--i){
if ((i <n-1 && a[i] != a[i + 1]) || i == n-1)fl[i] = 2;
if (fl[i] == 2 && a[i] > t[i]) b = 0;
v[i] = min(v[i], a[i]);
}
rep(i, n) {
if (fl[i] == 1 && t[i] > a[i])b = 0;
}
rep(i, n)if (!fl[i])ans = (ans*v[i]) % mod;
cout << (b?ans:0) << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:47:36: error: expected primary-expression before '=' token
47 | if (a[i]<a[i + 1]) = 0;
| ^
|
s693196211
|
p03959
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int N;
int T[100000],A[100000];
bool ht[100000],ha[100000];
int main(){
cin>>N;
FOR(i,0,N){
cin>>T[i];
}
FOR(i,0,N){
cin>>A[i];
}
int M=-1;
FOR(i,0,N){
if(M<T[i]){
M=T[i];
ht[i]=true;
}
}
M=-1;
ROF(i,0,N){
if(M<A[i]){
M=A[i];
ha[i]=true;
}
}
long long ans=1;
FOR(i,0,N){
if(ht[i]||ha[i]){
if(ht[i]&&ha[i]){
if(T[i]!=A[i]){
cout<<0<<endl;
return 0;
}
}else if(ht[i]){
if(T[i]>A[i]){
cout<<0<<endl;
return 0;
}
}else if(ha[i]){
if(T[i]<A[i]){
cout<<0<<endl;
return 0;
}
}
continue;
}else{
(ans*=min(t[i],a[i]))%=INF;
}
}
if(T[N-1]!=A[0]){
cout<<0<<endl;
}else{
cout<<ans<<endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:72:17: error: 't' was not declared in this scope
72 | (ans*=min(t[i],a[i]))%=INF;
| ^
a.cc:72:22: error: 'a' was not declared in this scope
72 | (ans*=min(t[i],a[i]))%=INF;
| ^
|
s835300788
|
p03959
|
C++
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int N;
int T[100000],A[100000];
int t[100000],a[100000];
bool ht[100000],ha[100000];
int main(){
cin>>N;
FOR(i,0,N){
cin>>T[i];
}
FOR(i,0,N){
cin>>A[i];
}
int M=-1;
FOR(i,0,N){
if(M<T[i]){
M=T[i];
ht[i]=true;
}
t[i]=M;
}
M=-1;
ROF(i,0,N){
if(M<A[i]){
M=A[i];
ha[i]=true;
}
a[i]=M;
}
long long ans=1;
FOR(i,0,N){
if(ht[i]||ha[i]){
if(ht[i]&&ha[i]){
if(T[i]!=A[i]){
cout<<0<<endl;
return 0;
}
}else if(ht[i]){
if(T[i]<A[i]){
cout<<0<<endl;
return 0;
}
}else if(ha[i]){
if(T[i]>A[i]){
cout<<0<<endl;
return 0;
)
}
continue;
}else{
(ans*=min(t[i],a[i]))%=INF;
}
}
if(T[N-1]!=A[0]){
cout<<0<<endl;
}else{
cout<<ans<<endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:71:9: error: expected primary-expression before ')' token
71 | )
| ^
a.cc:84:2: error: expected '}' at end of input
84 | }
| ^
a.cc:30:11: note: to match this '{'
30 | int main(){
| ^
|
s297538824
|
p03959
|
C++
|
#include<iostream>
using namespace std;
int T[100000],A[100000],temp[100000]={0};
bool mt[100000]={0};
int main(){
int N,i,j=0;
unsigned __int64 ans=1;
cin>>N;
for(i=0;i<N;i++){
cin>>T[i];
}
for(i=0;i<N;i++){
cin>>A[i];
}
mt[0]=1;mt[N-1]=1;
for(i=1;i<N;i++){
if(T[i]!=T[i-1]) mt[i]=1;
if(A[N-1-i]!=A[N-i]) mt[N-1-i]=1;
}
for(i=0;i<N;i++){
if(mt[i]==0){
if(T[i]>=A[i]){
temp[j]=T[i];
j++;
}else if(T[i]<A[i]){
temp[j]=A[i];
j++;
}
}
}
for(i=0;i<j;i++){
ans=ans*temp[i]%100000007;
}
//矛盾の時
if(T[N-1]!=A[0]) ans=0;
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:9:19: error: expected initializer before 'ans'
9 | unsigned __int64 ans=1;
| ^~~
a.cc:38:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
38 | ans=ans*temp[i]%100000007;
| ^~~
| abs
a.cc:42:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
42 | if(T[N-1]!=A[0]) ans=0;
| ^~~
| abs
a.cc:44:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
44 | cout<<ans<<endl;
| ^~~
| abs
|
s466308694
|
p03959
|
C++
|
#include <iostream>
using namespace std;
#define MOD 1000000007
#define REPS(i, n) for(int i = 1; i <= n; i++)
#define min(a, b) (a < b) ? a : b
typedef long long ll;
int main()
{
int n, t[10002], a[10002];
cin >> n;
REPS(i, n) cin >> t[i];
REPS(i, n) cin >> a[i];
t[0] = a[n+1] = 0;
if(t[n] != a[1]){
cout << 0 << endl;
return 0;
}
int x[10001], y[10001];
REPS(i, n){
if(t[i-1] < t[i]) x[i] = 1;
else x[i] = t[i];
if(a[n-i+2] < a[n-i+1]) y[n-i+1] = 1;
else y[n-i+1] = a[n-i+1];
}
ll ans = 1;
REPS(i, n){
ans *= min(x[i], y[i]);
ans %= MOD;
}
cout << ans << endl;
return 0;
}
yuto@DESKTOP-38451T9:/mnt/c/Users/yuto/Documents/ubuntu/atcoder/cf2016$ vim c.cpp
yuto@DESKTOP-38451T9:/mnt/c/Users/yuto/Documents/ubuntu/atcoder/cf2016$ g++ c.cpp
yuto@DESKTOP-38451T9:/mnt/c/Users/yuto/Documents/ubuntu/atcoder/cf2016$ cat c.cpp
#include <iostream>
using namespace std;
#define MOD 1000000007
#define REPS(i, n) for(int i = 1; i <= n; i++)
#define min(a, b) (a < b) ? a : b
typedef long long ll;
int main()
{
int n, t[10002], a[10002];
cin >> n;
REPS(i, n) cin >> t[i];
REPS(i, n) cin >> a[i];
t[0] = a[n+1] = 0;
int x[10001], y[10001];
REPS(i, n){
if(t[i-1] < t[i])
if(t[i] <= a[i]) x[i] = 1;
else x[i] = 0;
else x[i] = t[i];
if(a[n-i+2] == a[n-i+1])
if(a[n-i+1] <= t[n-i+1]) y[n-i+1] = 1;
else y[n-i+1] = 0;
else y[n-i+1] = a[n-i+1];
}
ll ans = 1;
REPS(i, n){
ans *= min(x[i], y[i]);
ans %= MOD;
}
cout << ans << endl;
return 0;
}
|
a.cc:44:5: error: stray '@' in program
44 | yuto@DESKTOP-38451T9:/mnt/c/Users/yuto/Documents/ubuntu/atcoder/cf2016$ vim c.cpp
| ^
a.cc:45:5: error: stray '@' in program
45 | yuto@DESKTOP-38451T9:/mnt/c/Users/yuto/Documents/ubuntu/atcoder/cf2016$ g++ c.cpp
| ^
a.cc:46:5: error: stray '@' in program
46 | yuto@DESKTOP-38451T9:/mnt/c/Users/yuto/Documents/ubuntu/atcoder/cf2016$ cat c.cpp
| ^
a.cc:44:1: error: 'yuto' does not name a type; did you mean 'auto'?
44 | yuto@DESKTOP-38451T9:/mnt/c/Users/yuto/Documents/ubuntu/atcoder/cf2016$ vim c.cpp
| ^~~~
| auto
a.cc:57:5: error: redefinition of 'int main()'
57 | int main()
| ^~~~
a.cc:11:5: note: 'int main()' previously defined here
11 | int main()
| ^~~~
|
s055150111
|
p03959
|
C++
|
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>
#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
#define INF 1000000007;
bool lock[100010];
ll dp[100010];
ll a[100010],b[100010];
int main()
{
int n;cin >> n;
REP(i,n)dp[i] = INF;
REP(i,n)cin >> a[i];
REP(i,n)cin >> b[i];
int now = 0;
REP(i,n)
{
if(a[i] > now)
{
lock[i] = true;
now = a[i];
}
dp[i] = min(dp[i],now);
}
now = 0;
REP(i,n)
{
if(b[n-i-1] > now)
{
if(lock[n-i-1] && b[n-i-1] > dp[n-i-1])
{
cout << 0 << endl;
return 0;
}
lock[n-i-1] = true;
}
now = b[n-i-1];
dp[n-i-1] = min(dp[n-i-1],now);
}
ll ans = 1;
REP(i,n)
{
if(!lock[i])
{
ans = (ans*dp[i]) % INF;
}
}
//SHOW1d(dp,n);
//SHOW1d(lock,n);
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:60:28: error: no matching function for call to 'min(ll&, int&)'
60 | dp[i] = min(dp[i],now);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:60:28: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
60 | dp[i] = min(dp[i],now);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:11:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:60:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
60 | dp[i] = min(dp[i],now);
| ~~~^~~~~~~~~~~
a.cc:77:32: error: no matching function for call to 'min(ll&, int&)'
77 | dp[n-i-1] = min(dp[n-i-1],now);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:77:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
77 | dp[n-i-1] = min(dp[n-i-1],now);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:77:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
77 | dp[n-i-1] = min(dp[n-i-1],now);
| ~~~^~~~~~~~~~~~~~~
|
s353726086
|
p03959
|
C++
|
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;
int a[100000];
int b[100000];
int h[100000];
int ah[100000];
int bh[100000];
const ll MOD = ll(1e9 + 7);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
memset(ah, -1, sizeof ah);
memset(bh, -1, sizeof bh);
for(int i = 0; i < N; i++) {
cin >> a[i];
}
ah[0] = a[0];
for(int i = 1; i < N; i++) {
if(a[i - 1] != a[i]) ah[i] = a[i];
}
for(int i = 0; i < N; i++) {
cin >> b[i];
}
bh[N - 1] = b[N - 1];
for(int i = 0; i < N - 1; i++) {
if(b[i] != b[i + 1]) bh[i] = b[i];
}
ll ans = 1;
for(int i = 0; i < N; i++) {
if(ah[i] != -1 && bh[i] != -1) {
if(ah[i] != bh[i]) {
cout << 0 << endl;
return 0;
}
}
if(ah[i] == -1 && bh[i] == -1) {
ans *= min(a[i], b[i]);
ans %= MOD;
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:25:9: error: 'memset' was not declared in this scope
25 | memset(ah, -1, sizeof ah);
| ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
6 | #include <cstdlib>
+++ |+#include <cstring>
7 | using namespace std;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.