submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s562843310
p00227
Java
import java.util.Arrays; import java.util.Scanner; public class Mani { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true) { int n = sc.nextInt(); int m = sc.nextInt(); if (n == 0) { break; } int[] p = new int[n]; for(int i=0;i<n;i++) { p[i] = sc.nextInt(); } Arrays.sort(p); int ans = 0; for(int i=0;i<n%m;i++) { ans += p[i]; } for(int i=0;i<n/m;i++) { for(int j=1;j<m;j++) { ans += p[n%m+m*i+j]; } } System.out.println(ans); } } }
Main.java:4: error: class Mani is public, should be declared in a file named Mani.java public class Mani { ^ 1 error
s031927904
p00227
Java
import java.util.Arrays; import java.util.Scanner; public class Mani { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(true) { int n = sc.nextInt(); int m = sc.nextInt(); if (n == 0) { break; } int[] p = new int[n]; for(int i=0;i<n;i++) { p[i] = sc.nextInt(); } Arrays.sort(p); int ans = 0; for(int i=0;i<n%m;i++) { ans += p[i]; } for(int i=0;i<n/m;i++) { for(int j=1;j<m;j++) { ans += p[n%m+m*i+j]; } } System.out.println(ans); } } }
Main.java:4: error: class Mani is public, should be declared in a file named Mani.java public class Mani { ^ 1 error
s322324655
p00227
C
#include <cstdio> #include <algorithm> using namespace std; int main(void) { int i, n, m, p; int sum, array[1000]; while (1){ scanf("%d %d", &n, &m); if (!n && !m){ break; } for (i = 0; i < n; i++){ scanf("%d", &array[i]); } sort(array, array + n); reverse(array, array + n); for (i = 0, sum = 0; i < n; i++){ if ((i + 1) % m != 0 || n - i + 1 < m){ sum += array[i]; } } printf("%d\n", sum); } return (0); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s151691766
p00227
C
#include<stdio.h> int main(void) { int a, b, c[1000], d, e, f, g = 1, i, j; while (scanf_s("%d %d", &a, &b)) { if (a == 0 && b == 0)break; j = 0, g = 1; for (i = 1;i <= a;i++) { scanf_s("%d", &d); c[i] = d; } f = a; while (g) { for (i = 1;i <= a;i++) { if (c[i] < c[i + 1]) { e = c[i]; c[i] = c[i + 1]; c[i + 1] = e; } } a--; if (a == 0) { g = a; } } for (i = 1;i <= f;i++) { if(i % b != 0) { j += c[i]; } } printf("%d\n", j); } return 0; }
main.c: In function 'main': main.c:6:16: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration] 6 | while (scanf_s("%d %d", &a, &b)) | ^~~~~~~ | scanf
s264702017
p00227
C
#include<stdio.h> int main(void) { int a, b, c[1000], d, e, g, i, j; while (scanf_s("%d %d", &a, &b)) { if (a == 0 && b == 0)break; j = 0, g = 1, e = 0; for (i = 1;i <= a;i++) { scanf_s("%d", &c[i]); } for (i = 1;i <= a;i++) { for (g = 1;g <= a-1;g++) { if (c[i] < c[j]) { e = c[i]; c[i] = c[g]; c[g] = e; } } } for (i = 1;i <= a;i++) { if(i % b != 0) { j += c[i]; } } printf("%d\n", j); } return 0; }
main.c: In function 'main': main.c:6:16: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration] 6 | while (scanf_s("%d %d", &a, &b)) | ^~~~~~~ | scanf
s682651309
p00227
C
#include <cstdio> #include <algorithm> #include <functional> #define N 1000 using namespace std; /** Application main entry point. */ int main ( int argc, char * argv[ ] ) { int i; for ( ; ; ) { int d[ N ]; int res = 0; int n, m; scanf ( "%d%d", &n, &m ); if ( !( n | m ) ) break ; for ( i = 0; i < n; ++i ) { scanf ( "%d", d + i ); } sort ( d, d + n, greater< int > ( ) ); for ( i = 0; i < n; ++i ) { res += ( i + 1 ) % m ? d[ i ] : 0; } printf ( "%d\n", res ); } return ( 0 ); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s031844098
p00227
C++
#include<iostream> #include<algorithm> using namespace std; int n,m,a[1000]; main() { while(cin>>n>>m,n) { int ans=0; for(int i=0;i<n;i++) { cin>>a[i]; ans+=a[i]; } sort(a,a+n); for(int i=n-m;i>=0i-=m) { ans-=a[i]; } cout<<ans<<endl; } }
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~ a.cc: In function 'int main()': a.cc:16:32: error: invalid operands of types 'int' and '__complex__ int' to binary 'operator>=' 16 | for(int i=n-m;i>=0i-=m) a.cc:16:39: error: expected ';' before ')' token 16 | for(int i=n-m;i>=0i-=m) | ^ | ;
s604548241
p00227
C++
#include <iostream> #include <algorithm> using namespace std; int main() { int n, m; while(1){ cin >> n >> m; if(n == 0 && m == 0) break; array<int, 1000> p; p.fill(0); for(int i = 0; i < n; ++i) cin >> p[i]; sort(p.begin(), p.end(), greater<int>()); int ans = 0; for(int i = 0; i < n; i += m){ for(int j = i; j < i + m - 1; ++j) ans += p[j]; } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:34: error: aggregate 'std::array<int, 1000> p' has incomplete type and cannot be defined 13 | array<int, 1000> p; | ^ a.cc:3:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>' 2 | #include <algorithm> +++ |+#include <array> 3 | using namespace std;
s186013402
p00227
C++
#include<cstdio> #include<string> #include<iostream> using namespace std; main(){ int m,n; int b[1001]; while(cin >> n >> m,m || n){ int total=0; int k=n/m; for(int i=0;i<n;i++) cin >> b[i]; sort(b,b+n); for(int i=1;i<=n;i++){ if(i%m) total+=b[n-i]; } cout << total << endl; } }
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'? 13 | sort(b,b+n); | ^~~~ | short
s051449404
p00227
C++
#include<iostream> using namespace std; main(){ int m,n; int b[1001]; while(cin >> n >> m,m || n){ int total=0; int k=n/m; for(int i=0;i<n;i++) cin >> b[i]; sort(b,b+n); for(int i=1;i<=n;i++){ if(i%m) total+=b[n-i]; } cout << total << endl; } }
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'? 11 | sort(b,b+n); | ^~~~ | short
s364743842
p00227
C++
#include<iostream> #include<cmath> #include<slgorithm> using namespace std; main(){ int m,n; int b[1001]; while(cin >> n >> m,m || n){ int total=0; int k=n/m; for(int i=0;i<n;i++) cin >> b[i]; sort(b,b+n); for(int i=1;i<=n;i++){ if(i%m) total+=b[n-i]; } cout << total << endl; } }
a.cc:3:9: fatal error: slgorithm: No such file or directory 3 | #include<slgorithm> | ^~~~~~~~~~~ compilation terminated.
s875155465
p00227
C++
#include<iostream> #include<algorithm> using namespace std; main(){ int ans=0; int be[10002]; int x=-1,n,m; while(1){ x=-1; ans=0; cin>>n>>m; if(n==m==0)break; for(int i=0;i<n;i++){ cin>>be[i]; ans+=be[i]; } sort(be,be+n,greater<int > ); while(n>=m){ x+=m; ans-=be[x]; n-=m; } cout<<ans<<endl; } }
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:17:28: error: expected primary-expression before ')' token 17 | sort(be,be+n,greater<int > ); | ^
s825833777
p00227
C++
#include<vector> #include<iostream> using namespace std; vector<int> l; int n,m; bool input(){ cin>>n>>m; if(n==m&&n==0)return false; l.clear(),l.resize(n); for(int i=0;i<n;i++){ cin>>l[i]; } return true; } int solve(){ sort(l.rbegin(),l.rend()); int ans = 0; for(int i=0;i<n;i++){ if( (i+1) %m == 0){ continue; } ans += l[i]; } return ans; } int main(){ while(input()){ cout<<solve()<<endl; } }
a.cc: In function 'int solve()': a.cc:19:3: error: 'sort' was not declared in this scope; did you mean 'short'? 19 | sort(l.rbegin(),l.rend()); | ^~~~ | short
s467252967
p00227
C++
#include<vector> #include<iostream> using namespace std; vector<int> l; int n,m; bool input(){ cin>>n>>m; if(n==m&&n==0)return false; l.clear(),l.resize(n); for(int i=0;i<n;i++){ cin>>l[i]; } return true; } int solve(){ sort(l.rbegin(),l.rend()); int ans = 0; for(int i=0;i<n;i++){ if( (i+1) %m == 0){ continue; } ans += l[i]; } return ans; } int main(){ while(input()){ cout<<solve()<<endl; } }
a.cc: In function 'int solve()': a.cc:19:3: error: 'sort' was not declared in this scope; did you mean 'short'? 19 | sort(l.rbegin(),l.rend()); | ^~~~ | short
s819830026
p00227
C++
#include <iostream> #include <vector> #include <algorithm> int main(){ int n, m; // n:konyu m:hukuro std::cin >> n >> m; while(n != 0 || m != 0){ std::vector<int> price; price.resize(n); for(int i = 0; i < n; ++i){ cin >> price[i]; // input } std::sort(price.begin(), price.end(), std::greater<int>()); int sum = 0; for(int i = 0; i < n; ++i){ if((i+1) % m != 0){ i += price[i];} } std::cout << sum << endl; std::cin >> n >> m; } return 0; }
a.cc: In function 'int main()': a.cc:12:25: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 12 | cin >> price[i]; // input | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:22:37: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 22 | std::cout << sum << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s158413500
p00227
C++
#include <iostream> #include <vector> #include <iterator> int main(){ int num, limit; while(std::cin >> num >> limit){ std::vector<int> price; int sum_price = 0; //input for(int i = 0; i < num; ++i){ int buf; sum_price += buf; std::sin >> buf; price.push_back(buf); } //sort std::sort(price.begin(),price.end(),std::greater<int>()); //discount int discount = 0; int in_bag = 0; for(auto itr = price.begin; itr != price.end(); ++itr){ ++in_bag; if(in_bag == limit){ discount += itr; in_bag = 0; } } std::cout << sum_price - dicount << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:16:30: error: 'sin' is not a member of 'std'; did you mean 'min'? 16 | std::sin >> buf; | ^~~ | min a.cc:20:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 20 | std::sort(price.begin(),price.end(),std::greater<int>()); | ^~~~ | qsort a.cc:24:38: error: unable to deduce 'auto' from 'price.std::vector<int>::begin' 24 | for(auto itr = price.begin; itr != price.end(); ++itr){ | ~~~~~~^~~~~ a.cc:24:38: note: couldn't deduce template parameter 'auto' 24 | for(auto itr = price.begin; itr != price.end(); ++itr){ | ^~~~~ a.cc:32:42: error: 'dicount' was not declared in this scope; did you mean 'discount'? 32 | std::cout << sum_price - dicount << std::endl; | ^~~~~~~ | discount
s103577902
p00227
C++
#include <iostream> #include <vector> #include <iterator> #include <algorithm> int main(){ int num, limit; while(std::cin >> num >> limit){ std::vector<int> price; int sum_price = 0; //input for(int i = 0; i < num; ++i){ int buf; sum_price += buf; std::cin >> buf; price.push_back(buf); } //sort std::sort(price.begin(),price.end(),std::greater<int>()); //discount int discount = 0; int in_bag = 0; for(auto itr = price.begin; itr != price.end(); ++itr){ ++in_bag; if(in_bag == limit){ discount += itr; in_bag = 0; } } std::cout << sum_price - discount << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:38: error: unable to deduce 'auto' from 'price.std::vector<int>::begin' 25 | for(auto itr = price.begin; itr != price.end(); ++itr){ | ~~~~~~^~~~~ a.cc:25:38: note: couldn't deduce template parameter 'auto' 25 | for(auto itr = price.begin; itr != price.end(); ++itr){ | ^~~~~
s507310577
p00227
C++
#include <iostream> #include <vector> #include <iterator> #include <algorithm> int main(){ int num, limit; while(std::cin >> num >> limit){ std::vector<int> price; int sum_price = 0; //input for(int i = 0; i < num; ++i){ int buf; sum_price += buf; std::cin >> buf; price.push_back(buf); } //sort std::sort(price.begin(),price.end(),std::greater<int>()); //discount int discount = 0; int in_bag = 0; for(auto itr = price.begin(); itr != price.end(); ++itr){ ++in_bag; if(in_bag == limit){ discount += itr; in_bag = 0; } } std::cout << sum_price - discount << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:28:42: error: no match for 'operator+=' (operand types are 'int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >') 28 | discount += itr; | ~~~~~~~~~^~~~~~
s313284869
p00227
C++
#include <iostream> #include <vector> #include <iterator> #include <algorithm> int main(){ int num, limit; while(std::cin >> num >> limit){ std::vector<int> price; int sum_price = 0; //input for(int i = 0; i < num; ++i){ int buf; sum_price += buf; std::cin >> buf; price.push_back(buf); } //sort std::sort(price.begin(),price.end(),std::greater<int>()); //discount int discount = 0; int in_bag = 0; for(auto itr = price.begin(); itr != price.end(); ++itr){ ++in_bag; if(in_bag == limit){ int buf = itr; discount += buf; in_bag = 0; } } std::cout << sum_price - discount << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:28:43: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization 28 | int buf = itr; | ^~~ | | | __gnu_cxx::__normal_iterator<int*, std::vector<int> >
s777216860
p00227
C++
#include <iostream> #define MAX_NM 1000 int n, m, all; int p[MAX_NM]; void solve(); int main(){ while(true){ all = 0; std::cin >> n >> m; for(int i = 0; i < n; ++i){ std::cin >> p[i]; all += p[i]; } solve(); std::cout << all << std::endl; } return 0; } void solve(){ std::sort(p, p + n, std::greater<int>()); for(int i = n - 1; i > 0; i -= m) all -= p[i]; return; }
a.cc: In function 'void solve()': a.cc:25:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 25 | std::sort(p, p + n, std::greater<int>()); | ^~~~ | qsort
s630337941
p00227
C++
#include <iostream> #define MAX_NM 1000 int n, m, all; int p[MAX_NM]; void solve(); int main(){ while(true){ all = 0; std::cin >> n >> m; for(int i = 0; i < n; ++i){ std::cin >> p[i]; all += p[i]; } solve(); std::cout << all << std::endl; } return 0; } void solve(){ std::sort(p, p + n, std::greater<int>()); for(int i = 1; i <= n; ++i) all -= p[i * m - 1]; return; }
a.cc: In function 'void solve()': a.cc:25:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 25 | std::sort(p, p + n, std::greater<int>()); | ^~~~ | qsort
s891676018
p00227
C++
#include <iostream> #define MAX_NM 1000 int n, m, all; int p[MAX_NM]; void solve(); int main(){ while(true){ all = 0; std::cin >> n >> m; for(int i = 0; i < n; ++i){ std::cin >> p[i]; all += p[i]; } solve(); std::cout << all << std::endl; } return 0; } void solve(){ std::sort(p, p + n, std::greater<int>()); for(int i = 1; i <= n; ++i) all -= p[i * m - 1]; return; }
a.cc: In function 'void solve()': a.cc:25:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 25 | std::sort(p, p + n, std::greater<int>()); | ^~~~ | qsort
s130044405
p00227
C++
#include <iostream> #define MAX_NM 1000 int n, m, all; int p[MAX_NM]; void solve(); int main(){ while(true){ all = 0; std::cin >> n >> m; for(int i = 0; i < n; ++i){ std::cin >> p[i]; all += p[i]; } solve(); std::cout << all << std::endl; } return 0; } void solve(){ std::sort(p, p + n, std::greater<int>()); for(int i = 1; i <= n; ++i) all -= p[i * m - 1]; return; }
a.cc: In function 'void solve()': a.cc:25:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 25 | std::sort(p, p + n, std::greater<int>()); | ^~~~ | qsort
s501394728
p00227
C++
#include <iostream> #include <vector> int main(){ int n,m; int p; while(true){ std::cin >> n >> m; if(n == 0 && m == 0){ break; } std::vector<int> price; for(int i=0; i<n ;++i){ std::cin >> p; price.push_back(p); } //sort in descending order std::sort(price.begin(), price.end(), std::greater<int>()); int i=1; //counter int sum=0; for(int x : price){ if(i%m != 0){ sum += x; } ++i; } //output std::cout << sum << std::endl; } }
a.cc: In function 'int main()': a.cc:20:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 20 | std::sort(price.begin(), price.end(), std::greater<int>()); | ^~~~ | qsort
s397430225
p00227
C++
#include <iostream> #include <vector> int main(){ int n,m; int p; while(true){ std::cin >> n >> m; if(n == 0 && m == 0){ break; } std::vector<int> price; for(int i=0; i<n ;++i){ std::cin >> p; price.push_back(p); } //sort in descending order std::sort(price.begin(), price.end(), std::greater<int>()); int i=1; //counter int sum=0; for(int x : price){ if(i%m != 0){ sum += x; } ++i; } //output std::cout << sum << std::endl; } }
a.cc: In function 'int main()': a.cc:20:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 20 | std::sort(price.begin(), price.end(), std::greater<int>()); | ^~~~ | qsort
s911625729
p00227
C++
#include <iostream> #include <string> #include <algorithm> #include <numeric> #include <boost/tokenizer.hpp> #include <boost/lexical_cast.hpp> #include <vector> #include <list> using namespace std; using namespace boost; int main(int argc, char* argv[]) { using sprtr = char_separator<char>; using tknzr = tokenizer<sprtr>; sprtr sep(" ", "", keep_empty_tokens); int f, mf, mo; string line; while(1) { int n, m; { getline(cin, line); tknzr tkns(line, sep); auto it = tkns.begin(); n = lexical_cast<int>(*it++); m = lexical_cast<int>(*it); } if( n == 0 && m == 0 ) { break; } list<int> ps; { getline(cin, line); tknzr tkns(line, sep); for( auto p : tkns ) { //cout << p << endl; ps.push_back(lexical_cast<int>(p)); } } ps.sort(greater<int>()); int div = n / m; int mod = n % m; int sum = 0; auto it = ps.begin(); for( int i = 0; i < div; i++ ) { for( int j = 0; j < m; j++ ) { auto p = *it++; if( j == m-1 ) continue; sum += p; } } if( mod ) { for( int i = 0; i < mod; i++ ) { auto p = *it++; sum += p; } } cout << sum << endl; ps.clear(); } return 0; }
a.cc:5:10: fatal error: boost/tokenizer.hpp: No such file or directory 5 | #include <boost/tokenizer.hpp> | ^~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s339752506
p00227
C++
#include <bits/stdc++.h> #define r(i,n) for(i=0;i<n;i++) using namespace std; int main(){ int a,b,i; while(cin>>a>>b,a){ int c[a],s=0,k=0.p=0; r(i,a){cin>>c[i];p+=c[i];} sort(c,c+a); for(i=a-1;i>=0;i--){ k++; if(k==b){ s+=c[i]; k=0; } } cout<<p-s<<endl;; } }
a.cc: In function 'int main()': a.cc:7:20: error: unable to find numeric literal operator 'operator""p' 7 | int c[a],s=0,k=0.p=0; | ^~~ a.cc:8:22: error: 'p' was not declared in this scope 8 | r(i,a){cin>>c[i];p+=c[i];} | ^ a.cc:17:11: error: 'p' was not declared in this scope 17 | cout<<p-s<<endl;; | ^
s205524628
p00227
C++
#include "stdafx.h" #include"iostream" using namespace std; int main() { while (1) { int n, m,p[10000],sum=0; cin >> n >> m; if (n == 0 && m == 0)break; for (int i = 1; i < n+1; i++) { cin >> p[i]; } for (int j = 0; j < n - 1; j++) { for (int i = 1; i < n + 1; i++) { if (p[i] < p[i + 1]) { swap(p[i], p[i + 1]); } } } for (int i = 1; i < n + 1; i++) { if (i%m != 0) { sum += p[i]; } } cout << sum << endl; } return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s277271299
p00227
C++
#include "stdafx.h" #include"iostream" using namespace std; int main() { while (1) { int n, m,p[10000],sum=0; cin >> n >> m; if (n == 0 && m == 0)break; for (int i = 1; i < n+1; i++) { cin >> p[i]; } for (int j = 0; j < n + 1; j++) { for (int i = 1; i <= n ; i++) { if (p[i] < p[i + 1]) { swap(p[i], p[i + 1]); } } } for (int i = 1; i < n + 1; i++) { if (i%m != 0) { sum += p[i]; } } cout << sum << endl; } return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s694908920
p00227
C++
#include <iostream> #include <vector> #include <string> #include <sstream> int main(){ int n,m,x; int flag = 0; int num = 0; std::vector<int> v; std::cin >> n >> m; while(std::cin >> x){ v.emplace_back(x); } std::sort(v.begin(), v.end(), std::greater<int>()); for(int y = 0;y < n;y++){ flag++; if(flag != m){ num += v[y]; } else flag = 0; } std::cout << num << std::endl; }
a.cc: In function 'int main()': a.cc:18:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 18 | std::sort(v.begin(), v.end(), std::greater<int>()); | ^~~~ | qsort
s426509630
p00227
C++
#include <iostream> #include <vector> #include <string> #include <sstream> int main(){ int n,m,x; int flag = 0; int num = 0; std::vector<int> v; std::cin >> n >> m; while(std::cin >> x){ v.emplace_back(x); } std::sort(v.begin(), v.end(), std::greater<int>()); for(int y = 0;y < n;y++){ flag++; if(flag != m){ num += v[y]; } else flag = 0; } std::cout << num << std::endl; }
a.cc: In function 'int main()': a.cc:18:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 18 | std::sort(v.begin(), v.end(), std::greater<int>()); | ^~~~ | qsort
s106788863
p00227
C++
#include <iostream> #include <vector> #include <string> #include <sstream> int main(){ int n,m,x; int flag = 0; int num = 0; std::vector<int> v; std::cin >> n >> m; while(std::cin >> x){ v.emplace_back(x); } std::sort(v.begin(), v.end(), std::greater<int>()); for(int y = 0;y < n;y++){ flag++; if(flag != m){ num += v[y]; } else flag = 0; } std::cout << num << std::endl; }
a.cc: In function 'int main()': a.cc:18:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 18 | std::sort(v.begin(), v.end(), std::greater<int>()); | ^~~~ | qsort
s366860563
p00227
C++
#include <iostream> #include <vector> #include <string> #include <sstream> int main(){ int n,m,x; int flag = 0; int num = 0; std::vector<int> v; std::cin >> n >> m; while(std::cin >> x){ v.emplace_back(x); } std::sort(v.begin(), v.end(), std::greater<int>()); for(int y = 0;y < n;y++){ flag++; if(flag != m){ num += v[y]; } else flag = 0; } std::cout << num << std::endl; }
a.cc: In function 'int main()': a.cc:18:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 18 | std::sort(v.begin(), v.end(), std::greater<int>()); | ^~~~ | qsort
s947148728
p00227
C++
#include <iostream> #include <vector> #include <string> int main(){ int n,m,x; int flag = 0; int num = 0; std::vector<int> v; std::cin >> n >> m; while(std::cin >> x){ v.emplace_back(x); } std::sort(v.rbegin(),v.rend()); for(int y = 0;y < n;y++){ flag++; if(flag != m){ num += v[y]; } else flag = 0; } std::cout << num << std::endl; }
a.cc: In function 'int main()': a.cc:17:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 17 | std::sort(v.rbegin(),v.rend()); | ^~~~ | qsort
s824383946
p00227
C++
#include <iostream> #include <vector> #include <string> int main(){ int n,m,x; int flag = 0; int num = 0; std::vector<int> v; std::cin >> n >> m; while(std::cin >> x){ v.push_back(x); } std::sort(v.rbegin(),v.rend()); for(int y = 0;y < n;++y){ flag++; if(flag != m){ num += v[y]; } else flag = 0; } std::cout << num << std::endl; }
a.cc: In function 'int main()': a.cc:17:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 17 | std::sort(v.rbegin(),v.rend()); | ^~~~ | qsort
s064565204
p00227
C++
#include <iostream> #include <vector> #include <string> int main(){ int n,m,x; int flag = 0; int num = 0; std::vector<int> v; std::cin >> n >> m; while(std::cin >> x){ v.push_back(x); } sort(v.rbegin(),v.rend()); for(int y = 0;y < n;++y){ flag++; if(flag != m){ num += v[y]; } else flag = 0; } std::cout << num << std::endl; }
a.cc: In function 'int main()': a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'? 17 | sort(v.rbegin(),v.rend()); | ^~~~ | short
s304852856
p00227
C++
#include <iostream> #include <array> int main(){ int n,m; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::array<u_int, n> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } std::sort(p.begin(), p.end()); int price=0; //最終出力 while(n>=m){ for(int i=0;i<m;i++){ price += p[n-1-i]; } n -= m; } for(int i=0;i<n;i++){ price += p[i]; } std::cout << price << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:36: error: the value of 'n' is not usable in a constant expression 10 | std::array<u_int, n> p; //野菜価格一覧 | ^ a.cc:6:13: note: 'int n' is not const 6 | int n,m; //問題文のn,m | ^ a.cc:10:36: note: in template argument for type 'long unsigned int' 10 | std::array<u_int, n> p; //野菜価格一覧 | ^ a.cc:12:38: error: invalid types 'int[int]' for array subscript 12 | std::cin >> p[i]; | ^ a.cc:14:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 14 | std::sort(p.begin(), p.end()); | ^~~~ | qsort a.cc:14:29: error: request for member 'begin' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~~~ a.cc:14:40: error: request for member 'end' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~ a.cc:20:43: error: invalid types 'int[int]' for array subscript 20 | price += p[n-1-i]; | ^ a.cc:25:35: error: invalid types 'int[int]' for array subscript 25 | price += p[i]; | ^
s324830722
p00227
C++
#include <iostream> #include <array> int main(){ int n=0,m=0; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::array<u_int, n> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } std::sort(p.begin(), p.end()); int price=0; //最終出力 while(n>=m){ for(int i=0;i<m;i++){ price += p[n-1-i]; } n -= m; } for(int i=0;i<n;i++){ price += p[i]; } std::cout << price << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:36: error: the value of 'n' is not usable in a constant expression 10 | std::array<u_int, n> p; //野菜価格一覧 | ^ a.cc:6:13: note: 'int n' is not const 6 | int n=0,m=0; //問題文のn,m | ^ a.cc:10:36: note: in template argument for type 'long unsigned int' 10 | std::array<u_int, n> p; //野菜価格一覧 | ^ a.cc:12:38: error: invalid types 'int[int]' for array subscript 12 | std::cin >> p[i]; | ^ a.cc:14:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 14 | std::sort(p.begin(), p.end()); | ^~~~ | qsort a.cc:14:29: error: request for member 'begin' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~~~ a.cc:14:40: error: request for member 'end' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~ a.cc:20:43: error: invalid types 'int[int]' for array subscript 20 | price += p[n-1-i]; | ^ a.cc:25:35: error: invalid types 'int[int]' for array subscript 25 | price += p[i]; | ^
s510994417
p00227
C++
#include <iostream> #include <array> int main(){ int n=0,m=0; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::array<u_int, n> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } std::sort(p.begin(), p.end()); int price=0; //最終出力 while(n>=m){ for(int i=0;i<m;i++){ price += p[n-1-i]; } n -= m; } for(int i=0;i<n;i++){ price += p[i]; } std::cout << price << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:36: error: the value of 'n' is not usable in a constant expression 10 | std::array<u_int, n> p; //野菜価格一覧 | ^ a.cc:6:13: note: 'int n' is not const 6 | int n=0,m=0; //問題文のn,m | ^ a.cc:10:36: note: in template argument for type 'long unsigned int' 10 | std::array<u_int, n> p; //野菜価格一覧 | ^ a.cc:12:38: error: invalid types 'int[int]' for array subscript 12 | std::cin >> p[i]; | ^ a.cc:14:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 14 | std::sort(p.begin(), p.end()); | ^~~~ | qsort a.cc:14:29: error: request for member 'begin' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~~~ a.cc:14:40: error: request for member 'end' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~ a.cc:20:43: error: invalid types 'int[int]' for array subscript 20 | price += p[n-1-i]; | ^ a.cc:25:35: error: invalid types 'int[int]' for array subscript 25 | price += p[i]; | ^
s251070255
p00227
C++
#include <iostream> #include <array> int main(){ int n=0,m=0; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::array<int, n> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } std::sort(p.begin(), p.end()); int price=0; //最終出力 while(n>=m){ for(int i=0;i<m;i++){ price += p[n-1-i]; } n -= m; } for(int i=0;i<n;i++){ price += p[i]; } std::cout << price << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:34: error: the value of 'n' is not usable in a constant expression 10 | std::array<int, n> p; //野菜価格一覧 | ^ a.cc:6:13: note: 'int n' is not const 6 | int n=0,m=0; //問題文のn,m | ^ a.cc:10:34: note: in template argument for type 'long unsigned int' 10 | std::array<int, n> p; //野菜価格一覧 | ^ a.cc:12:38: error: invalid types 'int[int]' for array subscript 12 | std::cin >> p[i]; | ^ a.cc:14:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 14 | std::sort(p.begin(), p.end()); | ^~~~ | qsort a.cc:14:29: error: request for member 'begin' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~~~ a.cc:14:40: error: request for member 'end' in 'p', which is of non-class type 'int' 14 | std::sort(p.begin(), p.end()); | ^~~ a.cc:20:43: error: invalid types 'int[int]' for array subscript 20 | price += p[n-1-i]; | ^ a.cc:25:35: error: invalid types 'int[int]' for array subscript 25 | price += p[i]; | ^
s735591882
p00227
C++
#include <iostream> #include <vector> int main(){ int n,m; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::vector<int> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } std::sort(p.begin(), p.end()); std::reverse(p.begin(), p.end()); //降順ソート for(int i=m-1;i<n;i+=m){ std::p.erase(std::v.bigin() +i); } std::cout << std::accumulate(p.begin(), p.end(), 0) << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 14 | std::sort(p.begin(), p.end()); | ^~~~ | qsort a.cc:15:22: error: 'reverse' is not a member of 'std' 15 | std::reverse(p.begin(), p.end()); //降順ソート | ^~~~~~~ a.cc:18:30: error: 'p' is not a member of 'std' 18 | std::p.erase(std::v.bigin() +i); | ^ a.cc:18:43: error: 'v' is not a member of 'std' 18 | std::p.erase(std::v.bigin() +i); | ^ a.cc:21:35: error: 'accumulate' is not a member of 'std' 21 | std::cout << std::accumulate(p.begin(), p.end(), 0) << std::endl; | ^~~~~~~~~~
s248117297
p00227
C++
#include <iostream> #include <vector> int main(){ int n,m; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::vector<int> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } std::sort(p.begin(), p.end()); std::reverse(p.begin(), p.end()); //降順ソート for(int i=m-1;i<n;i+=m){ p.erase(std::v.bigin() +i); } std::cout << std::accumulate(p.begin(), p.end(), 0) << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:22: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 14 | std::sort(p.begin(), p.end()); | ^~~~ | qsort a.cc:15:22: error: 'reverse' is not a member of 'std' 15 | std::reverse(p.begin(), p.end()); //降順ソート | ^~~~~~~ a.cc:18:38: error: 'v' is not a member of 'std' 18 | p.erase(std::v.bigin() +i); | ^ a.cc:21:35: error: 'accumulate' is not a member of 'std' 21 | std::cout << std::accumulate(p.begin(), p.end(), 0) << std::endl; | ^~~~~~~~~~
s760726317
p00227
C++
#include <iostream> #include <vector> int main(){ int n,m; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::vector<int> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } sort(p.begin(), p.end()); reverse(p.begin(), p.end()); //降順ソート for(int i=m-1;i<n;i+=m){ p.erase(std::v.bigin() +i); } std::cout << accumulate(p.begin(), p.end(), 0) << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(p.begin(), p.end()); | ^~~~ | short a.cc:15:17: error: 'reverse' was not declared in this scope 15 | reverse(p.begin(), p.end()); //降順ソート | ^~~~~~~ a.cc:18:38: error: 'v' is not a member of 'std' 18 | p.erase(std::v.bigin() +i); | ^ a.cc:21:30: error: 'accumulate' was not declared in this scope 21 | std::cout << accumulate(p.begin(), p.end(), 0) << std::endl; | ^~~~~~~~~~
s554967908
p00227
C++
#include <iostream> #include <vector> #include <algorithm> #include <numeric> int main(){ int n,m; //問題文のn,m while(std::cin >> n >> m){ if(n==0&&m==0) break; std::vector<int> p; //野菜価格一覧 for(int i=0;i<n;i++){ std::cin >> p[i]; } sort(p.begin(), p.end()); reverse(p.begin(), p.end()); //降順ソート for(int i=m-1;i<n;i+=m){ p.erase(p.bigin() +i); } std::cout << accumulate(p.begin(), p.end(), 0) << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:35: error: 'class std::vector<int>' has no member named 'bigin'; did you mean 'begin'? 20 | p.erase(p.bigin() +i); | ^~~~~ | begin
s522258147
p00227
C++
include <iostream> #include <vector> #include <queue> int main(){ int n,m; while(std::cin >> n >> m){ if(n == 0 && m == 0){ break; } std::priority_queue<int> que; int vegetable; for(int i = 0; i < n; ++i){ std::cin >> vagetable; que.push(); } int price = 0; for(int i = 0; i < n; ++i){ if((i % m) != (m - 1)){ price += que.top(); que.pop(); } } std::cout << price << std::endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
s878878027
p00227
C++
#include <iostream> #include <queue> int main(){ int n,m; while(std::cin >> n >> m){ if(n == 0 && m == 0){ break; } std::priority_queue<int> que; int vegetable; for(int i = 0; i < n; ++i){ std::cin >> vagetable; que.push(); } int price = 0; for(int i = 0; i < n; ++i){ if((i % m) != (m - 1)){ price += que.top(); que.pop(); } } std::cout << price << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:37: error: 'vagetable' was not declared in this scope; did you mean 'vegetable'? 13 | std::cin >> vagetable; | ^~~~~~~~~ | vegetable a.cc:14:33: error: no matching function for call to 'std::priority_queue<int>::push()' 14 | que.push(); | ~~~~~~~~^~ In file included from /usr/include/c++/14/queue:66, from a.cc:2: /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 = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; value_type = int]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; value_type = int]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate expects 1 argument, 0 provided
s067243149
p00227
C++
#include <iostream> #include <queue> int main(){ int n,m; while(std::cin >> n >> m){ if(n == 0 && m == 0){ break; } std::priority_queue<int> que; int vegetable; for(int i = 0; i < n; ++i){ std::cin >> vegetable; que.push(); } int price = 0; for(int i = 0; i < n; ++i){ if((i % m) != (m - 1)){ price += que.top(); que.pop(); } } std::cout << price << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:33: error: no matching function for call to 'std::priority_queue<int>::push()' 14 | que.push(); | ~~~~~~~~^~ In file included from /usr/include/c++/14/queue:66, from a.cc:2: /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 = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; value_type = int]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = int; _Sequence = std::vector<int, std::allocator<int> >; _Compare = std::less<int>; value_type = int]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate expects 1 argument, 0 provided
s634983733
p00228
Java
public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; Digital digital; while(true){ line = br.readLine(); int num = Integer.valueOf(line); if(num == -1){ break; } digital = DigitalType.NN.getDigital(); int sig; Digital digNum; for(int i = 0; i < num; i++){ line = br.readLine(); sig = Integer.valueOf(line); digNum = DigitalType.getDigitalFromNumber(sig); System.out.println(getDiffSignal(digital, digNum)); digital = digNum; } } } private static String getDiffSignal(Digital dig1, Digital dig2){ String result = ""; result = result + getDiff(dig1.getG(), dig2.getG()); result = result + getDiff(dig1.getF(), dig2.getF()); result = result + getDiff(dig1.getE(), dig2.getE()); result = result + getDiff(dig1.getD(), dig2.getD()); result = result + getDiff(dig1.getC(), dig2.getC()); result = result + getDiff(dig1.getB(), dig2.getB()); result = result + getDiff(dig1.getA(), dig2.getA()); return result; } private static String getDiff(int num1, int num2){ if(num1 == num2){ return "0"; }else{ return "1"; } } private enum DigitalType{ NN(-1, "00000000"), N0(0, "0111111"), N1(1, "0000110"), N2(2, "1011011"), N3(3, "1001111"), N4(4, "1100110"), N5(5, "1101101"), N6(6, "1111101"), N7(7, "0100111"), N8(8, "1111111"), N9(9, "1101111"); private int number; private Digital digital; DigitalType(int number, String signal){ this.number = number; this.digital = new Digital(signal); } public Digital getDigital(){ return digital; } public int getNumber() { return number; } public static Digital getDigitalFromNumber(int num){ for(DigitalType type : DigitalType.values()){ if(type.getNumber() == num) return type.getDigital(); } return null; } } private static class Digital { Integer g = 0,f = 0,e = 0,d = 0,c = 0,b = 0,a = 0; public Digital(String sig){ setSignal(sig); } public void setSignal(String sig){ String[] nums = sig.split(""); g = getNumber(g, Integer.parseInt(nums[0])); f = getNumber(f, Integer.parseInt(nums[1])); e = getNumber(e, Integer.parseInt(nums[2])); d = getNumber(d, Integer.parseInt(nums[3])); c = getNumber(c, Integer.parseInt(nums[4])); b = getNumber(b, Integer.parseInt(nums[5])); a = getNumber(a, Integer.parseInt(nums[6])); } private int getNumber(Integer target, Integer num){ if(target == 0){ if(num == 1) return 1; }else{ if(num == 1) return 0; } return target; } public Integer getG() { return g; } public Integer getF() { return f; } public Integer getE() { return e; } public Integer getD() { return d; } public Integer getC() { return c; } public Integer getB() { return b; } public Integer getA() { return a; } } }
Main.java:3: error: cannot find symbol public static void main(String[] args) throws IOException { ^ symbol: class IOException location: class Main Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main 4 errors
s793843344
p00228
C
#include<stdio> int main(void){ int i ,j,n,b,a; int s[10][7]={{0,1,1,1,1,1,1},{0,0,0,0,1,1,0},{1,0,1,1,0,1,1},{1,0,0,1,1,1,1},{1,1,0,0,1,1,0},{1,1,0,1,1,0,1},{1,1,1,1,1,0,1},{0,1,0,0,1,1,1},{1,1,1,1,1,1,1},{1,1,0,1,1,1,1}}; int ans[7]; while(scanf("%d",&n),n+1){ b=0; for(i=0;i<n;i++){ scanf("%d",&a); for(j=0;i<7;j++){ if(s[b][j]==s[a][j]) ans[j]=0; else ans[j]=1; } b=a; for(i=0;i<7;i++){ printf("%d",ans[i]); } puts(""); } } return 0;}
main.c:1:9: fatal error: stdio: No such file or directory 1 | #include<stdio> | ^~~~~~~ compilation terminated.
s311852206
p00228
C
#include <stdio.h> int main(){ int i,j,n; char L[][8]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1111110"}: while (1){ scanf("%d",&n); if (n==-1) break; char b[]="0000000"; int p=10; for (i=0;i<n;i++){ int a; scanf("%d",&a); for (j=0;j<7;j++){ if (L[a][j]==L[p][j]) b[j]='0'; else b[j]='1'; } p=a; printf("%s\n",b); } } return 0; }
main.c: In function 'main': main.c:5:116: error: expected ',' or ';' before ':' token 5 | char L[][8]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1111110"}: | ^
s596504848
p00228
C++
b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);}
a.cc:1:1: error: 'b' does not name a type 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:44: error: expected unqualified-id before ',' token 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:46: error: expected constructor, destructor, or type conversion before '=' token 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:60: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^~~~ a.cc: In function 'int main()': a.cc:1:85: error: 'n' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:73: error: 'scanf' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^~~~~ a.cc:1:96: error: 'i' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:117: error: 'k' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:124: error: 'q' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:132: error: 'j' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:158: error: 'p' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:145: error: 'printf' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} a.cc:1:167: error: 'puts' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^~~~ a.cc:1:180: error: 'b' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^ a.cc:1:195: error: 'exit' was not declared in this scope 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);} | ^~~~ a.cc:1:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>' +++ |+#include <cstdlib> 1 | b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);}
s301400260
p00228
C++
#include <iostream> #include <algorithm> #include <string> const int V[10][7] = { {0, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 1, 1, 0}, {1, 0, 1, 1, 0, 1, 1}, {1, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0}, {1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 1, 1, 0, 1}, {0, 1, 0, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 1, 1, 1, 1} }; using namespace std; typedef long long ll; typedef long double ld; string change(int a, int b) { string res = ""; for(int i=0; i<7; i++){ if(V[a][i] == V[b][i]) { res += "0"; } else { res += "1"; } } return res; } int main() { int n, f=-1, t; while(true) { cin >> n; if(n == -1) break; for(int i=0; i<n; i++) { cin >> t; if(f == -1) { for(int j=0; j<7; j++) { cout << V[t][j]; } cout << endl; f = t; } else { cout << change(f, t) << endl; f = t; } f = -1; } return 0; }
a.cc: In function 'int main()': a.cc:59:2: error: expected '}' at end of input 59 | } | ^ a.cc:36:12: note: to match this '{' 36 | int main() { | ^
s921968347
p00228
C++
using namespace std; string s[10] = { "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111", }; int main(void){ int n; while(cin>>n, (n!=-1)){ string now = "0000000"; for(int i=0;i<n;i++){ int x; cin>>x; string change = "0000000"; for(int i=0;i<7;i++){ if(s[x][i] != now[i]){ change[i] = '1'; } } cout<<change<<endl; now = s[x]; } } return 0; }
a.cc:3:1: error: 'string' does not name a type 3 | string s[10] = { | ^~~~~~ a.cc: In function 'int main()': a.cc:19:9: error: 'cin' was not declared in this scope 19 | while(cin>>n, (n!=-1)){ | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | using namespace std; a.cc:20:5: error: 'string' was not declared in this scope 20 | string now = "0000000"; | ^~~~~~ a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' +++ |+#include <string> 1 | using namespace std; a.cc:24:13: error: expected ';' before 'change' 24 | string change = "0000000"; | ^~~~~~~ | ; a.cc:26:12: error: 's' was not declared in this scope 26 | if(s[x][i] != now[i]){ | ^ a.cc:26:23: error: 'now' was not declared in this scope 26 | if(s[x][i] != now[i]){ | ^~~ a.cc:27:11: error: 'change' was not declared in this scope 27 | change[i] = '1'; | ^~~~~~ a.cc:30:7: error: 'cout' was not declared in this scope 30 | cout<<change<<endl; | ^~~~ a.cc:30:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:30:13: error: 'change' was not declared in this scope 30 | cout<<change<<endl; | ^~~~~~ a.cc:30:21: error: 'endl' was not declared in this scope 30 | cout<<change<<endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | using namespace std; a.cc:31:7: error: 'now' was not declared in this scope 31 | now = s[x]; | ^~~ a.cc:31:13: error: 's' was not declared in this scope 31 | now = s[x]; | ^
s272499169
p00228
C++
// 0228.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #include "stdafx.h" #include<stdio.h> #include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <iomanip> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define ld long double int main() { ios::sync_with_stdio(false); string a[10]; a[0] = "0111111"; a[1] = "0000110"; a[2] = "1011011"; a[3] = "1001111"; a[4] = "1100001"; a[5] = "1101101"; a[7] = "0100111"; a[6] = "1111101"; a[8] = "1111111"; a[9] = "1101111"; while (true) { ll n; cin >> n; if (n == -1) { break; } string s = "0000000"; for (int i = 0; i < n; i++) { int d; cin >> d; for (int j = 0; j < 7; j++) { if (a[d][j] == s[j]) { cout << 0; } else { cout << 1; } } cout << endl; s = a[i]; } } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s157640564
p00228
C++
#include <cstdio> using namespace std; int main(){ int n ,num; string seg="0000000"; // a b c d e f g の順 string set[10]={ /* 各数字のビット */ "0111111", // 0 "0000110", // 1 "1011011", // 2 "1001111", // 3 "1100110", // 4 "1101101", // 5 "1111101", // 6 "0100111", // 7 "1111111", // 8 "1101111" // 9 }; while( true ){ // -1まで cin >> n; if( n == -1 ){ break; } for( int i=0 ; i<n ; i++ ){ cin >> num; for( int j=0 ; j<7 ; j++ ){ if( seg[j] != set[num][j] ){ // ビットが違ったら cout << '1'; } else{ // 同じなら cout << '0' ; } } seg = set[num]; cout << endl; } seg = "0000000"; // セグメントを0のに初期化 } }
a.cc: In function 'int main()': a.cc:6:3: error: 'string' was not declared in this scope 6 | string seg="0000000"; // a b c d e f g の順 | ^~~~~~ a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' 1 | #include <cstdio> +++ |+#include <string> 2 | using namespace std; a.cc:7:9: error: expected ';' before 'set' 7 | string set[10]={ /* 各数字のビット */ | ^~~~ | ; a.cc:21:5: error: 'cin' was not declared in this scope 21 | cin >> n; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <cstdio> +++ |+#include <iostream> 2 | using namespace std; a.cc:29:13: error: 'seg' was not declared in this scope 29 | if( seg[j] != set[num][j] ){ // ビットが違ったら | ^~~ a.cc:29:23: error: 'set' was not declared in this scope 29 | if( seg[j] != set[num][j] ){ // ビットが違ったら | ^~~ a.cc:2:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>' 1 | #include <cstdio> +++ |+#include <set> 2 | using namespace std; a.cc:30:11: error: 'cout' was not declared in this scope 30 | cout << '1'; | ^~~~ a.cc:30:11: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:33:11: error: 'cout' was not declared in this scope 33 | cout << '0' ; | ^~~~ a.cc:33:11: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:36:7: error: 'seg' was not declared in this scope 36 | seg = set[num]; | ^~~ a.cc:36:13: error: 'set' was not declared in this scope 36 | seg = set[num]; | ^~~ a.cc:36:13: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>' a.cc:37:7: error: 'cout' was not declared in this scope 37 | cout << endl; | ^~~~ a.cc:37:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:37:15: error: 'endl' was not declared in this scope 37 | cout << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <cstdio> +++ |+#include <ostream> 2 | using namespace std; a.cc:40:5: error: 'seg' was not declared in this scope 40 | seg = "0000000"; // セグメントを0のに初期化 | ^~~
s149114582
p00229
Java
import java.util.Scanner; public class Mai { /** * @param args */ public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(true){ int coin=100; int b = cin.nextInt(); int r = cin.nextInt(); int g = cin.nextInt(); int c = cin.nextInt(); int s = cin.nextInt(); int t = cin.nextInt(); if(b+r+g+c+s+t==0){ break; } t = t-b*5-r*3; int bonusGame=b*5+r*3; for(int i =0; i < bonusGame;i++){ coin+=13; } for(int i = 0; i < b;i++){ coin+=12; } for(int i = 0; i < r;i++){ coin+=12; } for(int i = 0; i < g;i++){ coin+=4; } for(int i = 0; i < c;i++){ coin-=1; } t = t-b-r-g-c-s; coin -= t*3; System.out.println(coin); } } }
Main.java:3: error: class Mai is public, should be declared in a file named Mai.java public class Mai { ^ 1 error
s071626570
p00229
C
main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);}
main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} | ^~~~ main.c: In function 'main': main.c:1:1: error: type of 'b' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'r' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'g' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 's' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 't' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} main.c:1:24: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} | ^~~~~ main.c:1:24: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:66: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} | ^~~~~~ main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:66: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:126: error: expected statement before ')' token 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} | ^ main.c:1:128: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} main.c:1:128: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*77+r*51+g*4-c-3*t+18*b+3*r+3*g+3*c+3*s)));exit(0);} | ^~~~ main.c:1:128: note: include '<stdlib.h>' or provide a declaration of 'exit'
s352724972
p00229
C
main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);}
main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} | ^~~~ main.c: In function 'main': main.c:1:1: error: type of 'b' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'r' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'g' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 's' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 't' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} main.c:1:24: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} | ^~~~~ main.c:1:24: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:66: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} | ^~~~~~ main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:66: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:117: error: expected statement before ')' token 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} | ^ main.c:1:119: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} main.c:1:119: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s)));exit(0);} | ^~~~ main.c:1:119: note: include '<stdlib.h>' or provide a declaration of 'exit'
s198208904
p00229
C
#include <stdio.h> main(){for(int b,r,g,c,s,t;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r));}
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int] 2 | main(){for(int b,r,g,c,s,t;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r));} | ^~~~
s315198560
p00229
C
b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))}
main.c:1:1: warning: data definition has no type or storage class 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int] main.c:1:3: error: type defaults to 'int' in declaration of 'r' [-Wimplicit-int] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^ main.c:1:5: error: type defaults to 'int' in declaration of 'g' [-Wimplicit-int] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^ main.c:1:7: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^ main.c:1:9: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^ main.c:1:11: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^ main.c:1:13: error: return type defaults to 'int' [-Wimplicit-int] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^~~~ main.c: In function 'main': main.c:1:25: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} main.c:1:25: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^~~~~ main.c:1:25: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:67: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^~~~~~ main.c:1:67: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:67: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:67: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:112: error: expected expression before '}' token 1 | b,r,g,c,s,t;main(){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+3*s-3*t+2*c+g*7+95*b+63*r))} | ^
s445444498
p00229
C++
#include<stdio.h> int main(void){ int b,r,g,c,s,t; while(scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),b+r+g+c+s+t){ point=100; point+=(b*6+r*4)*15+g*7+c*2+s*3; point-=(b*5+r*3)*2+(t-b*5-r*3)*3; printf("%d\n",point); } return 0;}
a.cc: In function 'int main()': a.cc:6:1: error: 'point' was not declared in this scope; did you mean 'printf'? 6 | point=100; | ^~~~~ | printf
s523383641
p00229
C++
main(b,r,g,c,s,t){ for(;~scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t)&&t;)printf("%d\n",b*95+r*63+g*7+c*2+s*3-t*3+100); }
a.cc:1:5: error: expected constructor, destructor, or type conversion before '(' token 1 | main(b,r,g,c,s,t){ | ^
s425558731
p00229
C++
main(b,r,g,c,s,t){ for(;~scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t)&&t;)printf("%d\n",b*95+r*63+g*7-c+(s+c-t)*3+100); }
a.cc:1:5: error: expected constructor, destructor, or type conversion before '(' token 1 | main(b,r,g,c,s,t){ | ^
s883141558
p00229
C++
b,r,g,c,s; main(t){ for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;) printf("%d\n",100-(t-s)*3+c*2+g*7+95*b+63*r);return 0; }
a.cc:1:1: error: 'b' does not name a type 1 | b,r,g,c,s; | ^ a.cc:2:5: error: expected constructor, destructor, or type conversion before '(' token 2 | main(t){ | ^
s504474884
p00229
C++
b,r,g,c,s;main(t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100-(t-s)*3+c*2+g*7+95*b+63*r));}
a.cc:1:1: error: 'b' does not name a type 1 | b,r,g,c,s;main(t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100-(t-s)*3+c*2+g*7+95*b+63*r));} | ^ a.cc:1:15: error: expected constructor, destructor, or type conversion before '(' token 1 | b,r,g,c,s;main(t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100-(t-s)*3+c*2+g*7+95*b+63*r));} | ^
s929462899
p00230
C
#include <iostream> #include <deque> #include <algorithm> using namespace std; struct Node { int bid, floor, jump; Node(int b, int f, int j) { bid = b; floor = f; jump = j; } }; int main() { int B[2][100], i, j, n, f, b, c; bool visited[2][100]; deque<Node*> q; Node *node; while (cin) { cin >> n; if (n == 0) break; for (i = 0; i < 2; i++) { for (j = 0; j < n; j++) { cin >> B[i][j]; visited[i][j] = false; } } q.clear(); for (i = 0; i < 2; i++) { f = 0; if (B[i][f] == 1) { while (B[i][f+1] == 1) f++; } node = new Node(i, f, 0); q.push_back(node); } while (!q.empty()) { node = q.front(); q.pop_front(); if (visited[node->bid][node->floor]) continue; visited[node->bid][node->floor] = true; for (i = 0; i <= 2; i++) { f = node->floor + i; b = node->bid ^ 1; c = node->jump + 1; switch (B[b][f]) { case 1: while (B[b][f+1] == 1) f++; break; case 2: while (B[b][f] == 2) f--; break; } if (f == n - 1) { cout << c << endl; goto NEXT; } if (visited[b][f]) continue; q.push_back(new Node(b, f, c)); } } cout << "NA" << endl; NEXT:; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s180905847
p00230
C
char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;}
main.c:1:18: warning: data definition has no type or storage class 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^ main.c:1:18: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int] main.c:1:20: error: type defaults to 'int' in declaration of 'm' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^ main.c:1:22: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^ main.c:1:24: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^ main.c:1:26: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^ main.c:1:28: error: return type defaults to 'int' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^~~~ main.c: In function 'main': main.c:1:28: error: type of 's' defaults to 'int' [-Wimplicit-int] main.c:1:43: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} main.c:1:43: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^~~~~ main.c:1:43: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:80: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^~~~~~ main.c:1:80: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:80: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:80: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:151: error: invalid type argument of unary '*' (have 'int') 1 | char*z,a[2][204];n,m,i,c,p;main(s){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],s=*p,c<m&&!s|n+~p;)p+=p<n&&s?~s|z[2]-49?++c,2:1:-1;} | ^~
s004418242
p00230
C
char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;}
main.c:1:18: warning: data definition has no type or storage class 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^ main.c:1:18: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int] main.c:1:20: error: type defaults to 'int' in declaration of 'm' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^ main.c:1:22: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^ main.c:1:24: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^ main.c:1:26: error: return type defaults to 'int' [-Wimplicit-int] 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^~~~ main.c: In function 'main': main.c:1:26: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:41: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} main.c:1:41: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^~~~~ main.c:1:41: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:78: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^~~~~~ main.c:1:78: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:78: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:78: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:172: error: invalid operands to binary & (have 'char *' and 'int') 1 | char*z,a[2][204];n,m,i,p;main(c){for(;m=scanf("%d %[^\n] %[^\n]",&n,a,a+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=p=0;z=p+p+a[c+i&1],c<m&&*z&2|n+~p;)p+=p==n|z&2?-1:*z&1|z[2]&1?1:!++c+2;} | ^
s264782383
p00230
C
#include<stdio.h> int a[2][100]; int su; int dfs(int building,int level,int count){ int ret_a=200,ret_b=200,ret_c=200,ret_d=200; if(count>su*2 || level>su+1) return 200; if(a[building][level+1]==1) ret_a=dfs(building,level+1,count+1); else if(su==level-1) return -1; else if(a[building][level]==2) ret_b=dfs(building,level-1,count+1); else{ ret_c=dfs((building+1)%2,level+2,count+1)+1; ret_d=dfs((building+1)%2,level+1,count+1)+1; } if(ret_a<ret_b) ret_b=ret_a; if(ret_c<ret_d) ret_d=ret_c; if(ret_b<ret_d) return ret_b; else return ret_d; } } int main(){ int i,building,ret; while(1){ building=0; scanf("%d",&su); if(su==0) break; for(i=0;i<su;i++) scanf("%d",&a[0][i]); for(i=0;i<su;i++) scanf("%d",&a[1][i]); if(a[1][0]==1) building=1; ret=dfs(building,0,0); if(ret>=200) printf("NA\n"); else printf("%d\n",ret); } return 0; }
main.c:21:1: error: expected identifier or '(' before '}' token 21 | } | ^
s159860218
p00230
C++
#include <iostream> #include <vector> #include <queue> #include <map> #include <algorithm> #define fr first #define sc second #define INF (2 << 28) using namespace std; typedef pair<int, int> iiP; int n, mas[2][101]; int used[2][101]; int dy[] = {0, 1, 2}; int bfs(int sy, int sx){ queue <iiP> que; que.push(iiP(sx, sy)); memset(used, 0, sizeof(used)); used[sy][sx] = 0; while(!que.empty()){ iiP p = que.front(); que.pop(); if(p.fr == n-1 && mas[p.sc][p.fr] != 2) return used[p.sc][p.fr] + 1; if(mas[p.sc][p.fr] == 1){ for(int i = 1;; i++){ if(mas[p.sc][p.fr+i] != 1){ for(int j = 0; j < 3; j++){ if(p.fr+i - 1 + dy[j] < n && p.sc == 0 && used[1][p.fr+i - 1 + dy[j]] == 0){ que.push(iiP(p.fr+i - 1 + dy[j], 1)); used[1][p.fr+i - 1 + dy[j]] = used[p.sc][p.fr] + 1; } else if(p.fr+i - 1 + dy[j] < n && used[0][p.fr+i - 1 + dy[j]] == 0){ que.push(iiP(p.fr+i - 1 + dy[j], 0)); used[0][p.fr+i - 1 + dy[j]] = used[p.sc][p.fr] + 1; } } break; } } } else if(mas[p.sc][p.fr] == 0){ for(int i = 0; i < 3; i++){ if(p.fr + dy[i] < n && p.sc == 0 && used[1][p.fr + dy[i]] == 0){ que.push(iiP(p.fr + dy[i], 1)); used[1][p.fr + dy[i]] = used[p.sc][p.fr] + 1; } else if(p.fr + dy[i] < n && used[0][p.fr + dy[i]] == 0){ que.push(iiP(p.fr + dy[i], 0)); used[0][p.fr + dy[i]] = used[p.sc][p.fr] + 1; } } } else{ for(;;){ if(mas[p.sc][--p.fr] != 2) break; } que.push(iiP(p.fr, p.sc)); } } return INF; } int main(){ while(cin >> n, n){ for(int i = 0; i < 2; i++){ for(int j = 0; j < n; j++) cin >> mas[i][j]; } int ans = min(bfs(0, 0), bfs(1, 0)); if(ans == INF) cout << "NA" << endl; else cout << ans << endl; } }
a.cc: In function 'int bfs(int, int)': a.cc:21:3: error: 'memset' was not declared in this scope 21 | memset(used, 0, sizeof(used)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <algorithm> +++ |+#include <cstring> 6 | #define fr first
s504866545
p00230
C++
#include <iostream> #include <cstring> #include <vector> #include <queue> #include <map> #include <algorithm> #define fr first #define sc second #define INF (2 << 28) using namespace std; typedef pair<int, int> iiP; int n, mas[2][101]; int used[2][101]; int dy[] = {0, 1, 2}; int bfs(int sy, int sx){ queue <iiP> que; que.push(iiP(sx, sy)); memset(used, 0, sizeof(used)); used[sy][sx] = 0; while(!que.empty()){ iiP p = que.front(); que.pop(); //cout << p.sc << " " << p.fr << endl; if(p.fr == n-1 && mas[p.sc][p.fr] != 2) return used[p.sc][p.fr]; if(mas[p.sc][p.fr] == 1){ for(int i = 1;; i++){ if(mas[p.sc][p.fr+i] != 1){ for(int j = 0; j < 3; j++){ if(p.fr+i - 1 + dy[j] < n && p.sc == 0 && used[1][p.fr+i - 1 + dy[j]] == 0){ que.push(iiP(p.fr+i - 1 + dy[j], 1)); used[1][p.fr+i - 1 + dy[j]] = used[p.sc][p.fr] + 1; } else if(p.fr+i - 1 + dy[j] < n && used[0][p.fr+i - 1 + dy[j]] == 0){ que.push(iiP(p.fr+i - 1 + dy[j], 0)); used[0][p.fr+i - 1 + dy[j]] = used[p.sc][p.fr] + 1; } } break; } } } else if(mas[p.sc][p.fr] == 0){ for(int i = 0; i < 3; i++){ if(p.fr + dy[i] < n && p.sc == 0 && used[1][p.fr + dy[i]] == 0){ que.push(iiP(p.fr + dy[i], 1)); used[1][p.fr + dy[i]] = used[p.sc][p.fr] + 1; } else if(p.fr + dy[i] < n && used[0][p.fr + dy[i]] == 0){ que.push(iiP(p.fr + dy[i], 0)); used[0][p.fr + dy[i]] = used[p.sc][p.fr] + 1; } } } else{ for(int i = 1;;i++){ if(mas[p.sc][p.fr - i] != 2){ que.push(iiP(p.fr - i, p.sc)); used[p.sc][p.fr - i] = used[p.sc][p.fr]; break; } } } } return INF; } int main(){ while(cin >> n, n){ for(int i = 0; i < 2; i++){ for(int j = 0; j < n; j++) cin >> mas[i][j]; } int ans = min(bfs(0, 0), bfs(1, 0)); if(ans == INF) cout << "NA" << endl; else cout << ans << endl; }
a.cc: In function 'int main()': a.cc:84:4: error: expected '}' at end of input 84 | } | ^ a.cc:73:11: note: to match this '{' 73 | int main(){ | ^
s191103752
p00230
C++
#include <queue> #include <cstdio> int n, a[100], b[100], d[100][2]; int main() { while(scanf("%d", &n), n) { for(int i = 0; i < n; i++) scanf("%d", &a[i]); for(int i = 0; i < n; i++) scanf("%d", &b[i]); for(int i = 1; i < n; i++) d[i][0] = -1, d[i][1] = -1; d[0][0] = 0, d[0][1] = 0; queue<int> que; que.push(0); que.push(1); while(!que.empty()) { int x = que.top() / 2, y = que.top() % 2; que.pop(); for(int i = 0; i <= 2 && x + i < n; i++) { if(y == 1) { int tx = x + i; if(a[tx] == 1) { for(; tx + 1 < n; tx++) { if(a[tx + 1] != 1) break; } } else if(a[tx] == 2) { for(; tx - 1 > 0; tx--) { if(a[tx - 1] != 2) break; } } if(d[tx][0] > d[x][y] + 1) { d[tx][0] = d[x][y] + 1; que.push_back(make_pair(tx * 2)); } } else { int tx = x + i; if(b[tx] == 1) { for(; tx + 1 < n; tx++) { if(b[tx + 1] != 1) break; } } else if(b[tx] == 2) { for(; tx - 1 > 0; tx--) { if(b[tx - 1] != 2) break; } } if(d[tx][1] == -1) { d[tx][1] = d[x][y] + 1; que.push_back(make_pair(tx * 2 + 1)); } } } } int r = min(d[n - 1][0], d[n - 1][1]); if(r == -1) printf("NA\n"); else printf("%d\n", r); } return 0; }
a.cc: In function 'int main()': a.cc:10:17: error: 'queue' was not declared in this scope; did you mean 'std::queue'? 10 | queue<int> que; que.push(0); que.push(1); | ^~~~~ | std::queue In file included from /usr/include/c++/14/queue:66, from a.cc:1: /usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here 96 | class queue | ^~~~~ a.cc:10:23: error: expected primary-expression before 'int' 10 | queue<int> que; que.push(0); que.push(1); | ^~~ a.cc:10:33: error: 'que' was not declared in this scope 10 | queue<int> que; que.push(0); que.push(1); | ^~~ a.cc:14:36: error: 'y' was not declared in this scope 14 | if(y == 1) { | ^ a.cc:28:63: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 28 | que.push_back(make_pair(tx * 2)); | ^~~~~~~~~ | std::make_pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/deque:62, from /usr/include/c++/14/queue:62: /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:45:63: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 45 | que.push_back(make_pair(tx * 2 + 1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:50:25: error: 'min' was not declared in this scope; did you mean 'std::min'? 50 | int r = min(d[n - 1][0], d[n - 1][1]); | ^~~ | std::min /usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~
s006628068
p00230
C++
#include <queue> #include <cstdio> #include <algorithm> using namespace std; int n, a[100], b[100], d[100][2]; int main() { while(scanf("%d", &n), n) { for(int i = 0; i < n; i++) scanf("%d", &a[i]); for(int i = 0; i < n; i++) scanf("%d", &b[i]); for(int i = 1; i < n; i++) d[i][0] = -1, d[i][1] = -1; d[0][0] = 0, d[0][1] = 0; queue<int> que; que.push(0); que.push(1); while(!que.empty()) { int x = que.top() / 2, y = que.top() % 2; que.pop(); for(int i = 0; i <= 2 && x + i < n; i++) { if(y == 1) { int tx = x + i; if(a[tx] == 1) { for(; tx + 1 < n; tx++) { if(a[tx + 1] != 1) break; } } else if(a[tx] == 2) { for(; tx - 1 > 0; tx--) { if(a[tx - 1] != 2) break; } } if(d[tx][0] > d[x][y] + 1) { d[tx][0] = d[x][y] + 1; que.push_back(make_pair(tx * 2)); } } else { int tx = x + i; if(b[tx] == 1) { for(; tx + 1 < n; tx++) { if(b[tx + 1] != 1) break; } } else if(b[tx] == 2) { for(; tx - 1 > 0; tx--) { if(b[tx - 1] != 2) break; } } if(d[tx][1] == -1) { d[tx][1] = d[x][y] + 1; que.push_back(make_pair(tx * 2 + 1)); } } } } int r = min(d[n - 1][0], d[n - 1][1]); if(r == -1) printf("NA\n"); else printf("%d\n", r); } return 0; }
a.cc: In function 'int main()': a.cc:14:37: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'? 14 | int x = que.top() / 2, y = que.top() % 2; que.pop(); | ^~~ | pop a.cc:16:36: error: 'y' was not declared in this scope 16 | if(y == 1) { | ^ a.cc:30:53: error: 'class std::queue<int>' has no member named 'push_back' 30 | que.push_back(make_pair(tx * 2)); | ^~~~~~~~~ a.cc:30:72: error: no matching function for call to 'make_pair(int)' 30 | que.push_back(make_pair(tx * 2)); | ~~~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/deque:62, from /usr/include/c++/14/queue:62, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)' 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate expects 2 arguments, 1 provided a.cc:47:53: error: 'class std::queue<int>' has no member named 'push_back' 47 | que.push_back(make_pair(tx * 2 + 1)); | ^~~~~~~~~ a.cc:47:72: error: no matching function for call to 'make_pair(int)' 47 | que.push_back(make_pair(tx * 2 + 1)); | ~~~~~~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)' 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate expects 2 arguments, 1 provided
s834390139
p00230
C++
#include <queue> #include <cstdio> #include <algorithm> using namespace std; int n, a[100], b[100], d[100][2]; int main() { while(scanf("%d", &n), n) { for(int i = 0; i < n; i++) scanf("%d", &a[i]); for(int i = 0; i < n; i++) scanf("%d", &b[i]); for(int i = 1; i < n; i++) d[i][0] = -1, d[i][1] = -1; d[0][0] = 0, d[0][1] = 0; queue<int> que; que.push(0); que.push(1); while(!que.empty()) { int x = que.front() / 2, y = que.front() % 2; que.pop(); for(int i = 0; i <= 2 && x + i < n; i++) { if(y == 1) { int tx = x + i; if(a[tx] == 1) { for(; tx + 1 < n; tx++) { if(a[tx + 1] != 1) break; } } else if(a[tx] == 2) { for(; tx - 1 > 0; tx--) { if(a[tx - 1] != 2) break; } } if(d[tx][0] > d[x][y] + 1) { d[tx][0] = d[x][y] + 1; que.push_back(make_pair(tx * 2)); } } else { int tx = x + i; if(b[tx] == 1) { for(; tx + 1 < n; tx++) { if(b[tx + 1] != 1) break; } } else if(b[tx] == 2) { for(; tx - 1 > 0; tx--) { if(b[tx - 1] != 2) break; } } if(d[tx][1] == -1) { d[tx][1] = d[x][y] + 1; que.push_back(make_pair(tx * 2 + 1)); } } } } int r = min(d[n - 1][0], d[n - 1][1]); if(r == -1) printf("NA\n"); else printf("%d\n", r); } return 0; }
a.cc: In function 'int main()': a.cc:30:53: error: 'class std::queue<int>' has no member named 'push_back' 30 | que.push_back(make_pair(tx * 2)); | ^~~~~~~~~ a.cc:30:72: error: no matching function for call to 'make_pair(int)' 30 | que.push_back(make_pair(tx * 2)); | ~~~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/deque:62, from /usr/include/c++/14/queue:62, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)' 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate expects 2 arguments, 1 provided a.cc:47:53: error: 'class std::queue<int>' has no member named 'push_back' 47 | que.push_back(make_pair(tx * 2 + 1)); | ^~~~~~~~~ a.cc:47:72: error: no matching function for call to 'make_pair(int)' 47 | que.push_back(make_pair(tx * 2 + 1)); | ~~~~~~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)' 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate expects 2 arguments, 1 provided
s903453049
p00230
C++
#include <queue> #include <cstdio> #include <algorithm> using namespace std; int n, a[100], b[100], d[100][2]; int main() { while(scanf("%d", &n), n) { for(int i = 0; i < n; i++) scanf("%d", &a[i]); for(int i = 0; i < n; i++) scanf("%d", &b[i]); for(int i = 1; i < n; i++) d[i][0] = -1, d[i][1] = -1; d[0][0] = 0, d[0][1] = 0; queue<int> que; que.push(0); que.push(1); while(!que.empty()) { int x = que.front() / 2, y = que.front() % 2; que.pop(); for(int i = 0; i <= 2 && x + i < n; i++) { if(y == 1) { int tx = x + i; if(a[tx] == 1) { for(; tx + 1 < n; tx++) { if(a[tx + 1] != 1) break; } } else if(a[tx] == 2) { for(; tx - 1 > 0; tx--) { if(a[tx - 1] != 2) break; } } if(d[tx][0] > d[x][y] + 1) { d[tx][0] = d[x][y] + 1; que.push(make_pair(tx * 2)); } } else { int tx = x + i; if(b[tx] == 1) { for(; tx + 1 < n; tx++) { if(b[tx + 1] != 1) break; } } else if(b[tx] == 2) { for(; tx - 1 > 0; tx--) { if(b[tx - 1] != 2) break; } } if(d[tx][1] == -1) { d[tx][1] = d[x][y] + 1; que.push(make_pair(tx * 2 + 1)); } } } } int r = min(d[n - 1][0], d[n - 1][1]); if(r == -1) printf("NA\n"); else printf("%d\n", r); } return 0; }
a.cc: In function 'int main()': a.cc:30:67: error: no matching function for call to 'make_pair(int)' 30 | que.push(make_pair(tx * 2)); | ~~~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/deque:62, from /usr/include/c++/14/queue:62, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)' 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate expects 2 arguments, 1 provided a.cc:47:67: error: no matching function for call to 'make_pair(int)' 47 | que.push(make_pair(tx * 2 + 1)); | ~~~~~~~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)' 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1132:5: note: candidate expects 2 arguments, 1 provided
s546898401
p00230
C++
#include<iostream> #include<cstdio> #include<queue> #define P pair<int,int> using namespace std; int n[101], m[101], l[2][100], s[2][100], k[2] = { 1,0 }; int main() { int a; while (cin >> a, a) { memset(n, -1, sizeof(n)); memset(m, -1, sizeof(m)); memset(s, -1, sizeof(s)); for (int b = 0; b < a; b++)cin >> n[b]; for (int b = 0; b < a; b++)cin >> m[b]; int xMAX, yMAX = 0; for (int i = 0; i < a; i++) { switch (n[i]) { case 0: xMAX = i; break; case 2: l[0][i] = xMAX; } switch (m[i]) { case 0: yMAX = i; break; case 2: l[1][i] = yMAX; } } xMAX = yMAX = a + 5; for (int i = a - 1; i >= 0; i--) { switch (n[i]) { case 0: l[0][i] = i; break; case 1: if (n[i + 1] != 1)xMAX = i; l[0][i] = xMAX; } switch (m[i]) { case 0: l[1][i] = i; break; case 1: if (m[i + 1] != 1)yMAX = i; l[1][i] = yMAX; } } queue<P>Q; Q.push(P(0, l[0][0])); Q.push(P(1, l[1][0])); s[0][l[0][0]] = s[1][l[1][0]] = 0; while (Q.size()) { P o = Q.front(); Q.pop(); for (int i = 0; i <= 2; i++) { if (o.second + i < a&&s[k[o.first]][l[k[o.first]][o.second + i]] == -1) { s[k[o.first]][l[k[o.first]][o.second + i]] = s[o.first][o.second] + 1; Q.push(P(k[o.first], l[k[o.first]][o.second + i])); } } } for (int p = a - 1; p != -1; p--) { cout << s[0][p] << " " << s[1][p] << endl; } if (s[0][a - 1] == -1 && s[1][a - 1] == -1)puts("NA"); else if (s[0][a - 1] != -1 && s[1][a - 1] != -1)cout << min(s[0][a - 1], s[1][a - 1]) << endl; else cout << max(s[0][a - 1], s[1][a - 1]) << endl; } }
a.cc: In function 'int main()': a.cc:11:17: error: 'memset' was not declared in this scope 11 | memset(n, -1, sizeof(n)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<queue> +++ |+#include <cstring> 4 | #define P pair<int,int>
s633531348
p00230
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<stack> #include<functional> #include<list> #include<map> #include<unordered_map> #define P pair<int,int> using namespace std; int main() { int a; while (cin >> a, a) { int n[105], m[105], l[2][105], s[2][105], k[2] = { 1,0 }; memset(s, -1, sizeof(s)); for (int b = 0; b < a; b++)cin >> n[b]; for (int b = 0; b < a; b++)cin >> m[b]; int xMAX = 0, yMAX = 0; for (int i = 0; i < a; i++) { switch (n[i]) { case 2: l[0][i] = xMAX; break; default: xMAX = i; break; } switch (m[i]) { case 2: l[1][i] = yMAX; break; default: yMAX = i; break; } } xMAX = yMAX = a + 5; for (int i = a - 1; i >= 0; i--) { switch (n[i]) { case 0: l[0][i] = i; break; case 1: if (n[i + 1] != 1)xMAX = i; l[0][i] = xMAX; } switch (m[i]) { case 0: l[1][i] = i; break; case 1: if (m[i + 1] != 1)yMAX = i; l[1][i] = yMAX; } } queue<P>Q; Q.push(P(0, l[0][0])); Q.push(P(1, l[1][0])); s[0][l[0][0]] = s[1][l[1][0]] = 0; while (Q.size()) { P o = Q.front(); Q.pop(); if (o.second >= a - 1) { cout << s[o.first][o.second] << endl; goto m; } for (int i = 0; i <= 2; i++) { if (o.second + i < a&&s[k[o.first]][l[k[o.first]][o.second + i]] == -1) { s[k[o.first]][l[k[o.first]][o.second + i]] = s[o.first][o.second] + 1; Q.push(P(k[o.first], l[k[o.first]][o.second + i])); } } } puts("NA"); m:; } }
a.cc: In function 'int main()': a.cc:20:17: error: 'memset' was not declared in this scope 20 | memset(s, -1, sizeof(s)); | ^~~~~~ a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 11 | #include<map> +++ |+#include <cstring> 12 | #include<unordered_map>
s137028463
p00230
C++
#include<queue> #include<iostream> typedef unsigned long long ull; typedef pair<ull,ull> UL2; typedef pair<UL2,UL2> ULUL; typedef pair<ULUL,ULUL> ULMAX; using namespace std; int main(){ int n; int r[110],l[110]; cin >> n; for(int i=0;i<n;i++)cin >> r[i]; for(int j=0;j<n;j++)cin >> l[j]; queue<ULMAX> que; while(true){ que.push(ULMAX(ULUL(UL2(10000000,11000000),UL2(1222222,41241242)),ULUL(UL2(421412421,4122412),UL2(2222,112241)))); } return 0; }
a.cc:4:9: error: 'pair' does not name a type 4 | typedef pair<ull,ull> UL2; | ^~~~ a.cc:5:9: error: 'pair' does not name a type 5 | typedef pair<UL2,UL2> ULUL; | ^~~~ a.cc:6:9: error: 'pair' does not name a type 6 | typedef pair<ULUL,ULUL> ULMAX; | ^~~~ a.cc: In function 'int main()': a.cc:17:7: error: 'ULMAX' was not declared in this scope; did you mean 'ELIBMAX'? 17 | queue<ULMAX> que; | ^~~~~ | ELIBMAX a.cc:17:12: error: template argument 1 is invalid 17 | queue<ULMAX> que; | ^ a.cc:17:12: error: template argument 2 is invalid a.cc:19:5: error: request for member 'push' in 'que', which is of non-class type 'int' 19 | que.push(ULMAX(ULUL(UL2(10000000,11000000),UL2(1222222,41241242)),ULUL(UL2(421412421,4122412),UL2(2222,112241)))); | ^~~~ a.cc:19:21: error: 'UL2' was not declared in this scope 19 | que.push(ULMAX(ULUL(UL2(10000000,11000000),UL2(1222222,41241242)),ULUL(UL2(421412421,4122412),UL2(2222,112241)))); | ^~~ a.cc:19:16: error: 'ULUL' was not declared in this scope 19 | que.push(ULMAX(ULUL(UL2(10000000,11000000),UL2(1222222,41241242)),ULUL(UL2(421412421,4122412),UL2(2222,112241)))); | ^~~~
s894513434
p00230
C++
#include<iostream> #include<cassert> #include<ctime> #include<climits> #include<queue> #include<fstream> #include<deque> #include<iomanip> #include<list> #include<stack> #include<sstream> #include<string> #include<cctype> #include<cstdio> #include<vector> #include<cmath> #include<cstdlib> #include<algorithm> #include<cstring> #include<map> #include<set> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) #define EPS 1e-10 #define F first #define S second #define all(n) n.begin(),n.end() #define pb push_back #define insert(a,b,c,d) PP(P(a,b),P(c,d)) #define INF (1<<27) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> P; typedef pair<P,P> PP; const int dx[4] = {0,1,0,-1}; const int dy[4] = {1,0,-1,0}; const int dir[3] = {0,1,2}; const int DRAW = 100000; class AOJ0230{ private: int n; int **imap; int d[110][2]; public: AOJ0230(int n,int **F):n(n){ imap = new int*[n+1]; rep(i,n)imap[i] = new int[2]; rep(i,n)imap[i][0] = *(*(F+i)); rep(i,n)*(*(imap+i)+1) = *(*(F+i)+1); rep(i,n){ //if(imap[i][0] == 1)d[i][0] = -1,d[i][1] = DRAW; //else if(imap[i][1] == 1)d[i][1] = -1,d[i][0] = DRAW; //else if(imap[i][0] == 2)d[i][0] = -1,d[i][1] = DRAW; //else if(imap[i][1] == 2)d[i][1] = -1,d[i][0] = DRAW; /*else*/ d[i][0] = d[i][1] = DRAW; } } ~AOJ0230(){ delete [] imap[0]; delete [] imap; } int getPos(int np,int lorr){ // cout << "GET! np = "<< np << ", lorr = " << lorr << ", mpa = " << imap[np][lorr] << endl; if(imap[np][lorr] == 1){ for(int i=np;i<n && imap[i][lorr] == 1;i++,np++){} if(np > n-1)np = n-1; } else if(imap[np][lorr] == 2){ for(int i=np;i>=0 && imap[i][lorr] == 2;i--,np--){} //cout << "np = " << np << endl; if(np < 0)np = 0; else if(imap[np][lorr] == 1)np++; } if(np > n-1)return -1; else return np; } void run(){ queue<P> que; que.push(P(0,0)); // P(L or R,pos) L or R: 0 -> left, 1 -> right que.push(P(1,0)); d[0][0] = d[0][1] = 1; bool arrived = false; while(!que.empty()){ P p = que.front(); que.pop(); //cout << "p.info = " << p.F << "," << p.S << endl; assert(p.S <= n-1); if(p.S == n-1){ int lorr = p.F==1?0:1; //cout << "GET ANSWER!!! " << d[n-1][lorr] << endl; arrived = true; continue; } int lorr = p.F == 1?0:1; rep(i,3){ if(p.S+dir[i] > n-1)continue; //cout << "pre-position = "<< p.S << " to "; int np = getPos(p.S+dir[i],lorr); //cout << np << ", d["<<np<<"]["<<lorr<<"] = " << d[np][lorr] << ",pre-d["<<p.S<<"]["<<p.F<<"] = "<< d[p.S][p.F] << endl << endl; if(np == -1)continue; if(d[np][lorr] < d[p.S][p.F]+1)continue; d[np][lorr] = d[p.S][p.F]+1; //cout << "ARRIVED! d[" << np << "][" << lorr <<"] = " << d[np][lorr] << endl << endl; que.push(P(lorr,np)); } } if(!arrived)cout << "NA" << endl; else cout << min(d[n-1][0],d[n-1][1]) << endl; } void print(){ cout << endl << "left - imap ###" << endl; rep(i,n) cout << *(*(imap+i)) << ' '; cout << endl; cout << "right - imap ###" << endl; rep(i,n) cout << *(*(imap+i)+1) << ' '; cout << endl; } }; int main(){ int N; while(cin >> N && N){ int **inputs; inputs = new int*[N]; rep(i,N)inputs[i] = new int[2]; rep(i,N)cin >> inputs[i][0]; rep(i,N)cin >> inputs[i][1]; cerr << N << endl; rep(i,N)cerr << inputs[i][0] << ' '; cerr << endl; rep(i,N)cerr << inputs[i][1] << ' '; cerr << endl; //AOJ0230 ans = AOJ0230(N,inputs); delete [] inputs[0]; delete [] inputs; //cout << ans.getPos(2,1) << endl; ans.run(); } return 0; }
a.cc: In function 'int main()': a.cc:164:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 164 | ans.run(); | ^~~ | abs
s812142032
p00230
C++
#include<cstdio> #include<map> #include<queue> #include<algorithm> #define INF (1<<25) using namespace std; int buil[2][105], shortest[2][105]; int dfs(int a, int b){ if(b == 0)return shortest[a][b] = 1; if(b < n - 1 && buil[a][b] == 1 && buil[a][b + 1] == 1)return shortest[a][b] = INF - 1; if(buil[a][b] == 2)return shortest[a][b] = INF - 1; if(shortest[a][b] != INF)return shortest[a][b]; for(int i = 0;i <= 2 && b - i >= 0;i++){ } } int main(){ int n; while(true){ scanf("%d", &n); if(n == 0)return 0; for(int j = 0;j < 2;j++){ for(int i = 0;i < n;i++){ scanf("%d", &buil[j][i]); shortest[j][i] = INF; } } queue<pair<int, int> > q; if(buil[0][0] != 2){ int tmp = 0; while(buil[0][tmp + 1] == 1)tmp++; q.push(make_pair(0,tmp)); shortest[0][tmp] = 1; } if(buil[1][0] != 2){ int tmp = 0; while(buil[1][tmp + 1] == 1)tmp++; q.push(make_pair(1,tmp)); shortest[1][tmp] = 1; } int time = 1; while(!q.empty()){ time++; int len = q.size(); while(len--){ int l = q.front().first, r = q.front().second; q.pop(); for(int i = 0;i <= 2 && r + i < n;i++){ int tmpr = r + i; if(buil[1 - l][tmpr] == 1) while(tmpr + 1 < n && buil[1 - l][tmpr + 1] == 1)tmpr++; while(tmpr >= 0 && buil[1 - l][tmpr] == 2)tmpr--; if(shortest[1 - l][tmpr] != INF)continue; if(tmpr == -1)continue; shortest[1 - l][tmpr] = time; q.push(make_pair(1 - l, tmpr)); } } if(shortest[0][n - 1] != INF || shortest[1][n - 1] != INF)break; } if(shortest[0][n - 1] !=INF || shortest[1][n - 1] != INF) printf("%d\n", time - 1); else puts("NA"); } }
a.cc: In function 'int dfs(int, int)': a.cc:12:10: error: 'n' was not declared in this scope 12 | if(b < n - 1 && buil[a][b] == 1 && buil[a][b + 1] == 1)return shortest[a][b] = INF - 1; | ^ a.cc:17:1: warning: control reaches end of non-void function [-Wreturn-type] 17 | } | ^
s629953133
p00230
C++
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<queue> using namespace std; typedef pair<int, int> P; typedef pair<int, P> T; #define INF (1 << 30) int n, dist[2][210], window[2][210]; vector<T> edge[2][210]; bool come[2][210]; int main(){ while(cin >> n, n){ for(int j = 0;j < 2;j++){ for(int i = 0;i < n;i++){ cin >> window[j][i]; dist[j][i] = INF; come[j][i] = false; edge[j][i].clear(); } } for(int j = 0;j < 2;j++){ for(int i = 0;i < n;i++){ if(window[j][i] == 0 ||(window[j][i] == 1 && window[j][i + 1] == 0)){ for(int k = 0;k <= 2;k++){ edge[j][i].push_back(T(1, P(!j, i + k))); } } if(window[j][i + 1] == 1 && window[j][i] == 1){ edge[j][i].push_back(T(0, P(j, i + 1))); } if(window[j][i] == 2){ edge[j][i].push_back(T(0, P(j, i - 1))); } } } priority_queue<T, vector<T>, greater<T> > pq; pq.push(T(0, P(0, 0))); pq.push(T(0, P(1, 0))); dist[0][0] = dist[1][0] = 0; while(!pq.empty()){ T tmp = pq.top();pq.pop(); int d = tmp.first, x = tmp.second.first, y = tmp.second.second; come[x][y] = true; if(dist[x][y] < d)continue; for(int i = 0;i < edge[x][y].size();i++){ P to = edge[x][y][i].second; int r = edge[x][y][i].first, tx = to.first, ty = to.second; if(dist[tx][ty] <= d + r)continue; dist[tx][ty] = d + r; pq.push(T(dist[tx][ty], to)); } } //for(int i = 0;i < 2;i++,cout<<endl) for(int j = 0;j < n;j++) //cout << dist[i][j] << " "; int res = min(dist[0][n - 1], dist[1][n - 1]); if(res == INF)cout << "NA" << endl; else cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:59:12: error: 'res' was not declared in this scope 59 | if(res == INF)cout << "NA" << endl; | ^~~
s529286641
p00230
C++
#include <queue> #include <tuple> #include <cstdio> using namespace std; typedef tuple<int,int,int> tiii; //building, floor, depth int M[2][101],B[2][101]; int main(){ int n,i; for(;scanf("%d",&n),n;){ for(i=0;i<n;i++)scanf("%d",B[0]+i); for(i=0;i<n;i++)scanf("%d",B[1]+i); memset(M,99,sizeof(M)); queue<tiii> q; q.push(make_tuple(0,0,0));M[0][0]=0; q.push(make_tuple(1,0,0));M[1][0]=0; for(;!q.empty();){ tiii t=q.front();q.pop(); int building=get<0>(t); int floor=get<1>(t); int depth=get<2>(t); for(;B[building][floor]==1&&B[building][floor+1]==1;){ if(M[building][floor+1]>M[building][floor])M[building][floor+1]=M[building][floor]; floor++; } for(;B[building][floor]==2;){ if(M[building][floor-1]>M[building][floor])M[building][floor-1]=M[building][floor]; floor--; } if(floor==n-1){printf("%d\n",depth);goto success;} for(i=2;i>=0;i--)if(M[building^1][floor+i]>M[building][floor]){ M[building^1][floor+i]=M[building][floor]; q.push(make_tuple(building^1,floor+i,depth+1)); } } puts("NA");continue; success:; } }
a.cc: In function 'int main()': a.cc:12:17: error: 'memset' was not declared in this scope 12 | memset(M,99,sizeof(M)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <cstdio> +++ |+#include <cstring> 4 | using namespace std;
s189855557
p00230
C++
#include <queue> #include <tuple> #include <cstdio> using namespace std; #define SENTINEL 99999 typedef tuple<int,int,int> tiii; //building, floor, depth int M[2][101],B[2][101],n; int bfs(int i){ memset(M,99,sizeof(M)); queue<tiii> q; q.push(make_tuple(i,0,0));M[i][0]=0; for(;!q.empty();){ tiii t=q.front();q.pop(); int building=get<0>(t); int floor=get<1>(t); int depth=get<2>(t); for(;B[building][floor]==1&&B[building][floor+1]==1;){ if(M[building][floor+1]>M[building][floor])M[building][floor+1]=M[building][floor]; floor++; } for(;B[building][floor]==2;){ if(M[building][floor-1]>M[building][floor])M[building][floor-1]=M[building][floor]; floor--; } if(floor>=n-1)return depth; for(i=2;i>=0;i--)if(M[building^1][floor+i]>M[building][floor]){ M[building^1][floor+i]=M[building][floor]; q.push(make_tuple(building^1,floor+i,depth+1)); } } return SENTINEL; } int main(){ int i,j; for(;scanf("%d",&n),n;){ for(j=0;j<2;j++){ for(i=0;i<n;i++)scanf("%d",B[j]+i),M[j][i]=SENTINEL; B[j][i]=0,M[j][i]=SENTINEL; } i=min(bfs(0),bfs(1)); printf(i==SENTINEL?"NA\n":"%d\n",i); } }
a.cc: In function 'int bfs(int)': a.cc:9:17: error: 'memset' was not declared in this scope 9 | memset(M,99,sizeof(M)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <cstdio> +++ |+#include <cstring> 4 | using namespace std;
s705768286
p00231
C++
#inlcude<cstdio> using namespace std; int m[100],a[100],b[100],n; bool judge(int x){ int w=0; for(int i=0;i<n;i++) if(a[i]<=x&&b[i]>x)w+=m[i]; return w<=150; } int main(){ while(stanf("%d",&n)&&n){ for(int i=0;i<n;i++)scanf("%d%d%d",m+i,a+i,b+i); bool res=true; for(int i=0;i<n;i++)res&=judge(a[i]); for(int i=0;i<n;i++)res&=judge(b[i]); puts(res?"OK":"NG"); } return 0; }
a.cc:1:2: error: invalid preprocessing directive #inlcude; did you mean #include? 1 | #inlcude<cstdio> | ^~~~~~~ | include a.cc: In function 'int main()': a.cc:11:11: error: 'stanf' was not declared in this scope 11 | while(stanf("%d",&n)&&n){ | ^~~~~ a.cc:12:29: error: 'scanf' was not declared in this scope 12 | for(int i=0;i<n;i++)scanf("%d%d%d",m+i,a+i,b+i); | ^~~~~ a.cc:16:9: error: 'puts' was not declared in this scope 16 | puts(res?"OK":"NG"); | ^~~~
s374911017
p00231
C++
//I'm beginner. //n個の区間がある。i(>=0)個目の区間は[a, b)で重さmである。 //ある点xについて、xを含むまたはxと接する区間が151以上になるならNG, ならないならOKと出力。 //考察: //関係ない点を除く、座標圧縮をする、それだけ。 #include <iostream> #include <set> #include <map> using namespace std; int n; int m[100], a[100], b[100]; int time[2000]; void compress() { int i; set<int> comp; map<int, int> indComp; typedef pair<int, int> P; for (i = 0; i < n; i++) { comp.insert(a[i]); comp.insert(b[i]); } int ind = 0; for (set<int>::iterator it = comp.begin(); it != comp.end(); it++) { indComp.insert(P(*it, ind++) ); } for (i = 0; i < n; i++) { a[i] = indComp[a[i]]; b[i] = indComp[b[i]]; } } bool in_solve_out() { int i; cin >> n; if (!n) { return false; } for (i = 0; i < n; i++) { cin >> m[i] >> a[i] >> b[i]; } compress(); for (i = 0; i < n; i++) { time[a[i]] += m[i]; time[b[i]] -= m[i]; } for (i = 1; i < 2*n + 10; i++) { time[i] += time[i-1]; } for (i = 0; i < 2*n + 10; i++) { if (time[i] > 150) { cout << "NG" << endl; return true; } } cout << "OK" << endl; return true; } void clear() { for (int i = 0; i < n*2 + 10; i++) { time[i] = 0; } }; signed main() { while (in_solve_out() ) { clear(); } return 0; }
a.cc:13:14: error: 'int time [2000]' redeclared as different kind of entity 13 | int time[2000]; | ^ In file included 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/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:6: /usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'bool in_solve_out()': a.cc:50:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 50 | time[a[i]] += m[i]; | ^ a.cc:50:28: warning: pointer to a function used in arithmetic [-Wpointer-arith] 50 | time[a[i]] += m[i]; | ~~~~~~~~~~~^~~~~~~ a.cc:50:28: error: assignment of read-only location '*(time + ((sizetype)a[i]))' a.cc:51:26: warning: pointer to a function used in arithmetic [-Wpointer-arith] 51 | time[b[i]] -= m[i]; | ^ a.cc:51:28: warning: pointer to a function used in arithmetic [-Wpointer-arith] 51 | time[b[i]] -= m[i]; | ~~~~~~~~~~~^~~~~~~ a.cc:51:28: error: assignment of read-only location '*(time + ((sizetype)b[i]))' a.cc:54:23: warning: pointer to a function used in arithmetic [-Wpointer-arith] 54 | time[i] += time[i-1]; | ^ a.cc:54:36: warning: pointer to a function used in arithmetic [-Wpointer-arith] 54 | time[i] += time[i-1]; | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] a.cc:54:25: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to binary 'operator+' 54 | time[i] += time[i-1]; | ~~~~~~~~^~~~~~~~~~~~ a.cc:54:25: note: in evaluation of 'operator+=(time_t(time_t*) noexcept {aka long int(long int*) noexcept}, time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept})' a.cc:58:27: warning: pointer to a function used in arithmetic [-Wpointer-arith] 58 | if (time[i] > 150) { | ^ a.cc:58:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 58 | if (time[i] > 150) { | ~~~~~~~~^~~~~ a.cc: In function 'void clear()': a.cc:69:23: warning: pointer to a function used in arithmetic [-Wpointer-arith] 69 | time[i] = 0; | ^ a.cc:69:25: error: assignment of read-only location '*(time + ((sizetype)i))' 69 | time[i] = 0; | ~~~~~~~~^~~
s723284811
p00231
C++
#include<iostream> #include<vector> using namespace std; class Hito{ public: int m,a,b; hito(); void set(int mm, int aa, int bb){ m = mm; a = aa; b = bb; } }; int main() { for(;;){ int n; int m, a, b; int finTime = 0; int nowg = 0; bool flg = false; vector<Hito> data(n); cin >> n; if(n == 0){ break; } for(int i = 0;i < n; i++){ cin >> m >> a >> b; if(finTime < b){ finTime = b; } data[i].set(m,a,b); } for(int i = 0; i < finTime; i++){ for(int j = 0; j < n; j++){ //ŽžŠÔ“à‚É‹‚é if(data[j].a <= i && data[j].b > i){ nowg += data[j].m; } } // printf("%d:nowg>> %d\n",i,nowg); if(nowg > 150){ flg = true; break; } nowg = 0; } if(flg == true){ cout << "NG" << endl; } else{ cout << "OK" << endl; } } }
a.cc:9:9: error: ISO C++ forbids declaration of 'hito' with no type [-fpermissive] 9 | hito(); | ^~~~
s488150888
p00231
C++
#include <iostream> #include <vector> using namespace std; void solve() { int n; while(cin >> n, n) { vector<int> weight(n + 1); vector<int> start(n + 1); vector<int> end(n); vector<int> order_start(n + 1); vector<int> order_end(n); for(int i = 0; i < n; ++i) { cin >> weight[i] >> start[i] >> end[i]; order_start[i] = i; order_end[i] = i; } weight[n] = INT_MAX; start[n] = INT_MAX; for(int i = 0; i < n; ++i) { for(int j = n - 1; j > i; --j) { if(start[j] < start[j - 1]) { swap(order_start[j], order_start[j - 1]); } if(end[j] < end[j - 1]) { swap(order_end[j], order_end[j - 1]); } } } int sum = weight[order_start[0]]; int start_pos = 1; int end_pos = 0; while(start_pos != n) { if(start[order_start[start_pos]] == end[order_end[end_pos]]) { sum -= weight[order_end[end_pos]]; sum += weight[order_start[start_pos]]; start_pos++; end_pos++; } else if(start[order_start[start_pos]] < end[order_end[end_pos]]) { sum += weight[order_start[start_pos]]; start_pos++; } else if(start[order_start[start_pos]] > end[order_end[end_pos]]) { sum -= weight[order_end[end_pos]]; end_pos++; } if(sum > 150) { break; } } if(sum <= 150) { cout << "OK" << endl; } else { cout << "NG" << endl; } } } int main() { solve(); return(0); }
a.cc: In function 'void solve()': a.cc:22:29: error: 'INT_MAX' was not declared in this scope 22 | weight[n] = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <vector> +++ |+#include <climits> 3 |
s663665442
p00231
C++
#include <iostream> #include <utility> #include <vector> using namespace std; int main() { int n; while(cin>>n, n) { vector<pair<int,int> > v(n*2); for(int i=0; i<n; i++) { int mass, begin, end; cin >> mass >> begin >> end; // テヲツゥツ凝」ツ?クテ」ツ?凝」ツ?凝」ツつ凝ィツイツ?ィツ債キテ」ツ?ョテ・ツ「ツ療ヲツクツ崚」ツ?ョテ・ツ「ツεァツ閉古」ツ?ッテヲツクツ。テ」ツつ甘・ツァツ凝」ツつ?」ツ?ィテァツオツづ」ツつ? v[i*2] = make_pair(begin, mass); v[i*2+1] = make_pair(end, -mass); } // テ、ツコツ凝」ツ?ョティツオツキテ」ツつ甘」ツつ津ヲツ卍づァツウツサテ・ツ按療ゥツ??」ツ?ォテ」ツつステ」ツδシテ」ツδ? sort(v.begin(), v.end()); int load = 0; bool isOk = true; for(int i=0; i<2*n; i++) { load += v[i].second; if(load > 150) isOk = false; } cout << (isOk ? "OK" : "NG") << endl; } return 0; }
a.cc: In function 'int main()': a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'? 19 | sort(v.begin(), v.end()); | ^~~~ | short
s905141495
p00231
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <map> #include <sstream> #include <functional> #include <numeric> #include <cmath> #include <cstring> #include <queue> using namespace std; class person { public: int start, end, weight; person(int start=0, int end=0, int weight = 0):start(start),end(end),weight(weight){}; bool operator< (const person& per) const { if(start != per.start) return start < per.start; if(end != per.end) return end < per.end; if(weight != per.weight) return weight < per.weight; return false; } }; int n; vector<person> data; const int INF = 1 << 29; bool main(void) { while(cin >> n && n) { data.resize(n); for (int i = 0; i < n; i++) { int m, a, b; cin >> m >> a >> b; data[i] = person(a, b, m); } sort(data.begin(), data.end()); queue<person> cur; bool ok = true; int time = data[0].start; cur.push(data[0]); int weights = data[0].weight; for (int i = 1; i < n; i++) { time = data[i].start; person p = cur.front(); while(time >= p.end) { if(!cur.empty()) { weights -= p.weight; cur.pop(); if(!cur.empty()) p = cur.front(); else break; } else break; } cur.push(data[i]); weights+=data[i].weight; if(weights > 150) { ok = false; break; } } cout << (ok ? ("OK") : ("NG")) << endl; } return 0; }
a.cc:34:1: error: '::main' must return 'int' 34 | bool main(void) | ^~~~ a.cc: In function 'int main()': a.cc:38:17: error: reference to 'data' is ambiguous 38 | data.resize(n); | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:43:25: error: reference to 'data' is ambiguous 43 | data[i] = person(a, b, m); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:46:22: error: reference to 'data' is ambiguous 46 | sort(data.begin(), data.end()); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:46:36: error: reference to 'data' is ambiguous 46 | sort(data.begin(), data.end()); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:49:28: error: reference to 'data' is ambiguous 49 | int time = data[0].start; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:50:26: error: reference to 'data' is ambiguous 50 | cur.push(data[0]); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:51:31: error: reference to 'data' is ambiguous 51 | int weights = data[0].weight; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:54:32: error: reference to 'data' is ambiguous 54 | time = data[i].start; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:30:16: note: 'std::vector<person> data' 30 | vector<person> data; | ^~~~ a.cc:67:34: error: reference to 'data' is ambiguous 67 | cur.push(data[i]); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: cand
s388431621
p00232
Java
import java.util.Scanner; public class P0232 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); while(true) { int x = sc.nextInt(); int y = sc.nextInt(); int z = sc.nextInt(); if (x+y+z==0) { break; } int v[] = new int[x]; for (int i=0;i<x;i++) { v[i] = sc.nextInt(); } double p[][] = new double[y+1][60000]; p[0][0]=1.0d; int event[] = new int[y+1]; int eventa[] = new int[y+1]; for (int i=0;i<z;i++) { int n = sc.nextInt(); int e = sc.nextInt(); int a = sc.nextInt(); event[n]=e; eventa[n]=a; } //System.out.println("----"); for (int i=0;i<y;i++) { for (int m=0;m<60000;m++) { if (p[i][m]==0.0) { continue; } //System.out.println(i+","+m+","+p[i][m]); for (int j=0;j<x;j++) { int money = m; int target = i+v[j]; if (target>y) { target=y; } switch (event[target]) { case 1: target+=eventa[target]; if (target>y) { target=y; } break; case 2: money+=eventa[target]; break; case 3: money-=eventa[target]; if (money<0) { money = 0; } break; } p[target][money]+=p[i][m]/x; //System.out.println(i+" To "+target+" :p="+p[i][m]/x+" : money=" + m + " To "+money); } } } double ans = 0.0; for (int i=0;i<60000;i++) { ans+=p[y][i]*i; } System.out.println((int) ans); } } }
Main.java:2: error: class P0232 is public, should be declared in a file named P0232.java public class P0232 { ^ 1 error
s225291958
p00232
C
#include<stdio.h> int x,y,z; int v[4],n,e[50],a[50]; double dp[51][4901]; int min(int in1,int in2) { return in1>in2?in2:in1; } int max(int in1,int in2) { return in1<in2?in2:in1; } double dfs(int current,int money){ double sum=0; int i,j; if(current==0) for(i=0;i<51;i++) for(j=0;j<4901;j++) dp[i][j]=-1; if(current==y) return (double)money; if(e[current]==2) money+=a[current]; if(e[current]==3) money-=a[current]; if(money<0) money=0; if(dp[current][money]!=-1.0) return dp[current][money]; if(e[current]==1) sum+=dfs(current+a[current],money); else{ for(i=0;i<x;i++){ if(current+v[i]) sum+=dfs(min(current+v[i],y),money); } } return dp[current][money]=sum/(double)x; } int main(){ int i; while(true){ scanf("%d %d %d",&x,&y,&z); if(x+y+z==0) break; for(i=0;i<x;i++) scanf("%d",&v[i]); for(i=0;i<z;i++) { scanf("%d ",&n); scanf("%d %d",&e[n],&a[n]); } printf("%d\n",(int)dfs(0,0)); } return 0; }
main.c: In function 'main': main.c:35:15: error: 'true' undeclared (first use in this function) 35 | while(true){ | ^~~~ main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | main.c:35:15: note: each undeclared identifier is reported only once for each function it appears in 35 | while(true){ | ^~~~
s657655555
p00232
C++
#include<iostream> #include<algorithm> int x, y, z; double dp[51][5100]; int rulet[5]; std::pair<int, int>event[51]; int main(){ memset(dp, 0, sizeof(dp)); std::cin >> x >> y >> z; for (int i = 0; i < x; i++){ std::cin >> rulet[i]; } for (int i = 0; i < z; i++){ int n, e, a; std::cin >> n >> e >> a; event[n] = std::make_pair(e, a); } dp[0][0] = 1.0; for (int i = 0; i < y; i++){ for (int j = 0; j <= 5000; j++){ if (dp[i][j] != 0){ for (int k = 0; k < x; k++){ int coin = j; int to = std::min(y, i + rulet[k]); int c = event[to].first; if (c == 1)to = std::min(y, to + event[to].second); else if (c == 2)coin += event[to].second; else if (c == 3)coin = std::max(0, coin - event[to].second); dp[to][coin] += dp[i][j] / x; } } } } double res = 0; for (int i = 0; i <= 5000; i++){ res += i*dp[y][i]; } std::cout << (int)res << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:11:9: error: 'memset' was not declared in this scope 11 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 |
s313915476
p00232
C++
#include <iostream> #include <vector> #include <map> #include <algorithm> #include <string> #include <complex> #include <queue> #include <deque> #include <cmath> #define FOR(i,a,b) for(int i=(a);i<(int)(b);i++) #define REP(i,a) FOR(i,0,a) #define FORE(i,a,b) for(int i=(a);i<=(int)(b);i++) using namespace std; typedef complex<int> cl; typedef pair<double,int> pr; typedef pair<pr,int> ppr; typedef vector<pr> vpr; const int INF=1<<30; const int dx[]={0,1,0,-1},dy[]={1,0,-1,0}; double DP[51][5001]={}; int main() { int X,Y,Z; int tmp; while(cin >> X >> Y >>Z){ REP(i,51) REP(j,5001) DP[i][j]=0; int event[51][2]={}; int eye[4]={}; REP(i,X) cin >> eye[i]; REP(i,Z){ cin >> tmp ; cin >>event[tmp][0] >> event[tmp][1]; } DP[0][0]=1; REP(i,Y) REP(j,X) FORE(k,0,5000){ double par=DP[i][k]/(double)X; if(par==0) continue; int money=k; int next=min(Y,i+eye[j]); switch(event[next][0]){ case 1: next+=event[next][1]; break; case 2: money+=event[next][1]; break; case 3: money-=event[next][1]; money=max(0,money); break; } DP[next][money]+=par; }/* double mean=0; FORE(i,1,5000){ mean+=i*DP[Y][i]; } cout << (int)mean<< endl; }*/ return 0; }
a.cc: In function 'int main()': a.cc:66:2: error: expected '}' at end of input 66 | } | ^ a.cc:22:12: note: to match this '{' 22 | int main() { | ^
s729590695
p00232
C++
#include <bits/stdc++.h> #define PB push_back #define MP make_pair #define REP(i,n) for (int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define ALL(a) (a).begin(),(a).end() using namespace std; double EPS=1e-10; int INF=1e9; struct dat{ int x,turn,sum; dat(){} dat(int x,int turn,int sum):x(x),turn(turn),sum(sum){} }; int main(){ int x,y,z; while(cin>>x>>y>>z&&(x||y||z)){ int v[x],e1[y],e2[y]; REP(i,x)cin>>v[i]; REP(i,y)e1[i]=e2[i]=-1; REP(i,z){ int a,b,c; cin>>a>>b>>c; e1[a]=b; e2[a]=c; } double ans=0; queue<dat> Q; Q.push((dat){0,0,0.0}); while(!Q.empty()){ dat d=Q.front();Q.pop(); REP(i,x){ int np=d.x+v[i],ns=d.sum,nt=d.turn+1; if(np>=y){ ans+=(double)ns/pow(x,nt); continue; } if(np<0)np=0; if(e1[np]==1){ np+=e2[np]; }else if(e1[np]==2){ ns+=e2[np]; }else if(e1[np]==3){ ns-=e2[np]; } if(ns<0)ns=0; if(np>=y){ ans+=ns/pow(x,nt); continue; } Q.push((dat){np,nt,ns}); } } cout<<(int)ans<<endl; } }
a.cc: In function 'int main()': a.cc:29:33: error: narrowing conversion of '0.0' from 'double' to 'int' [-Wnarrowing] 29 | Q.push((dat){0,0,0.0}); | ^
s410969755
p00232
C++
#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; int v[4]; int e[51]; int a[51]; double dp[51][5010][2]; int main() { cin.tie(0); ios::sync_with_stdio(false); int vn, g, en; while (cin >> vn >> g >> en , vn) { for (int i = 0; i < vn; i++) { cin >> v[i]; } memset(e, 0, sizeof e); for (int i = 0; i < en; i++) { int n; cin >> n; cin >> e[n] >> a[n]; } memset(dp, 0, sizeof dp); dp[0][0][0] = 1.0; for (int i = 0; i < g; i++) { for (int j = 0; j <= 5000; j++) { for (int skip = 0; skip <= 1; skip++) { if (dp[i][j][skip] == 0) continue; int nj = j; if (skip == 0) { if (e[i] == 1) { int ni = min(i + a[i], g); dp[ni][j][1] += dp[i][j][0]; continue; } if (e[i] == 2) nj = j + a[i]; if (e[i] == 3) nj = max(0, j - a[i]); } for (int k = 0; k < vn; k++) { int ni = min(i + v[k], g); dp[ni][nj][0] += dp[i][j][skip] / vn; } } } } double ans = 0; for (int j = 0; j <= 5000; j++) { for (int s = 0; s < 2; s++) { ans += j * dp[g][j][s]; } } cout << int(ans) << endl; } }
a.cc: In function 'int main()': a.cc:23:17: error: 'memset' was not declared in this scope 23 | memset(e, 0, sizeof e); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <algorithm> +++ |+#include <cstring> 5 | using namespace std;
s064481054
p00232
C++
#include <cstdio> #include <vector> const int kMaxTurn = 64; //1????????????1??\??????????????§, 50???????????\??????????????????. const int kMaxSquare = 64; int roulette[4]; typedef struct{ int type; int value; } BoardState; BoardState board[51]; typedef struct{ float prob; int money; } BpState; int bp(int X, int Y){ std::vector<BpState> bp[kMaxTurn][kMaxSquare]; float prob = 1.0f / (float)X; bp[0][0].push_back({ 1.0f, 0 }); for (int t = 0; t < Y; t++){ for (int n = 0; n < Y; n++){ if (bp[t][n].size() == 0) continue; for (int k = 0; k < X; k++){ int pos = (n + roulette[k] < Y) ? n + roulette[k] : Y; switch (board[pos].type){ case 0: for (int i = 0; i < bp[t][n].size(); i++) bp[t + 1][pos].push_back({ bp[t][n].at(i).prob * prob, bp[t][n].at(i).money }); break; case 1: for (int i = 0; i < bp[t][n].size(); i++) bp[t + 1][pos + board[pos].value].push_back({ bp[t][n].at(i).prob * prob, bp[t][n].at(i).money }); break; case 2: for (int i = 0; i < bp[t][n].size(); i++) bp[t + 1][pos].push_back({ bp[t][n].at(i).prob * prob, bp[t][n].at(i).money + board[pos].value }); break; case 3: for (int i = 0; i < bp[t][n].size(); i++) bp[t + 1][pos].push_back({ bp[t][n].at(i).prob * prob, (bp[t][n].at(i).money - board[pos].value >= 0) ? bp[t][n].at(i).money - board[pos].value : 0 }); default: break; } } } } float res = 0.0f; for (int i = 1; i <= Y; i++) for (int j = 0; j < bp[i][Y].size(); j++) res += bp[i][Y].at(j).prob * (float)bp[i][Y].at(j).money; return (int)res; } int main(){ while (1){ int X, Y, Z; //X:????????¬?????????????????°, Y: ??????????????°(???: ????????????), Z: ???????????????????????° scanf_s("%d %d %d", &X, &Y, &Z); if (X == 0) return 0; for (int i = 0; i < X; i++) scanf_s("%d", &roulette[i]); for (int i = 0; i < 51; i++) board[i] = { 0, 0 }; for (; Z > 0; Z--){ int N, E, A; //N: ?????????, E: ??????????¨????, A: ??????????????§????????° or ?¢???????????????? scanf_s("%d %d %d", &N, &E, &A); board[N] = { E, A }; } printf("%d\n", bp(X, Y)); } }
a.cc: In function 'int main()': a.cc:66:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 66 | scanf_s("%d %d %d", &X, &Y, &Z); | ^~~~~~~ | scanf
s905528892
p00232
C++
#include <cstdio> #include <map> #define scanf scanf_s const int kMaxSquare = 64; int roulette[4]; typedef struct{ int type; int value; } BoardState; BoardState board[kMaxSquare]; int bp(int X, int Y){ std::map<int, double> bp[kMaxSquare]; double prob = 1.0f / static_cast<double>(X); bp[0][0] = 1.0f; for (int n = 0; n < Y; n++){ for (std::map<int, double>::iterator it = bp[n].begin(); it != bp[n].end(); it++){ for (int k = 0; k < X; k++){ int pos = (n + roulette[k] < Y) ? n + roulette[k] : Y; switch (board[pos].type){ case 0: bp[pos][it->first] += it->second * prob; break; case 1: bp[(pos + board[pos].value > Y) ? pos + board[pos].value : Y][it->first] += it->second * prob; break; case 2: bp[pos][it->first + board[pos].value] += it->second * prob; break; case 3: bp[pos][(it->first - board[pos].value > 0) ? it->first - board[pos].value : 0] += it->second * prob; default: break; } } } } double res = 0.0f; for (std::map<int, double>::iterator it = bp[Y].begin(); it != bp[Y].end(); it++) res += static_cast<double>(it->first) * it->second; return static_cast<int>(res); } int main(){ while (1){ int X, Y, Z; //X:????????¬?????????????????°, Y: ??????????????°(???: ????????????), Z: ???????????????????????° scanf("%d %d %d", &X, &Y, &Z); if (X == 0) return 0; for (int i = 0; i < X; i++) scanf("%d", &roulette[i]); for (int i = 0; i < kMaxSquare; i++) board[i] = { 0, 0 }; for (; Z > 0; Z--){ int N, E, A; //N: ?????????, E: ??????????¨????, A: ??????????????§????????° or ?¢???????????????? scanf("%d %d %d", &N, &E, &A); board[N] = { E, A }; } printf("%d\n", bp(X, Y)); } }
a.cc: In function 'int main()': a.cc:4:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 4 | #define scanf scanf_s | ^~~~~~~ a.cc:56:17: note: in expansion of macro 'scanf' 56 | scanf("%d %d %d", &X, &Y, &Z); | ^~~~~
s403412857
p00232
C++
#include <cstdio> #include <algorithm> //#define scanf scanf_s const int kMaxSquare = 64; const int kMaxMoney = 5100; const int kMaxGainMoney = 100; int roulette[4]; typedef struct{ int type; int value; } BoardState; BoardState board[kMaxSquare]; int bp(int X, int Y){ float bp[kMaxSquare][kMaxMoney]; float prob = 1.0f / static_cast<float>(X); bp[0][0] = 1.0f; for (int n = 0; n < Y; n++){ for (int m = 0; m <= kMaxGainMoney * n; m++){ if(bp[n][m] == 0.0f) continue; for (int k = 0; k < X; k++){ int pos = min(n+roulette[k], Y); if (board[pos].type == 1) bp[min(pos + board[pos].value, Y)][m] += bp[n][m] * prob; else if (board[pos].type == 2) bp[pos][m + board[pos].value] += bp[n][m]* prob; else if (board[pos].type == 3) bp[pos][max(m - board[pos].value, 0)] += bp[n][m] * prob; else bp[pos][m] += bp[n][m] * prob; } } } float res = 0.0f; for (int m = 0; m <= Y * kMaxGainMoney; m++) res += static_cast<float>(m) * bp[Y][m]; return static_cast<int>(res); } int main(){ while (1){ int X, Y, Z; scanf("%d %d %d", &X, &Y, &Z); if (X == 0) return 0; for (int i = 0; i < X; i++) scanf("%d", &roulette[i]); for (int i = 0; i < kMaxSquare; i++) board[i] = { 0, 0 }; for (; Z > 0; Z--){ int N, E, A; scanf("%d %d %d", &N, &E, &A); board[N] = { E, A }; } printf("%d\n", bp(X, Y)); } }
a.cc: In function 'int bp(int, int)': a.cc:28:19: error: 'min' was not declared in this scope; did you mean 'std::min'? 28 | int pos = min(n+roulette[k], Y); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:34:49: error: 'max' was not declared in this scope; did you mean 'std::max'? 34 | bp[pos][max(m - board[pos].value, 0)] += bp[n][m] * prob; | ^~~ | std::max /usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~
s974928430
p00232
C++
#include <cstdio> #include <algorithm> //#define scanf scanf_s const int kMaxSquare = 64; const int kMaxMoney = 5100; const int kMaxGainMoney = 100; int roulette[4]; typedef struct{ int type; int value; } BoardState; BoardState board[kMaxSquare]; int bp(int X, int Y){ float bp[kMaxSquare][kMaxMoney]; float prob = 1.0f / static_cast<float>(X); for(int n = 0; n <= X; n++) for(int m = 0; m <= Y*kMaxGainMOney; m++) pb[n][m] = 0.0f; bp[0][0] = 1.0f; for (int n = 0; n < Y; n++){ for (int m = 0; m <= kMaxGainMoney * n; m++){ if(bp[n][m] == 0.0f) continue; for (int k = 0; k < X; k++){ int pos = std::min(n+roulette[k], Y); if (board[pos].type == 1) bp[std::min(pos + board[pos].value, Y)][m] += bp[n][m] * prob; else if (board[pos].type == 2) bp[pos][m + board[pos].value] += bp[n][m]* prob; else if (board[pos].type == 3) bp[pos][std::max(m - board[pos].value, 0)] += bp[n][m] * prob; else bp[pos][m] += bp[n][m] * prob; } } } float res = 0.0f; for (int m = 0; m <= Y * kMaxGainMoney; m++) res += static_cast<float>(m) * bp[Y][m]; return static_cast<int>(res); } int main(){ while (1){ int X, Y, Z; scanf("%d %d %d", &X, &Y, &Z); if (X == 0) return 0; for (int i = 0; i < X; i++) scanf("%d", &roulette[i]); for (int i = 0; i < kMaxSquare; i++) board[i] = { 0, 0 }; for (; Z > 0; Z--){ int N, E, A; scanf("%d %d %d", &N, &E, &A); board[N] = { E, A }; } printf("%d\n", bp(X, Y)); } }
a.cc:25:23: error: stray '\23' in program 25 | pb[n][m] = 0.0f;<U+0013> | ^~~~~~~~ a.cc: In function 'int bp(int, int)': a.cc:24:27: error: 'kMaxGainMOney' was not declared in this scope; did you mean 'kMaxGainMoney'? 24 | for(int m = 0; m <= Y*kMaxGainMOney; m++) | ^~~~~~~~~~~~~ | kMaxGainMoney a.cc:25:7: error: 'pb' was not declared in this scope; did you mean 'bp'? 25 | pb[n][m] = 0.0f; | ^~ | bp
s067792263
p00232
C++
#include <cstdio> #include <algorithm> //#define scanf scanf_s const int kMaxSquare = 64; const int kMaxMoney = 5100; const int kMaxGainMoney = 100; int roulette[4]; typedef struct{ int type; int value; } BoardState; BoardState board[kMaxSquare]; int bp(int X, int Y){ float bp[kMaxSquare][kMaxMoney]; float prob = 1.0f / static_cast<float>(X); for(int n = 0; n <= X; n++) for(int m = 0; m <= Y*kMaxGainMoney; m++) bp[n][m] = 0.0f; bp[0][0] = 1.0f; for (int n = 0; n < Y; n++){ for (int m = 0; m <= kMaxGainMoney * n; m++){ if(bp[n][m] == 0.0f) continue; for (int k = 0; k < X; k++){ int pos = std::min(n+roulette[k], Y); if (board[pos].type == 1) bp[std::min(pos + board[pos].value, Y)][m] += bp[n][m] * prob; else if (board[pos].type == 2) bp[pos][m + board[pos].value] += bp[n][m]* prob; else if (board[pos].type == 3) bp[pos][std::max(m - board[pos].value, 0)] += bp[n][m] * prob; else bp[pos][m] += bp[n][m] * prob; } } } float res = 0.0f; for (int m = 0; m <= Y * kMaxGainMoney; m++) res += static_cast<float>(m) * bp[Y][m]; return static_cast<int>(res); } int main(){ while (1){ int X, Y, Z; scanf("%d %d %d", &X, &Y, &Z); if (X == 0) return 0; for (int i = 0; i < X; i++) scanf("%d", &roulette[i]); for (int i = 0; i < kMaxSquare; i++) board[i] = { 0, 0 }; for (; Z > 0; Z--){ int N, E, A; scanf("%d %d %d", &N, &E, &A); board[N] = { E, A }; } printf("%d\n", bp(X, Y)); } }
a.cc:25:23: error: stray '\23' in program 25 | bp[n][m] = 0.0f;<U+0013> | ^~~~~~~~