submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s945357734 | p03952 | C++ | #include <bits/stdc++.h>
using namespace std;
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//container util
#define all(x) (x).begin(),(x).end()
//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int main(){
ll n,x;
cin >> n >> x;
if( 1 < x && x < 2*n-1) cout << "Yes" << endl;
else {
cout << "No" << endl; return 0;
}
else if(n == 2){
cout << 1 << endl;
cout << 2 << endl;
cout << 3 << endl;
return 0;
}
VI num;
deque<int> qu;
if(x == 2){
qu.push_back(x+1);
qu.push_back(x);
qu.push_back(x-1);
qu.push_back(x+2);
FOR(i,1,2*n){
if(i == x-1 || i == x+1 ||
i == x || i == x+2 ){
// already pushed
continue;
}
if(i%2) qu.push_front(i);
else qu.push_back(i);
}
}else{
qu.push_back(x-1);
qu.push_back(x);
qu.push_back(x+1);
qu.push_back(x-2);
FOR(i,1,2*n){
if(i == x-1 || i == x+1 ||
i == x || i == x-2 ){
// already pushed
continue;
}
if(i%2) qu.push_front(i);
else qu.push_back(i);
}
}
while(qu.empty() == false){
cout << qu.front() << endl;
qu.pop_front();
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:35:3: error: 'else' without a previous 'if'
35 | else if(n == 2){
| ^~~~
|
s069069410 | p03952 | C++ | #include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
int main(){
int N,x,k,count=0;
cin>>N>>x;
if(x!=N/2 or x!=N/2+1 or x!=N/2-1){
cout<<"No"<<endl;
}else{
cout<<"Yes"<<endl;
for(int i=1;count<N/2-2;i++){
if(i<x-2 or i>x+2){
count++
cout<<i<<endl;
k=i;
}
}
cout<<x+1<<endl<<x-1<<endl<<x<<endl<<x+2<<x-2;
for(int i=k;i<=N;i++){
if(i<x-2 or i>x+2){
cout<<i<<endl;
}
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:20: error: expected ';' before 'cout'
14 | count++
| ^
| ;
15 | cout<<i<<endl;
| ~~~~
|
s683580317 | p03952 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int INF = INT_MAX;
int ans[300000];
bool used[300000];
int main(){
int N, X;
cin >> N >> X;
if(X == 1 || X == 2*N-1){
cout << "No" << endl;
return 0;
}
cout << "Yes" << endl;
else if(N == 2){
REP(i,3){
cout << i+1 << endl;
}
return 0;
}
fill(ans, ans+2*N-1, INF);
ans[N-2] = 2*N-1;
ans[N-1] = X;
ans[N] = 1;
used[1] = true;
used[X] = true;
used[2*N-1] = true;
for(int i = X+1; i <= 2*N-1; i++){
if(!used[i]){
ans[N+1] = i;
used[i] = true;
break;
}
}
for(int i = 1; i <= X-1; i++){
if(!used[i]){
ans[N-3] = i;
used[i] = true;
break;
}
}
int index = 1;
REP(i,2*N-1){
if(ans[i] == INF){
while(used[index]){
index++;
}
ans[i] = index;
used[index] = true;
}
}
REP(i,2*N-1){
cout << ans[i] << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:5: error: 'else' without a previous 'if'
26 | else if(N == 2){
| ^~~~
|
s284439094 | p03952 | C++ | #include<algorithm>
#include<iostream>
using namespace std;
int main(){
int N,x;
cin>>N>>x;
if(x!=N){
cout<<"No"<<endl;
}
else{
cout<<"Yes"<<endl;
REP(i,1,2*N+2){
cout<<i<<endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:13:9: error: 'i' was not declared in this scope
13 | REP(i,1,2*N+2){
| ^
a.cc:13:5: error: 'REP' was not declared in this scope
13 | REP(i,1,2*N+2){
| ^~~
|
s557430181 | p03952 | C++ | use std::io::*;
use std::str::FromStr;
fn main(){
println!("{}",
if read::<usize>() == read::<usize>() {"Yes"}
else {"No"});
}
fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
.collect();
token.parse().ok().expect("failed to parse token")
} | a.cc:1:1: error: 'use' does not name a type
1 | use std::io::*;
| ^~~
a.cc:2:1: error: 'use' does not name a type
2 | use std::str::FromStr;
| ^~~
a.cc:4:1: error: 'fn' does not name a type
4 | fn main(){
| ^~
a.cc:10:1: error: 'fn' does not name a type
10 | fn read<T: FromStr>() -> T {
| ^~
|
s009901520 | p03952 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
public class AGC006B{
public static void main(String[] args) throws IOException {
MyScanner sc = new MyScanner(System.in);
int n=sc.nextInt();
int x = sc.nextInt();
if(x==1||x==2*n-1) {
System.out.println("No");
return;
}
System.out.println("Yes");
if(n==2) {
System.out.println(1);
System.out.println(2);
System.out.println(3);
return;
}
if(x+1!=2*n-1) {
Queue<Integer> q=new ArrayDeque<>();
for(int i=2; i<2*n-1;i++) {
if(i!=x+1&&i!=x)
q.add(i);
}
for(int i=0; i<n-3; i++) {
int e=q.poll();
System.out.println(e);
}
System.out.println(x+1);
System.out.println(1);
System.out.println(x);
System.out.println(2*n-1);
for(int i=0; i<n-2; i++) {
System.out.println(q.poll());
}
} else {
Queue<Integer> q=new ArrayDeque<>();
for(int i=2; i<2*n-1;i++) {
if(i!=x-1&&i!=x)
q.add(i);
}
for(int i=0; i<n-3; i++) {
int e=q.poll();
System.out.println(e);
}
System.out.println(x-1);
System.out.println(1);
System.out.println(x);
System.out.println(2*n-1);
for(int i=0; i<n-2; i++) {
System.out.println(q.poll());
}
}
}
static class MyScanner
{
BufferedReader br;
StringTokenizer st;
public MyScanner(InputStream s)
{
br=new BufferedReader(new InputStreamReader(s));
}
public String nextLine() throws IOException
{
return br.readLine();
}
public String next() throws IOException
{
while(st==null || !st.hasMoreTokens())
st=new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException
{
return Integer.parseInt(next());
}
public double nextDouble() throws IOException
{
return Double.parseDouble(next());
}
public boolean ready() throws IOException
{
return br.ready();
}
public long nextLong() throws IOException
{
return Long.parseLong(next());
}
}
}
| Main.java:7: error: class AGC006B is public, should be declared in a file named AGC006B.java
public class AGC006B{
^
1 error
|
s219318961 | p03952 | C++ | #include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
int n,x;
cin>>n>>x;
if(n==2&&(x==3||x==1)){
cout<<"No"<<endl;
return 0;
}
int a[n*2];
for(int i=(2*n)/2,j=0;j<2*n-1;j++i=(i+1)%(2*n-1)){
a[i]=x++;
}
cout<<"Yes"<<endl;
r(i,2*n-1)cout<<a[i]<<endl;
} | a.cc: In function 'int main()':
a.cc:12:42: error: expected ')' before 'i'
12 | for(int i=(2*n)/2,j=0;j<2*n-1;j++i=(i+1)%(2*n-1)){
| ~ ^
| )
a.cc:12:57: error: expected ';' before ')' token
12 | for(int i=(2*n)/2,j=0;j<2*n-1;j++i=(i+1)%(2*n-1)){
| ^
| ;
|
s369978874 | p03952 | C++ | // ------------------------------------
// Date:2018/ 3/29
// Problem:_ _ _ c.cpp
//
// ------------------------------------
#include <bits/stdc++.h>
using namespace std;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;
int N, x;
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> x;
if (x == 1 or x == 2 * N - 1) {
// 1および2*N - 1は、どちらもそれより1大きいもしくは1小さい数が作れないのでNo
cout << "No" << endl;
} else {
if (x > 2) {
cout << "Yes" << endl;
deque< int > d;
// x - 2, x -1, x, x -3の順にxを囲んだ上で
// xを真ん中に配置するように残りの数字を両端から囲んであげる
d.push_front(x);
d.push_front(x - 1);
d.push_back(x + 1);
d.push_back(x - 2);
FOR(i, 1, x - 2) {
if(i & 1) d.push_front(i);
else d.push_back(i);
}
int bias = ((x - 4) % 2 + 2) % 2;
FOR(i, x + 2, 2 * N) {
if ((x + bias + i) % 2 == 1) {
d.push_front(i);
} else {
d.push_back(i);
}
}
while(!d.empty()) {
// 端から出力
cout << d.back() << endl;
d.pop_back();
}
} else {
if (N != x) {
cout << "No" << endl;
} else {
// N == xのとき、順番に並べればxは必ず真ん中に来る
FOR(i, 1, 2 * N) {
cout << i << endl;
}
}
}
}
return 0;
}
| a.cc:65:18: error: extended character is not valid in an identifier
65 | d.push_back(i);
| ^
a.cc:66:9: error: extended character is not valid in an identifier
66 | }
| ^
a.cc:66:12: error: extended character is not valid in an identifier
66 | }
| ^
a.cc:70:7: error: extended character is not valid in an identifier
70 | cout << d.back() << endl;
| ^
a.cc:71:7: error: extended character is not valid in an identifier
71 | d.pop_back();
| ^
a.cc: In function 'int main()':
a.cc:65:18: error: '\U00003000d' was not declared in this scope
65 | d.push_back(i);
| ^~~
a.cc:66:9: error: '\U00003000' was not declared in this scope
66 | }
| ^~
a.cc:70:7: error: '\U00003000' was not declared in this scope
70 | cout << d.back() << endl;
| ^~
a.cc:71:9: error: expected ';' before 'd'
71 | d.pop_back();
| ^~
| ;
|
s150947785 | p03952 | C++ | #include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int main() {
ll n, x;
cin >> n >> x;
if (x == 1 || x == 2 * n - 1)cout << "No" << endl;
else {
cout << "Yes" << endl;
if (n == 2)cout << 1 << endl << 2 << endl << 3 << endl;
else {
ll ans[200020], cnt = 1;
ans[n] = x;
ans[n - 1] = x + 1;
ans[n + 1] = x - 1;
ans[n + 2] = x + 2;
for (int i = 1; i < 2*n; i++) {
if (i == x || i == x + 1 || i == x + 2 || i == x - 1)continue;
ans[cnt] = i;
if (cnt == n - 1)cnt += 5;
else cnt++;
}
}
for (int i = 0; i < 2 * n; i++)cout << ans[i] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:32:56: error: 'ans' was not declared in this scope; did you mean 'abs'?
32 | for (int i = 0; i < 2 * n; i++)cout << ans[i] << endl;
| ^~~
| abs
|
s359384841 | p03952 | C++ | #include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
int n;cin>>n;
int x;cin>>x;
if(x==1)return puts("No")*0;
cout<<"Yes"<<endl;
map<int,int>mp;
if(n==2){
cout<<"1 2 3"<<endl;
}else if(x==2){
mp[x+1]=mp[x]=mp[x-1]=mp[x+2]=1;
}else{
mp[x+1]=mp[x]=mp[x-1]=mp[x-2]=1;
}
vi iijissougaomoitukanai;
rep(i,2*n-1)if(mp[i+1]!=1)iijissougaomoitukanai.push_back(i+1);
int l=0;
for(int i=1;i<=2*n-1;i++){
if((2*n-1)/2==i){
if(x==2)cout<<x+1<<'\n'<<x<<'\n'<<x-1<<'\n'<<x+2<<endl;
else cout<<x-1<<'\n'<<x<<'\n'<<x+1<<'\n'<<x-2<<endl;
i+=3;
}
else cout<<iijissougaomoitukanai[l++]<<endl;
}
}
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
signed main(){
int n;cin>>n;
int x;cin>>x;
if(x==1)return puts("No")*0;
cout<<"Yes"<<endl;
map<int,int>mp;
if(n==2){
cout<<"1 2 3"<<endl;
}else if(x==2){
mp[x+1]=mp[x]=mp[x-1]=mp[x+2]=1;
}else{
mp[x+1]=mp[x]=mp[x-1]=mp[x-2]=1;
}
vi iijissougaomoitukanai;
rep(i,2*n-1)if(mp[i+1]!=1)iijissougaomoitukanai.push_back(i+1);
int l=0;
for(int i=1;i<=2*n-1;i++){
if((2*n-1)/2==i){
if(x==2)cout<<x+1<<'\n'<<x<<'\n'<<x-1<<'\n'<<x+2<<endl;
else cout<<x-1<<'\n'<<x<<'\n'<<x+1<<'\n'<<x-2<<endl;
i+=3;
}
else cout<<iijissougaomoitukanai[l++]<<endl;
}
}
| a.cc:64:33: error: redefinition of 'template<class T, class S> void cmin(T&, const S&)'
64 | template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
| ^~~~
a.cc:17:33: note: 'template<class T, class S> void cmin(T&, const S&)' previously declared here
17 | template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
| ^~~~
a.cc:65:33: error: redefinition of 'template<class T, class S> void cmax(T&, const S&)'
65 | template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
| ^~~~
a.cc:18:33: note: 'template<class T, class S> void cmax(T&, const S&)' previously declared here
18 | template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
| ^~~~
a.cc:70:8: error: redefinition of 'int main()'
70 | signed main(){
| ^~~~
a.cc:23:8: note: 'int main()' previously defined here
23 | signed main(){
| ^~~~
|
s217365923 | p03952 | C++ | int n, x;
int main() {
cin >> n >> x;
if (n == 2) {
if (x == 2) {
cout << "Yes" << endl;
rep(i, 3) {
cout << i + 1 << endl;
}
}
else cout << "No" << endl;
}
else {
if (x == 2 * n - 1 || x == 1)cout << "No" << endl;
else {
cout << "Yes" << endl;
vector<int> vi;
rep(i, 2 * n - 1) {
vi.push_back(i + 1);
}
if (x + 2 <= 2 * n - 1) {
rep(i, 2 * n - 1) {
if (i + 1 == n - 1)cout << x - 1 << endl;
else if (i + 1 == n)cout << x << endl;
else if (i + 1 == n + 1)cout << x + 1 << endl;
else if (i + 1 == n + 2)cout << x - 2 << endl;
else if (i + 1 == x - 1)cout << n - 1 << endl;
else if (i + 1 == x)cout << n << endl;
else if (i + 1 == x + 1)cout << n + 1 << endl;
else if (i + 1 == x - 2)cout << n + 2 << endl;
else cout << vi[i] << endl;
}
}
else {
rep(i, 2 * n - 1) {
if (i + 1 == n - 1)cout << x + 2 << endl;
else if (i + 1 == n)cout << x - 1 << endl;
else if (i + 1 == n + 1)cout << x << endl;
else if (i + 1 == n + 2)cout << x + 1 << endl;
else if (i + 1 == x + 2)cout << n - 1 << endl;
else if (i + 1 == x - 1)cout << n << endl;
else if (i + 1 == x)cout << n + 1 << endl;
else if (i + 1 == x + 1)cout << n + 2 << endl;
else cout << vi[i] << endl;
}
}
}
}
} | a.cc: In function 'int main()':
a.cc:4:9: error: 'cin' was not declared in this scope
4 | cin >> n >> x;
| ^~~
a.cc:7:25: error: 'cout' was not declared in this scope
7 | cout << "Yes" << endl;
| ^~~~
a.cc:7:42: error: 'endl' was not declared in this scope
7 | cout << "Yes" << endl;
| ^~~~
a.cc:8:29: error: 'i' was not declared in this scope
8 | rep(i, 3) {
| ^
a.cc:8:25: error: 'rep' was not declared in this scope
8 | rep(i, 3) {
| ^~~
a.cc:12:22: error: 'cout' was not declared in this scope
12 | else cout << "No" << endl;
| ^~~~
a.cc:12:38: error: 'endl' was not declared in this scope
12 | else cout << "No" << endl;
| ^~~~
a.cc:15:46: error: 'cout' was not declared in this scope
15 | if (x == 2 * n - 1 || x == 1)cout << "No" << endl;
| ^~~~
a.cc:15:62: error: 'endl' was not declared in this scope
15 | if (x == 2 * n - 1 || x == 1)cout << "No" << endl;
| ^~~~
a.cc:17:25: error: 'cout' was not declared in this scope
17 | cout << "Yes" << endl;
| ^~~~
a.cc:17:42: error: 'endl' was not declared in this scope
17 | cout << "Yes" << endl;
| ^~~~
a.cc:18:25: error: 'vector' was not declared in this scope
18 | vector<int> vi;
| ^~~~~~
a.cc:18:32: error: expected primary-expression before 'int'
18 | vector<int> vi;
| ^~~
a.cc:19:29: error: 'i' was not declared in this scope
19 | rep(i, 2 * n - 1) {
| ^
a.cc:19:25: error: 'rep' was not declared in this scope
19 | rep(i, 2 * n - 1) {
| ^~~
|
s676413436 | p03952 | C++ | import sys
N, x = map(int, sys.stdin.readline().split())
if N == x:
print('Yes')
print(' '.join(map(lambda x: str(x+1), range(N*2-1))))
else:
print('No') | a.cc:4:9: warning: multi-character character constant [-Wmultichar]
4 | print('Yes')
| ^~~~~
a.cc:7:9: warning: multi-character character constant [-Wmultichar]
7 | print('No')
| ^~~~
a.cc:1:1: error: 'import' does not name a type
1 | import sys
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s140735143 | p03952 | C++ | #include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#define NMAX 100000
#define MMAX 10000
using namespace std;
int N,x,judge = 0,dp[NMAX][NMAX*2] = {};
vector<int > med;
int main(){
ios::sync_with_stdio(false);
cin >> N >> x;
vector<int> v(N*2-1);
iota(v.begin(), v.end(), 1); // v に 1, 2, ... N を設定
do {
for (int i = 0; i < v.size(); ++i)
{
dp[0][i] = v[i];
}
for (int i = 1; i < N; ++i)
{
for (int j = 0; j < (N-i)*2-1; ++j)
{
med.push_back(dp[i-1][j]);
med.push_back(dp[i-1][j+1]);
med.push_back(dp[i-1][j+2]);
sort(med.begin(), med.end());
dp[i][j] = med[1];
med.clear();
}
}
if(dp[N-1][0] == x){
judge = 1;
break;
}
} while( next_permutation(v.begin(), v.end()) ); // 次の順列を生成
if(judge){
cout << "Yes\n";
for (int i = 0; i < v.size(); ++i)
{
cout << v[i] << "\n";
}
}else{
cout << "No\n";
}
return 0;
} | /tmp/cc0l5s6l.o: in function `main':
a.cc:(.text+0x145): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
a.cc:(.text+0x185): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
a.cc:(.text+0x1d4): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
a.cc:(.text+0x1e6): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
a.cc:(.text+0x23e): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
/tmp/cc0l5s6l.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3d7): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
a.cc:(.text+0x3f0): relocation truncated to fit: R_X86_64_PC32 against symbol `med' defined in .bss section in /tmp/cc0l5s6l.o
collect2: error: ld returned 1 exit status
|
s295450958 | p03952 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
string s,t;
int n,N,len=1;
cin >> N >> n;
if(n==1||n==(N*2-1)){
cout <<"No" << endl;
}else if(N>2){
cout << "Yes" << endl;
for(int i=0;i<(N*2-1);i++){
if(i==(N-2))cout << (n+1) << endl;
else if(i==(N-1))cout << n << endl;
else if(i==(N))cout << (n-1) << endl;
else if(i==(N+1))cout << (n+2) << endl;
else{
if(len==(n-1)){
len+=4;
}
cout << len << endl;
len++;
}
}else if(N==2){
for(int k=1;k<=3;k++){
cout << k << endl;
}
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:6: error: expected '}' before 'else'
25 | }else if(N==2){
| ^~~~
a.cc:10:18: note: to match this '{'
10 | }else if(N>2){
| ^
a.cc: At global scope:
a.cc:31:5: error: expected unqualified-id before 'return'
31 | return 0;
| ^~~~~~
a.cc:32:1: error: expected declaration before '}' token
32 | }
| ^
|
s917164050 | p03952 | C++ | #include <iostream>
#include<cstdio>
const int N = 200000 + 10;
int n, x;
int ans[N];
int main() {
scanf_s("%d%d", &n, &x);
if (x == 1 || x == 2 * n - 1) return puts("No"), 0;
puts("Yes");
ans[n] = x;
static bool flag[N];
flag[x] = true;
ans[n - 1] = 2 * n - 1;
ans[n + 1] = 1;
ans[n + 2] = x + 1;
flag[1] = flag[x+1] = flag[2 * n - 1] = true;
for (int i = 1, j = 1; i < 2 * n; ++i) {
if (!ans[i]) {
while (flag[j]) ++j;
ans[i] = j;
flag[j] = true;
}
}
for (int i = 1; i < 2 * n; ++i) printf("%d\n", ans[i]);
return 0;
} | a.cc: In function 'int main()':
a.cc:9:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
9 | scanf_s("%d%d", &n, &x);
| ^~~~~~~
| scanf
|
s112440203 | p03952 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int x = sc.nextInt();
if (x == 1 || x == 2 * N - 1) {
out.println("No");
out.flush();
return;
}
out.println("Yes");
if (N == 2) {
for (int i = 1, n = 2 * N; i < n; ++i) {
out.println(i);
}
} else {
if (x > N) {
for (int i = N; i < N * 2; ++i) {
if (i != x) {
out.println(i);
}
}
out.println(x);
for (int i = 1; i < N; ++i) {
if (i != x) {
out.println(i);
}
}
} else {
for (int i = N + 1; i < N * 2; ++i) {
if (i != x) {
out.println(i);
}
}
out.println(x);
for (int i = 1; i < N + 1; ++i) {
if (i != x) {
out.println(i);
}
}
}
}
out.flush();
}
} | Main.java:5: error: cannot find symbol
PrintWriter out = new PrintWriter(System.out);
^
symbol: class PrintWriter
location: class Main
Main.java:5: error: cannot find symbol
PrintWriter out = new PrintWriter(System.out);
^
symbol: class PrintWriter
location: class Main
2 errors
|
s115564878 | p03952 | Java | //-----------------------------------------------------------
// すぐ使える
//-----------------------------------------------------------
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// 1行、2つ(複数)数字
String[] ss0 = br.readLine().trim().split(" ", 0);
int N = Integer.parseInt(ss0[0]);
int x = Integer.parseInt(ss0[1]);
do {
if (N == x) {
for(int i = 1; i<=(N*2-1); i++){ System.out.println(i); }
break;
}
if( N >= 3){
if( (N-1)=x ){
System.out.println(N+1);
for(int i = 1; i<=(N*2-1); i++){
if (i != (N+1)) {System.out.println(i); }
}
break;
}
if( (N+1)=x ){
System.out.println(N-1);
for(int i = 1; i<=(N*2-1); i++){
if (i != (N-1)) {System.out.println(i); }
}
break;
}
}
System.out.println("No");
} while (false);
}
// Debug.Print
static void dp(String s) {
System.out.println(s);
}
static void dp(StringBuilder s) { dp(s.toString()); }
static void dp(int i) { dp(String.valueOf(i)); }
static void dp(long i) { dp(String.valueOf(i)); }
} | Main.java:24: error: unexpected type
if( (N-1)=x ){
^
required: variable
found: value
Main.java:31: error: unexpected type
if( (N+1)=x ){
^
required: variable
found: value
2 errors
|
s895783660 | p03952 | Java | import java.util.Scanner;
public class Main {
public static void main(String args[] ) throws Exception {
new Main().exec(args);
}
public Main() {
}
public void exec(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
int x=sc.nextInt();
boolean flg=true;
if(x==1 || x==2*N-1) flg=false;
int[] outputArray = new int[2*N-1];
System.out.println(flg?"Yes":"No");
if(flg) {
if(N==2) {
outputArray[0]=1;
outputArray[1]=2;
outputArray[2]=3;
}
// else if(N==3) {
// if(x==2) {
// outputArray[0]=3;
// outputArray[1]=5;
// outputArray[2]=2;
// outputArray[3]=1;
// outputArray[4]=4;
// }else if(x==3){
// outputArray[0]=2;
// outputArray[1]=5;
// outputArray[2]=3;
// outputArray[3]=1;
// outputArray[4]=4;
//
// }else{
// outputArray[0]=2;
// outputArray[1]=5;
// outputArray[2]=4;
// outputArray[3]=1;
// outputArray[4]=3;
// }
// }
else {
for(int i=0; i<outputArray.length; i++) {
outputArray[i]=i+1;
}
if(x==2) {
swap(outputArray,N-1,2*N-1);
swap(outputArray,N,x);
swap(outputArray,N+1,1);
}else{
swap(outputArray,N-2,2);
swap(outputArray,N-1,2*N-1);
if(x==N-2){
swap(outputArray,N,2);
}else if(x==N-1){
swap(outputArray,N,2*N-1);
}else {
swap(outputArray,N,x);
}
swap(outputArray,N+1,1);
}
}
output(outputArray);
}
} | Main.java:71: error: reached end of file while parsing
}
^
1 error
|
s383887558 | p03952 | C++ | #include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
// #include <fstream>//ifstream/ofstream
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>
#define PRIME_SHORT 10007
#define PRIME 1000000007
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;
const bool debug = false;
void rar(int n, int* a);
void rar2(int n, int m, int** a);
int ipow(int base, int exp);
int left(int current, bool swap);
int right(int current, bool swap);
int griddist(int x, int y, int s, int t);
int griddist(pii one, pii two);
double sqeucldist(double x, double y, double s, double t);
double sqeucldist(pii one, pii two);
ull modadd(ull a, ull b, int mod);
ull modmult(ull a, ull b, int mod);
int main(void) {
size_t n, x;
cin >> n >> x;
n = 2*n-1;
if (n == 2){
cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
return 0;
}
if (x != 1 && x != n)
{
cout << "Yes\n";
ull *row = new ull[n];
size_t pos = n/2;
row[pos] = x;
row[pos-1] = x-1;
row[pos+1] = x+1;
if (x == 2) {
row[pos-2] = x+2;
row[pos+2] = n;
for (size_t i = 0; i < pos-2; ++i) {
row[i] = i+5;
}
for (size_t i = pos+3; i < n; ++i){
row[i] = i;
}
} else if (x == n-1) {
row[pos-2] = 1;
row[pos+2] = x-2;
for (size_t i = 0; i < pos-2; ++i) {
row[i] = i+2;
}
for (size_t i = pos+3; i < n; ++i){
row[i] = i-3;
}
} else {
row[pos-2] = x+2;
row[pos+2] = x-2;
for (size_t i = 0; i < pos-2; ++i) {
row[i] = i<(x-3) ? i+1 : i+6;
}
for (size_t i = pos+3; i < n; ++i){
row[i] = i<(x-3) ? i-4: i+1;
}
}
for (size_t i = 0; i < n; ++i) {
cout << row[i] << endl;
}
} else {
cout << "No" << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:59:18: error: no match for 'operator==' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'int')
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ~~~~~~~~~^~~
| | |
| | int
| std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}
a.cc:59:18: note: candidate: 'operator==(int, int)' (built-in)
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ~~~~~~~~~^~~
a.cc:59:18: note: no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
In file included from a.cc:2:
/usr/include/c++/14/array:303:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> bool std::operator==(const array<_Tp, _Nm>&, const array<_Tp, _Nm>&)'
303 | operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
| ^~~~~~~~
/usr/include/c++/14/array:303:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::array<_Tp, _Nm>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from a.cc:3:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::fpos<_StateT>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::allocator<_CharT>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:59:20: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
59 | cout << x==2 ? "Yes\n1\n2\n3" : "No" << endl;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... |
s929145336 | p03952 | Java | /* Filename: AGC006B.java
* Author: Mushiyo
*/
import java.util.Scanner;
import java.util.Arrays;
public class AGC006B {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
int N = input.nextInt();
int x = input.nextInt();
int rowNLen = 2 * N - 1;
if (x == 1 || x == rowNLen) {
System.out.println("No");
} else {
int[] ans = new int[rowNLen + 1];
for (int i = 0; i < ans.length; ++i) {
ans[i] = i;
}
int mid = N;
int tmp = ans[mid];
ans[mid] = x;
ans[x] = tmp;
//System.out.println(Arrays.toString(ans));
tmp = ans[mid - 1];
ans[mid - 1] = rowNLen;
ans[rowNLen] = tmp;
//System.out.println(Arrays.toString(ans));
if (ans[mid + 1] != 1) {
tmp = ans[mid + 1];
ans[mid + 1] = 1;
ans[1] = tmp;
}
//System.out.println(Arrays.toString(ans));
System.out.println("Yes");
StringBuilder ansOut = new StringBuilder();
for (int i = 1; i < ans.length; ++i) {
ansOut.append(ans[i] + '\n');
}
System.out.println(ansOut);
}
}
}
}
| Main.java:8: error: class AGC006B is public, should be declared in a file named AGC006B.java
public class AGC006B {
^
1 error
|
s874165558 | p03952 | C++ | #include <iostream>
#include <vector>
int main(void){
int n, x;
std::cin >> n >> x;
std::vector<int> v;
for(int i=1; i<=2*n-1; i++){
v.push_back(i);
}
if(x<2 || 2*n-2<x){
std::cout << "No" << std::endl;
}else{
std::cout << "Yes" << std::endl;
int slide = n-x;
for(int i=0; i<2*n-1; i++){
std::cout << v[(i+2*n-1-slide)%(2*n-1)] << std::endl;
}
}
return 0;
}#include <iostream>
#include <vector>
int main(void){
int n, x;
std::cin >> n >> x;
std::vector<int> v;
for(int i=1; i<=2*n-1; i++){
v.push_back(i);
}
if(x<2 || 2*n-2<x){
std::cout << "No" << std::endl;
}else{
std::cout << "Yes" << std::endl;
int slide = n-x;
for(int i=0; i<2*n-1; i++){
std::cout << v[(i+2*n-1-slide)%(2*n-1)] << std::endl;
}
}
return 0;
} | a.cc:25:2: error: stray '#' in program
25 | }#include <iostream>
| ^
a.cc:25:3: error: 'include' does not name a type
25 | }#include <iostream>
| ^~~~~~~
|
s095042742 | p03952 | Java | import java.util.Scanner;
public class MedianPyramidEasy {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int x = sc.nextInt();
if(x == n){
System.out.println("Yes");
for(int i = 1;i < 2*n;i++){
System.out.println(i);
}
}else{
System.out.println("No");
}
}
}
| Main.java:3: error: class MedianPyramidEasy is public, should be declared in a file named MedianPyramidEasy.java
public class MedianPyramidEasy {
^
1 error
|
s742954624 | p03952 | C++ | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;
int main()
{
int N, x;
scanf("%d%d", &N, &x);
if (N == 2) {
if (x == 2) {
printf("Yes\n");
printf("1\n");
printf("2\n");
printf("3\n");
return 0;
} else {
printf("No\n");
return 0;
}
}
if (x == 1 || x == 2 * N - 1) {
printf("No\n");
return 0;
} else {
printf("Yes\n");
if (x =< N) {
int counter = 1;
int i = 1;
while (counter <= N - 3) {
printf("%d\n", i);
counter++;
if (i + 1 == x - 1) {
i = x + 3;
} else {
i++
}
}
printf("x + 2\n");
printf("x - 1\n");
printf("x\n");
printf("x + 1\n");
counter += 4;
while (counter <= 2 * N - 1) {
printf("%d\n", i);
counter++;
if (i + 1 == x - 1) {
i = x + 3;
} else {
i++
}
}
return 0;
} else {
int counter = 1;
int i = 1;
while (counter <= N - 3) {
printf("%d\n", i);
counter++;
if (i + 1 == x - 2) {
i = x + 2;
} else {
i++;
}
}
printf("%d\n", x - 2);
printf("%d\n", x + 1);
printf("%d\n", x);
printf("%d\n", x - 1);
counter += 4;
while (counter <= 2 * N - 1) {
printf("%d\n", i);
counter++;
if (i + 1 == x - 2) {
i = x + 2;
} else {
i++;
}
}
}
}
} | a.cc: In function 'int main()':
a.cc:29:16: error: expected primary-expression before '<' token
29 | if (x =< N) {
| ^
a.cc:38:24: error: expected ';' before '}' token
38 | i++
| ^
| ;
39 | }
| ~
a.cc:52:24: error: expected ';' before '}' token
52 | i++
| ^
| ;
53 | }
| ~
|
s147468457 | p03952 | C++ | // #ifndef GLOBAL_JUDGE
// freopen("txt.in","r",stdin);
// freopen("txt.out","w",stdout);
// #endif // GLOBAL_JUDGE
| /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s286063888 | p03952 | C++ | #include <iostream>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N, x;
cin >> N >> x;
if(x==1 || x==2*N-1){
cout << "No" << endl;
return 0;
}
if(x==2){
int cur = 3;
for(int i=1; i<N-2; i++){
if(cur==x) cur++;
cout << cur << endl;
cur++;
}
cout << 2*N-2 << endl;
cout << 1 << endl;
cout << x << endl;
cout << 2*N-1 << endl;
for(int i=N+2; i<2*N; i++){
if(cur==x) cur++;
cout << cur << endl;
cur++;
}
| a.cc: In function 'int main()':
a.cc:33:10: error: expected '}' at end of input
33 | }
| ^
a.cc:18:13: note: to match this '{'
18 | if(x==2){
| ^
a.cc:33:10: error: expected '}' at end of input
33 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s858768642 | p03952 | C++ | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int N;
int x;
int n;
std::cin >> N;
std::cin >> x;
if(x < 2 || x > 2N)
{
std::cout << "No" << std::endl;
return 0;
}
else
{
std::cout << "Yes" << std::endl;
}
n = 2*N-1;
for(int i = 1; i <= n; i++)
{
std::cout << i << std::endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:25: error: unable to find numeric literal operator 'operator""N'
15 | if(x < 2 || x > 2N)
| ^~
|
s811605751 | p03952 | C++ | #include "bits/stdc++.h"
using namespace std;
int main(){
long long n,x;
cin >> n >> x;
if(n == 1){
cout << "Yes\n";
cout << 1 << endl;
}
else if(n == 2){
if(x == 2){
cout << "Yes\n";
cout << 1 << endl << 2 << endl << 3 << endl;
}
else{
cout << "No\n";
}
}
else{
if(x == 1 || x == 2*n - 1){
cout << "No\n";
}
else{
vector<long long> arr(2*n,-1);
long long index = x;
arr[n] = index;
arr[n+1] = 2*n - 1;
arr[n+2] = 1;
long long count = 2;
for(long long i=1;i<=2*n - 1;i++){
if(count == x){
count++;
}
if(arr[i] == -1){
arr[i] = count++;t
}
}
cout << "Yes\n";
for(long long i=1;i<=2*n-1;i++){
cout << arr[i] << endl;
}
}
}
} | a.cc: In function 'int main()':
a.cc:48:58: error: 't' was not declared in this scope
48 | arr[i] = count++;t
| ^
|
s292735574 | p03952 | C | #include<stdio.h>
#include<stdlib.h>
int mai() {
int N;
int x;
int loop;
scanf("%d %d", &N, &x);
exit(0);
if (N == x) {
printf("Yes\n");
for (loop = 0; loop < 2*N - 1; loop++)printf("%d\n", loop);
}
else printf("No\n");
return 0;
} | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s599254649 | p03952 | C | #include<stdio.h>
int mai() {
int N;
int x;
int loop;
scanf("%d %d", &N, &x);
if (N == x) {
printf("Yes\n");
for (loop = 0; loop < 2N - 1; loop++)printf("%d\n", loop);
}
else printf("No\n");
return 0;
} | main.c: In function 'mai':
main.c:11:39: error: invalid suffix "N" on integer constant
11 | for (loop = 0; loop < 2N - 1; loop++)printf("%d\n", loop);
| ^~
|
s346555442 | p03952 | C++ | print('No') | a.cc:1:7: warning: multi-character character constant [-Wmultichar]
1 | print('No')
| ^~~~
a.cc:1:6: error: expected constructor, destructor, or type conversion before '(' token
1 | print('No')
| ^
|
s445779766 | p03952 | Java | import java.io.*;
import java.util.*;
public class R6qB {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
int n = in.nextInt();
int x = in.nextInt();
if (n != x) {
if (x <= 1 || x >= 2 * n - 1)
w.println("No");
else {
w.println("Yes");
for (int i = 1; i < 2 * n; i++) {
if (i < x - 2 || i > x + 2)
w.println(i);
}
if (x == 2) {
w.println(3);
w.println(2);
w.println(1);
w.println(4);
} else {
w.println(x - 2);
w.println(x + 1);
w.println(x);
w.println(x - 1);
}
}
} else {
w.println("Yes");
for (int i = 1; i < 2 * n; i++)
w.println(i);
}
w.close();
}
static int get(ArrayList<Integer> x) {
while (x.size() > 1) {
ArrayList<Integer> y = new ArrayList<Integer>();
for (int i = 0; i + 2 < x.size(); i++) {
ArrayList<Integer> z = new ArrayList<Integer>();
for (int k = i; k <= i + 2; k++)
z.add(x.get(i));
Collections.sort(z);
y.add(z.get(1));
}
x = y;
}
return x.get(0);
}
static class InputReader {
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int snext() {
if (snumChars == -1)
throw new InputMismatchException();
if (curChar >= snumChars) {
curChar = 0;
try {
snumChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (snumChars <= 0)
return -1;
}
return buf[curChar++];
}
public int nextInt() {
int c = snext();
while (isSpaceChar(c)) {
c = snext();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = snext();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = snext();
} while (!isSpaceChar(c));
return res * sgn;
}
public long nextLong() {
int c = snext();
while (isSpaceChar(c)) {
c = snext();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = snext();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = snext();
} while (!isSpaceChar(c));
return res * sgn;
}
public int[] nextIntArray(int n) {
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
}
return a;
}
public String readString() {
int c = snext();
while (isSpaceChar(c)) {
c = snext();
}
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = snext();
} while (!isSpaceChar(c));
return res.toString();
}
public String nextLine() {
int c = snext();
while (isSpaceChar(c))
c = snext();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = snext();
} while (!isEndOfLine(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
private boolean isEndOfLine(int c) {
return c == '\n' || c == '\r' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
}
| Main.java:4: error: class R6qB is public, should be declared in a file named R6qB.java
public class R6qB {
^
1 error
|
s727500943 | p03952 | C++ |
#include <cassert>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<
typedef long long llint;
int main(void) {
int N, x;
scanf("%d %d", &N, &x);
if (x == 1 || x == 2*N-1) {
puts("No");
return 0;
}
vector<int> a;
REP(i, 2*N-1) a.push_back(i+1);
int rot = (x - N + 2*N-1) % (2*N-1);
rotate(a.begin(), a.begin() + rot, a.end());
puts("Yes");
for (int x: a) printf("%d\n", x);
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:3: error: 'vector' was not declared in this scope
25 | vector<int> a;
| ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
5 | #include <set>
+++ |+#include <vector>
6 |
a.cc:25:10: error: expected primary-expression before 'int'
25 | vector<int> a;
| ^~~
a.cc:26:17: error: 'a' was not declared in this scope
26 | REP(i, 2*N-1) a.push_back(i+1);
| ^
a.cc:29:10: error: 'a' was not declared in this scope
29 | rotate(a.begin(), a.begin() + rot, a.end());
| ^
a.cc:29:3: error: 'rotate' was not declared in this scope
29 | rotate(a.begin(), a.begin() + rot, a.end());
| ^~~~~~
|
s001268151 | p03953 | C | #include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+10;
int c[maxn],a[maxn],to[maxn],ans[maxn],tmp[maxn],p[maxn],pos[maxn],K,now;
int n,m;
void solve(int y)
{
for(;y;y>>=1)
{
if (y&1)
{
for (int i=1;i<=n;++i)p[i]=ans[to[i]];
for (int i=1;i<=n;++i)ans[i]=p[i];
}
for (int i=1;i<=n;++i)p[i]=to[to[i]];
for (int i=1;i<=n;++i)to[i]=p[i];
}
for(int i=1;i<=n;++i)p[i]=c[ans[i]];
for(int i=1;i<=n;++i)c[i]=p[i];
}
signed main()
{
cin>>n;
for (int i=1;i<=n;++i)cin>>pos[i],c[i]=pos[i]-pos[i-1],to[i]=ans[i]=i;
scanf("%d%lld",&m,&K);
for(int i=1;i<=m;++i)cin>>a[i];
for(int i=1;i<=m;++i)
swap(to[a[i]],to[a[i]+1]);
solve(K);
for (int i=1;i<=n;++i)
c[i]+=c[i-1],cout<<c[i]<<".0 "<<endl;;
}
/*
这个1e18 明示矩阵加速/倍增
fi表示第i只兔子的期望位置。
扫操作,每次操作还要扫一下上一只和下一只,然后才能转移
这
pos[i]=pos[i-1]+pos[i+1]-pos[i]
草啊谁tm想得到差分啊????
*/
| main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s393205231 | p03953 | C++ | #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
int n,m,a[MAXN],ans[MAXN],res[MAXN],tmp[MAXN];
long long k;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;++i)scanf("%d",a+i);
for(int i=1;i<n;++i)ans[i]=i;
scanf("%d%lld",&m,&k);
for(int i=1;i<=m;++i){
int x;
scanf("%d",&x);
swap(ans[x],ans[x-1]);
}
for(int i=1;i<n;++i)res[i]=i;
while(k){
if(k&1)
for(int i=1;i<n;++i)res[i]=ans[res[i]];
for(int i=1;i<n;++i)tmp[i]=ans[ans[i]];
for(int i=1;i<n;++i)ans[i]=tmp[i];
k>>=1;
}
long long sum=a[1];
for(int i=1;i<=n;++i){
printf("%lld.0\n",sum);
sum+=a[res[i]+1]-a[res[i]];
}
} | a.cc:9:11: error: 'MAXN' was not declared in this scope
9 | int n,m,a[MAXN],ans[MAXN],res[MAXN],tmp[MAXN];
| ^~~~
a.cc:9:21: error: 'MAXN' was not declared in this scope
9 | int n,m,a[MAXN],ans[MAXN],res[MAXN],tmp[MAXN];
| ^~~~
a.cc:9:31: error: 'MAXN' was not declared in this scope
9 | int n,m,a[MAXN],ans[MAXN],res[MAXN],tmp[MAXN];
| ^~~~
a.cc:9:41: error: 'MAXN' was not declared in this scope
9 | int n,m,a[MAXN],ans[MAXN],res[MAXN],tmp[MAXN];
| ^~~~
a.cc: In function 'int main()':
a.cc:13:37: error: 'a' was not declared in this scope
13 | for(int i=1;i<=n;++i)scanf("%d",a+i);
| ^
a.cc:14:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
14 | for(int i=1;i<n;++i)ans[i]=i;
| ^~~
| abs
a.cc:19:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
19 | swap(ans[x],ans[x-1]);
| ^~~
| abs
a.cc:21:25: error: 'res' was not declared in this scope
21 | for(int i=1;i<n;++i)res[i]=i;
| ^~~
a.cc:24:33: error: 'res' was not declared in this scope
24 | for(int i=1;i<n;++i)res[i]=ans[res[i]];
| ^~~
a.cc:24:40: error: 'ans' was not declared in this scope; did you mean 'abs'?
24 | for(int i=1;i<n;++i)res[i]=ans[res[i]];
| ^~~
| abs
a.cc:25:29: error: 'tmp' was not declared in this scope; did you mean 'tm'?
25 | for(int i=1;i<n;++i)tmp[i]=ans[ans[i]];
| ^~~
| tm
a.cc:25:36: error: 'ans' was not declared in this scope; did you mean 'abs'?
25 | for(int i=1;i<n;++i)tmp[i]=ans[ans[i]];
| ^~~
| abs
a.cc:26:29: error: 'ans' was not declared in this scope; did you mean 'abs'?
26 | for(int i=1;i<n;++i)ans[i]=tmp[i];
| ^~~
| abs
a.cc:26:36: error: 'tmp' was not declared in this scope; did you mean 'tm'?
26 | for(int i=1;i<n;++i)ans[i]=tmp[i];
| ^~~
| tm
a.cc:29:19: error: 'a' was not declared in this scope
29 | long long sum=a[1];
| ^
a.cc:32:16: error: 'res' was not declared in this scope
32 | sum+=a[res[i]+1]-a[res[i]];
| ^~~
|
s117283052 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
using Lint=long long;
vector<int> mul(vector<int>& a,vector<int>& b)
{
const int N=a.size();
vector<int> res(N);
for(int i=0;i<N;i++) res[i]=b[a[i]];
return res;
}
vector<int> pow(vector<int>& p,Lint K)
{
const int N=p.size();
vector<int> res(N);
for(int i=0;i<N;i++) res[i]=i;
while(K>0){
if(K&1) res=mul(res,p);
p=mul(p,p); K>>=1;
}
return res;
}
int main()
{
int N; cin>>N;
vector<Lint> x(N);
for(int i=0;i<N;i++) cin>>x[i];
Lint M,K; cin>>M>>K;
vector<int> a(M);
for(int i=0;i<M;i++) cin>>a[i],a[i]--;
const int sz=N-1;
vector<int> d(sz);
for(int i=0;i<sz;i++) d[i]=x[i+1]-x[i];
vector<int> p(sz);
for(int i=0;i<sz;i++) p[i]=i;
for(int i=0;i<M;i++){
swap(p[a[i]-1],p[a[i]]);
}
res=pow(p,K);
for(int i=0;i<sz;i++) x[i+1]=x[i]+d[res[i]];
for(int i=0;i<N;i++) cout<<x[i]<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:4: error: 'res' was not declared in this scope
43 | res=pow(p,K);
| ^~~
|
s199308360 | p03953 | C++ | #include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
const int maxn=1e5+10;
const int mod=1e9+7;
namespace gengyf{
inline ll read(){
int f=1,x=0;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
return f*x;
}
ll n,m,a[maxn],ans[maxn],res[maxn],tmp[maxn];
ll k,sum;
int main(){
n=read();
for(int i=1;i<=n;i++){
scnaf("%lld",a+i);
}
m=read();k=read();
for(int i=1;i<n;i++)ans[i]=i;
for(int i=1;i<=m;i++){
ll x;x=read();
swap(ans[x],ans[x-1]);
}
for(int i=1;i<n;i++)res[i]=i;
while(k){
if(k&1)
for(int i=1;i<n;i++)res[i]=ans[res[i]];
for(int i=1;i<n;i++)tmp[i]=ans[ans[i]];
for(int i=1;i<n;i++)ans[i]=tmp[i];
k>>=1;
}
sum=a[1];
for(int i=1;i<=n;i++){
printf("%lld.0\n",sum);
sum+=a[res[i]+1]-a[res[i]];
}
return 0;
}
}
signed main(){
gengyf::main();
return 0;
}
| a.cc: In function 'int gengyf::main()':
a.cc:21:17: error: 'scnaf' was not declared in this scope; did you mean 'scanf'?
21 | scnaf("%lld",a+i);
| ^~~~~
| scanf
|
s185025758 | p03953 | C++ | // luogu-judger-enable-o2
| /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s349056139 | p03953 | C++ | #include<bits/stdc++.h>
namespace my_std{
using namespace std;
#define reg register
#define Rint register int
#define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define FORit(templ,arr,i,a,b) for(register templ *i=(arr)+(a);i!=(arr)+(b)+1;++i)
#define ROFit(templ,arr,i,a,b) for(register templ *i=(arr)+(a);i!=(arr)+(b)-1;--i)
#define GO(x,p,e,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
#define MEM(x,v) memset(x,v,sizeof(x))
#define fir first
#define sec second
#define pq priority_queue
#define PII pair<int,int>
#define MP make_pair
typedef long long LL;
typedef double DB;
inline int read(){
int ans=0,f=1;char c=getchar();
while(!isdigit(c)){ f^=(c=='-'); c=getchar(); }
for(;isdigit(c);c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48); return f?ans:-ans;
}
const int mod = 998244353 , N = 100010;
inline void inc(int &x,const int &y){ x+=y; if(x>=mod) x-=mod; }
inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res;}
inline int gcd(int x,int y){ if(x<y) swap(x,y); return y?gcd(y,x%y):x; }
#define FILE(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
}
using namespace my_std;
int n,m,x[N],pos[N],vis[N];
LL k , ans[N];
int stk[N] , top;
int main(){
n = read();
FOR(i,1,n) x[i] = read() , pos[i] = i;
ROF(i,n,1) x[i] -= x[i - 1];
m = read() , scanf("%lld",&k);
Rint xx;
FOR(i,1,m) xx = read() , swap(pos[xx] , pos[xx + 1]);
FOR(i,1,n){
if(!vis[i]){
for(Rint j = i;!vis[j];j = pos[j]) vis[stk[top++] = j] = 1;
FOR(j,0,top - 1) ans[stk[j]] = x[stk[(j + k) % top]];
top = 0;
}
}
FOR(i,1,n) ans[i] += ans[i - 1] , printf("%lld.0\n",ans[i]);
return 0;
}
Download as text | a.cc: In function 'int main()':
a.cc:38:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
38 | FOR(i,1,n) x[i] = read() , pos[i] = i;
| ^
a.cc:6:45: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
| ^
a.cc:39:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
39 | ROF(i,n,1) x[i] -= x[i - 1];
| ^
a.cc:7:45: note: in definition of macro 'ROF'
7 | #define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
| ^
a.cc:41:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
41 | Rint xx;
| ^~
a.cc:42:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
42 | FOR(i,1,m) xx = read() , swap(pos[xx] , pos[xx + 1]);
| ^
a.cc:6:45: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
| ^
a.cc:43:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
43 | FOR(i,1,n){
| ^
a.cc:6:45: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
| ^
a.cc:45:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
45 | for(Rint j = i;!vis[j];j = pos[j]) vis[stk[top++] = j] = 1;
| ^
a.cc:46:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
46 | FOR(j,0,top - 1) ans[stk[j]] = x[stk[(j + k) % top]];
| ^
a.cc:6:45: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
| ^
a.cc:50:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
50 | FOR(i,1,n) ans[i] += ans[i - 1] , printf("%lld.0\n",ans[i]);
| ^
a.cc:6:45: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
| ^
a.cc: At global scope:
a.cc:53:1: error: 'Download' does not name a type
53 | Download as text
| ^~~~~~~~
|
s782942765 | p03953 | C++ |
#include<bits/stdc++.h>
using namespace std;
long long n,x[111111],p[111111],y[111111],siz[111111],cir[111111],m,k,sum;
bool vis[111111];
int main(){
scanf("%lld",&n);
for(int i=1;i<=n;i++)scanf("%lld",&x[i]),p[i]=i,y[i]=x[i]-x[i-1];
scanf("%lld%lld",&m,&k);
for(int i=1,a;i<=m;i++)scanf("%lld",&a),swap(p[a],p[a+1]);
for(int i=1,c,pos,cnt=0;i<=n;i++)if(!vis[i]){
++cnt,c=0,pos=i;
while(!vis[pos])vis[pos]=1,cir[pos]=cnt,++c,pos=p[pos];
siz[cnt]=c;
}
for(int i=1;i<=n;i++){
int t=k%siz[cir[i]],pos=i;
while(t--)pos=p[pos];
printf("%lld.0\n",y[pos]+sum),sum+=y[pos];
}
}
| a.cc:1:1: error: '\U0000200b' does not name a type
1 |
|
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/in |
s184629641 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
int x = 0,f = 1;
char ch = getchar();
while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e5 + 7;
int n, m;
int replace[N], stk[N], res[N], vis[N];
LL x[N], ans[N], k;
int main() {
#ifdef fwat
freopen("data.in", "r", stdin);
#endif
n = gi();
rep(i, 1, n) x[i] = gi(), replace[i] = i;
scanf("%d%lld", &m, &k);
rep(i, 1, m) {
int x = gi();
swap(replace[x], replace[x + 1]);
}
rep(i, 1, n) if(!vis[i]) {
int tp = 0;
for(int j = i; !vis[j]; j = replace[j]) stk[tp++] = j, vis[j] = 1;
for(int j = 0; j < tp; ++j)
res[stk[j]] = stk[(j + k) % tp];
}
rep(i, 1, n) ans[i] = ans[i - 1] + x[res[i]] - x[res[i] - 1];
rep(i, 1, n) printf("%lld\n", ans[i]);
return 0;
} | a.cc: In function 'int main()':
a.cc:27:35: error: reference to 'replace' is ambiguous
27 | rep(i, 1, n) x[i] = gi(), replace[i] = i;
| ^~~~~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
| ^~~~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4280:5: note: 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
4280 | replace(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~
a.cc:20:5: note: 'int replace [100007]'
20 | int replace[N], stk[N], res[N], vis[N];
| ^~~~~~~
a.cc:31:22: error: reference to 'replace' is ambiguous
31 | swap(replace[x], replace[x + 1]);
| ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
| ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4280:5: note: 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
4280 | replace(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~
a.cc:20:5: note: 'int replace [100007]'
20 | int replace[N], stk[N], res[N], vis[N];
| ^~~~~~~
a.cc:31:34: error: reference to 'replace' is ambiguous
31 | swap(replace[x], replace[x + 1]);
| ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
| ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4280:5: note: 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
4280 | replace(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~
a.cc:20:5: note: 'int replace [100007]'
20 | int replace[N], stk[N], res[N], vis[N];
| ^~~~~~~
a.cc:35:45: error: reference to 'replace' is ambiguous
35 | for(int j = i; !vis[j]; j = replace[j]) stk[tp++] = j, vis[j] = 1;
| ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
| ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4280:5: note: 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
4280 | replace(_ForwardIterator __first, _ForwardIterator __last,
| ^~~~~~~
a.cc:20:5: note: 'int replace [100007]'
20 | int replace[N], stk[N], res[N], vis[N];
| ^~~~~~~
|
s118058570 | p03953 | C++ | /**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back
const long long MAXN = 1e6 + 1;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long readInt() {
bool minus1 = false;
long long result = 0;
char ch;
ch = getchar();
while (true) {
if (ch == '-') break;
if (ch >= '0' && ch <= '9') break;
ch = getchar();
}
if (ch == '-') minus1 = true; else result = ch-'0';
while (true) {
ch = getchar();
if (ch < '0' || ch > '9') break;
result = result*10 + (ch - '0');
}
if (minus1)
return -result;
else
return result;
}
#define int __int64
int a[MAXN];
int prem[MAXN];
int n;
vector <int> mult(const vector <int>& a, const vector <int>& b) {
vector <int> c(a.size());
for (int i = 0; i < a.size(); i++) {
c[i] = a[b[i]];
}
return c;
}
vector <int> binpow(vector <int>& a, int K) {
int sz = a.size();
vector <int> ans(sz);
for (int i = 0; i < sz; i++) ans[i] = i;
while(K) {
if (K & 1) {
ans = mult(ans, a);
}
a = mult(a, a);
K >>= 1;
}
return ans;
}
main() {
#ifdef IZI_KATKA
assert(freopen("input", "r", stdin));
assert(freopen("output", "w", stdout));
#endif
n = readInt();
vector <int> d(n - 1);
vector <int> perm(n - 1);
for (int i = 0; i < n; i++) {
a[i] = readInt();
}
for (int i = 0; i < n - 1; i++) {
d[i] = a[i + 1] - a[i];
perm[i] = i;
}
int M = readInt(), K = readInt();
for (int i = 1; i <= M; i++) {
int x = readInt() - 1;
swap(perm[x - 1], perm[x]);
}
vector <int> kekekek = binpow(perm, K);
int cur = a[0];
for (int i = 0; i < n - 1; i++) {
cout << cur << endl;
cur += d[kekekek[i]];
}
cout << cur;
return 0;
}
| a.cc:61:13: error: '__int64' does not name a type; did you mean '__int64_t'?
61 | #define int __int64
| ^~~~~~~
a.cc:63:1: note: in expansion of macro 'int'
63 | int a[MAXN];
| ^~~
a.cc:61:13: error: '__int64' does not name a type; did you mean '__int64_t'?
61 | #define int __int64
| ^~~~~~~
a.cc:65:1: note: in expansion of macro 'int'
65 | int prem[MAXN];
| ^~~
a.cc:61:13: error: '__int64' does not name a type; did you mean '__int64_t'?
61 | #define int __int64
| ^~~~~~~
a.cc:67:1: note: in expansion of macro 'int'
67 | int n;
| ^~~
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:69:9: note: in expansion of macro 'int'
69 | vector <int> mult(const vector <int>& a, const vector <int>& b) {
| ^~~
a.cc:69:12: error: template argument 1 is invalid
69 | vector <int> mult(const vector <int>& a, const vector <int>& b) {
| ^
a.cc:69:12: error: template argument 2 is invalid
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:69:33: note: in expansion of macro 'int'
69 | vector <int> mult(const vector <int>& a, const vector <int>& b) {
| ^~~
a.cc:69:36: error: template argument 1 is invalid
69 | vector <int> mult(const vector <int>& a, const vector <int>& b) {
| ^
a.cc:69:36: error: template argument 2 is invalid
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:69:56: note: in expansion of macro 'int'
69 | vector <int> mult(const vector <int>& a, const vector <int>& b) {
| ^~~
a.cc:69:59: error: template argument 1 is invalid
69 | vector <int> mult(const vector <int>& a, const vector <int>& b) {
| ^
a.cc:69:59: error: template argument 2 is invalid
a.cc: In function 'int mult(const int&, const int&)':
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:70:13: note: in expansion of macro 'int'
70 | vector <int> c(a.size());
| ^~~
a.cc:70:16: error: template argument 1 is invalid
70 | vector <int> c(a.size());
| ^
a.cc:70:16: error: template argument 2 is invalid
a.cc:70:22: error: request for member 'size' in 'a', which is of non-class type 'const int'
70 | vector <int> c(a.size());
| ^~~~
a.cc:71:14: error: expected ';' before 'i'
71 | for (int i = 0; i < a.size(); i++) {
| ^
a.cc:71:21: error: 'i' was not declared in this scope
71 | for (int i = 0; i < a.size(); i++) {
| ^
a.cc:71:27: error: request for member 'size' in 'a', which is of non-class type 'const int'
71 | for (int i = 0; i < a.size(); i++) {
| ^~~~
a.cc: At global scope:
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:77:9: note: in expansion of macro 'int'
77 | vector <int> binpow(vector <int>& a, int K) {
| ^~~
a.cc:77:12: error: template argument 1 is invalid
77 | vector <int> binpow(vector <int>& a, int K) {
| ^
a.cc:77:12: error: template argument 2 is invalid
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:77:29: note: in expansion of macro 'int'
77 | vector <int> binpow(vector <int>& a, int K) {
| ^~~
a.cc:77:32: error: template argument 1 is invalid
77 | vector <int> binpow(vector <int>& a, int K) {
| ^
a.cc:77:32: error: template argument 2 is invalid
a.cc:61:13: error: '__int64' has not been declared
61 | #define int __int64
| ^~~~~~~
a.cc:77:38: note: in expansion of macro 'int'
77 | vector <int> binpow(vector <int>& a, int K) {
| ^~~
a.cc: In function 'int binpow(int&, int)':
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:78:5: note: in expansion of macro 'int'
78 | int sz = a.size();
| ^~~
a.cc:79:16: error: template argument 2 is invalid
79 | vector <int> ans(sz);
| ^
a.cc:79:22: error: 'sz' was not declared in this scope
79 | vector <int> ans(sz);
| ^~
a.cc:80:14: error: expected ';' before 'i'
80 | for (int i = 0; i < sz; i++) ans[i] = i;
| ^
a.cc:80:21: error: 'i' was not declared in this scope
80 | for (int i = 0; i < sz; i++) ans[i] = i;
| ^
a.cc: At global scope:
a.cc:91:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
91 | main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:96:5: error: 'n' was not declared in this scope; did you mean 'yn'?
96 | n = readInt();
| ^
| yn
a.cc:61:13: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
61 | #define int __int64
| ^~~~~~~
a.cc:97:13: note: in expansion of macro 'int'
97 | vector <int> d(n - 1);
| ^~~
a.cc:97:16: error: template argument 1 is invalid
97 | vector <int> d(n - 1);
| ^
a.cc:97:16: error: template argument 2 is invalid
a.cc:98:16: error: template argument 2 is invalid
98 | vector <int> perm(n - 1);
| ^
a.cc:99:14: error: expected ';' before 'i'
99 | for (int i = 0; i < n; i++) {
| ^
a.cc:99:21: error: 'i' was not declared in this scope
99 | for (int i = 0; i < n; i++) {
| ^
a.cc:100:9: error: 'a' was not declared in this scope
100 | a[i] = readInt();
| ^
a.cc:102:14: error: expected ';' before 'i'
102 | for (int i = 0; i < n - 1; i++) {
| ^
a.cc:102:21: error: 'i' was not declared in this scope
102 | for (int i = 0; i < n - 1; i++) {
| ^
a.cc:103:16: error: 'a' was not declared in this scope
103 | d[i] = a[i + 1] - a[i];
| ^
a.cc:107:9: error: expected ';' before 'M'
107 | int M = readInt(), K = readInt();
| ^
a.cc:108:14: error: expected ';' before 'i'
108 | for (int i = 1; i <= M; i++) {
| ^
a.cc:108:21: error: 'i' was not declared in this scope
108 | for (int i = 1; i <= M; i++) {
| ^
a.cc:108:26: error: 'M' was not declared in this scope
108 | for (int i = 1; i <= M; i++) {
| ^
a.cc:109:13: error: expected ';' before 'x'
109 | int x = readInt() - 1;
| ^
a.cc:110:19: error: 'x' was not declared in this scope
110 | swap(perm[x - 1], perm[x]);
| ^
a.cc:113:16: error: template argument 2 is invalid
113 | vector <int> kekekek = binpow(perm, K);
| ^
a.cc:113:41: error: 'K' was not declared in this scope
113 | vector <int> kekekek = binpow(perm, K);
| ^
a.cc:114:9: error: expected ';' before 'cur'
114 | int cur = a[0];
| ^~~
a.cc:115:14: error: expected ';' before 'i'
115 | for (int i = 0; i < n - 1; i++) {
| ^
a.cc:115:21: error: 'i' was not declared in this scope
115 | for (int i = 0; i < n - 1; i++) {
| ^
a.cc:116:17: error: 'cur' was not declared in this scope
116 | cout << cur << endl;
| ^~~
a.cc:119:13: error: 'cur' was not declared in this scope
119 | cout << cur;
| ^~~
|
s147468963 | p03953 | C++ | #include <iostream>
#include <fstream>
using namespace std;
const int nmax=100005;
int x[nmax],p[nmax],dif[nmax],viz[nmax],cyc[nmax],newp[nmax];
long long k;
int n,i,j,xx,m,nr;
int main()
{
//freopen("data.in","r",stdin);
ios_base::sycn_with_stdio(false);
cin>>n;
for(i=1;i<=n;i++)
{
cin>>x[i];
}
for(i=1;i<n;i++)
dif[i]=(x[i+1]-x[i]),p[i]=i;
cin>>m>>k;
for(i=1;i<=m;i++)
{
cin>>xx;
swap(p[xx-1],p[xx]);
}
for(i=1;i<n;i++)
if(!viz[i])
{
nr=0;xx=i;
while(!viz[xx])
{
viz[xx]=1;
cyc[nr++]=xx;
xx=p[xx];
}
long long md=(k)%(long long)nr;
for(j=0;j<nr;j++)
newp[cyc[j]]=(cyc[(j+md)%nr]);
}
for(i=1;i<=n;i++)
{
if(i>1)x[i]=x[i-1]+dif[newp[i-1]];
cout<<x[i]<<'\n';
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:15: error: 'sycn_with_stdio' is not a member of 'std::ios_base'
11 | ios_base::sycn_with_stdio(false);
| ^~~~~~~~~~~~~~~
|
s809832917 | p03953 | C++ | # include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn(1e5 + 5);
int n, m, b[maxn], que[maxn], len, vis[maxn];
ll k, f[maxn], g[maxn];
int main() {
int i, j;
scanf("%d", &n);
for (i = 1; i <= n; ++i) scanf("%lld", &f[i]), b[i] = i;
for (i = n; i; --i) f[i] -= f[i - 1];
scanf("%d%lld", &m, &k);
for (i = 1; i <= m; ++i) scanf("%d", &j), swap(b[j], b[j + 1]);
for (i = 1; i <= n; ++i)
if (!vis[i]) {
vis[i] = 1, j = b[i], que[len = 1] = i;
while (!vis[j]) que[++len] = j, vis[j] = 1, j = b[j];
for (j = 1; j <= len; ++j) nxt[que[j]] = que[(k + j - 1) % len + 1];
}
for (i = 1; i <= n; ++i) g[i] = f[nxt[i]];
for (i = 1; i <= n; ++i) g[i] += g[i - 1], printf("%lld\n", g[i]);
return 0;
} | a.cc: In function 'int main()':
a.cc:21:52: error: 'nxt' was not declared in this scope
21 | for (j = 1; j <= len; ++j) nxt[que[j]] = que[(k + j - 1) % len + 1];
| ^~~
a.cc:23:43: error: 'nxt' was not declared in this scope
23 | for (i = 1; i <= n; ++i) g[i] = f[nxt[i]];
| ^~~
|
s704182948 | p03953 | C++ | #include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 255050
ll n,m,k;
ll a[N],x[N];
vec v(80);
vec<vec> mv(N,v);
main(){
n=in();
rep(i,n)x[i]=in();
m=in();
k=lin();
rep(i,m)a[i]=in();
rep(i,n-1)mv[0][i]=i;
rep(i,m)swap(mv[0][a[i]-1],mv[0][a[i]-2]);
rep(i,63){
rep(j,n-1){
mv[i+1][j]=mv[i][mv[i][j]];
}
}
/*
rep(i,3){
rep(j,n)cout<<mv[i][j]<<" ";
cout<<endl;
}
*/
vec now(n),temp(n);
rep(i,n-1)now[i]=i;
rep(i,63){
if(k&(1ll<<i)){
rep(j,n-1){
temp[j]=now[mv[i][j]];
/*printf("mv[i][j]=%d now[mv[i][j]]=%d\n",mv[i][j],now[mv[i][j]]);
*/
}
/*cout<<"now="<<i<<endl;
rep(ii,n-1)cout<<temp[i]<<" ";
cout<<endl;
*/
now=temp;
}
}
/*
rep(i,n-1)cout<<now[i]<<" ";
cout<<endl;
*/
vec d(n);
rep(i,n-1)d[i]=x[i+1]-x[i];
/*
rep(i,n-1)cout<<d[i]<<" ";
*/
cout<<x[0]<<endl;
rep(i,n-1){
x[i+1]=x[i]+d[now[i]];
cout<<x[i+1]<<endl;
}
} | a.cc:35:13: error: 'std::vector<int>' is not a template
35 | #define vec vector<int>
| ^~~~~~~~~~~
a.cc:56:1: note: in expansion of macro 'vec'
56 | vec<vec> mv(N,v);
| ^~~
a.cc:56:16: error: no matching function for call to 'std::vector<int>::vector(int, std::vector<int>&)'
56 | vec<vec> mv(N,v);
| ^
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from a.cc:8:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed:
a.cc:56:16: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
56 | vec<vec> mv(N,v);
| ^
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>]'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
678 | vector(initializer_list<value_type> __l,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>; std::__type_identity_t<_Alloc> = std::allocator<int>]'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>; std::false_type = std::false_type]'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>; std::true_type = std::true_type]'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>; std::__type_identity_t<_Alloc> = std::allocator<int>]'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; value_type = int; allocator_type = std::allocator<int>]'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
569 | vector(size_type __n, const value_type& __value,
| ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; allocator_type = std::allocator<int>]'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::allocator_type&' {aka 'const std::allocator<int>&'}
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>]'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
a.cc:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
58 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:64:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[long long int]' for array subscript
64 | rep(i,n-1)mv[0][i]=i;
| ^
a.cc:65:23: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[long long int]' for array subscript
65 | rep(i,m)swap(mv[0][a[i]-1],mv[0][a[i]-2]);
| ^
a.cc:65:37: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[long long int]' for array subscript
65 | rep(i,m)swap(mv[0][a[i]-1],mv[0][a[i]-2]);
| ^
a.cc:68:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[long long int]' for array subscript
68 | mv[i+1][j]=mv[i][mv[i][j]];
| ^
a.cc:68:35: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[long long int]' for array subscript
68 | mv[i+1][j]=mv[i][mv[i][j]];
| ^
a.cc:82:34: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[long long int]' for array subscript
82 | temp[j]=now[mv[i][j]];
| ^
|
s541089439 | p03953 | C++ | }
for (int i=1;i<n;i++)
{
if (vis[i]) continue;
int x=i,cnt=0,y;
while(!vis[x]) cnt++,vis[x]=1,x=a[x];
y=x=i;
for (int j=1;j<=(int)(k%cnt);j++) y=a[y];
while(!ans[x]) ans[x]=v[y+1]-v[y],x=a[x],y=a[y];
}
ll now=v[1];
for (int i=1;i<=n;i++) printf("%lld.0\n",now),now+=ans[i];
return 0;
}
| a.cc:1:9: error: expected declaration before '}' token
1 | }
| ^
a.cc:2:5: error: expected unqualified-id before 'for'
2 | for (int i=1;i<n;i++)
| ^~~
a.cc:2:18: error: 'i' does not name a type
2 | for (int i=1;i<n;i++)
| ^
a.cc:2:22: error: 'i' does not name a type
2 | for (int i=1;i<n;i++)
| ^
a.cc:11:5: error: 'll' does not name a type
11 | ll now=v[1];
| ^~
a.cc:12:5: error: expected unqualified-id before 'for'
12 | for (int i=1;i<=n;i++) printf("%lld.0\n",now),now+=ans[i];
| ^~~
a.cc:12:18: error: 'i' does not name a type
12 | for (int i=1;i<=n;i++) printf("%lld.0\n",now),now+=ans[i];
| ^
a.cc:12:23: error: 'i' does not name a type
12 | for (int i=1;i<=n;i++) printf("%lld.0\n",now),now+=ans[i];
| ^
a.cc:13:5: error: expected unqualified-id before 'return'
13 | return 0;
| ^~~~~~
a.cc:14:1: error: expected declaration before '}' token
14 | }
| ^
|
s214770989 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef double db;
const int N=1e5+10;
int n,m,tot,st,d[N],id[N],nt[N],K,ans[N],q[N],cnt,vs[N],p[N];
signed main(){
scanf("%lld",&n);
for (int i=1;i<=n;i++)scanf("%d",&p[i]);
for (int i=2;i<=n;i++)d[i]=p[i]-p[i-1],id[i]=i;
scanf("%lld%lld",&m,&K);
for (int i=1;i<=m;i++){
scanf("%lld",&x);
swap(id[x],id[x+1]);
}
for (int i=2;i<=n;i++) nt[id[i]]=i;
for (int i=2;i<=n;i++)
if (!vs[i]){
int cnt;
for (cnt=0,j=i;!vs[j];j=nt[j]){
q[++cnt]=j;
vs[j]=1;
}
x=K%cnt;k=x%cnt+1;
for (int j=1;j<=cnt;j++){
ans[q[k]]=d[q[j]];
k=k==cnt?1:(k+1);
}
}
int pos=p[1];
for (int i=1;i<=n;i++){
pos+=ans[i];
printf("%.10lf\n",(db)pos);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:31: error: 'x' was not declared in this scope
14 | scanf("%lld",&x);
| ^
a.cc:21:36: error: 'j' was not declared in this scope
21 | for (cnt=0,j=i;!vs[j];j=nt[j]){
| ^
a.cc:25:25: error: 'x' was not declared in this scope
25 | x=K%cnt;k=x%cnt+1;
| ^
a.cc:25:33: error: 'k' was not declared in this scope
25 | x=K%cnt;k=x%cnt+1;
| ^
|
s606183067 | p03953 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
const int maxn=1e5+5;
ll k;
int n,m;
int c[maxn];
bool bo[maxn];
int a[maxn],ans[maxn];
int read() {
int x=0,f=1;char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
return x*f;
}
int main() {
n=read();
for(int i=1;i<=n;i++)
a[i]=read(),c[i]=i;
m=read();scanf("%lld",&k);
for(int i=1;i<=m;i++) {
int x=read();
swap(c[x],c[x+1]);
}
for(int i=1;i<=n;i++)
if(!bo[i]) {
int u=i,cnt=0,step,goal;
while(!bo[c[u]])
bo[c[u]]=1,cnt++,u=c[u];
step=k%cnt,goal=u=i;
for(int j=1;j<=step;j++)
goal=c[goal];
for(int j=1;j<=cnt;j++)
ans[u]=goal,u=c[u],goal=c[goal];
}
for(int i=2;i<=n;i++) {
int x=ans[i];
ans[i]=a[x]-a[x-1];
}
ans[1]=a[1];
for(int i=1;i<=n;i++)
ans[i]+=ans[i-1],printf("%.1lf\n",(double)ans[i]);
return 0;
}
| a.cc:8:1: error: 'll' does not name a type
8 | ll k;
| ^~
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:25:32: error: 'k' was not declared in this scope
25 | m=read();scanf("%lld",&k);
| ^
|
s592849419 | p03953 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int a[MAXN],d[MAXN],n,m,p[MAXN],ret[MAXN],t[MAXN];
typedef long long ll;
ll k;
inline void ksm(ll k)
{
for(int i=1;i<=n;++i)ret[i]=i;
while(k){
if(k&1){
for(int i=1;i<=n;++i)ret[i]=p[ret[i]];
}
for(int i=1;i<=n;++i)t[i]=p[i];
for(int i=1;i<=n;++i)p[i]=t[p[i]];
k>>=1;
}
}
int v[MAXN],ans[MAXN];
int main()
{
cin>>n;
for(int i=1;i<=n;++i)scanf("%d",a+i),d[i]=a[i]-a[i-1],v[i]=i;
cin>>m>>k;
for(int i=1;i<=m;++i){
int x;
scanf("%d",&x);
swap(v[x],v[x+1]);
}
for(int i=1;i<=n;++i)p[v[i]]=i;
ksm(k);
for(int i=1;i<=n;++i)ans[ret[i]]=i;
for(int i=1;i<=n;++i)
printf("%d ",sum+=d[ans[i]]);
return 0;
}
| a.cc: In function 'int main()':
a.cc:36:30: error: 'sum' was not declared in this scope
36 | printf("%d ",sum+=d[ans[i]]);
| ^~~
|
s309850117 | p03953 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int a[MAXN],d[MAXN],n,m,p[MAXN],ret[MAXN],t[MAXN];
typedef long long ll;
ll k;
inline void ksm(ll k)
{
for(int i=1;i<=n;++i)ret[i]=i;
while(k){
if(k&1){
for(int i=1;i<=n;++i)ret[i]=p[ret[i]];
}
for(int i=1;i<=n;++i)t[i]=p[i];
for(int i=1;i<=n;++i)p[i]=t[p[i]];
k>>=1;
}
int v[MAXN],ans[MAXN];
int main()
{
cin>>n;
for(int i=1;i<=n;++i)scanf("%d",a+i),d[i]=a[i]-a[i-1],v[i]=i;
cin>>m>>k;
for(int i=1;i<=m;++i){
int x;
scanf("%d",&x);
swap(v[x],v[x+1]);
}
for(int i=1;i<=n;++i)p[v[i]]=i;
ksm(k);
for(int i=1;i<=n;++i)ans[ret[i]]=i;
for(int i=1;i<=n;++i)
printf("%d ",sum+=d[ans[i]]);
return 0;
}
| a.cc: In function 'void ksm(ll)':
a.cc:21:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
21 | int main()
| ^~
a.cc:21:9: note: remove parentheses to default-initialize a variable
21 | int main()
| ^~
| --
a.cc:21:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:22:1: error: a function-definition is not allowed here before '{' token
22 | {
| ^
a.cc:37:2: error: expected '}' at end of input
37 | }
| ^
a.cc:10:1: note: to match this '{'
10 | {
| ^
|
s932472145 | p03953 | C++ | inline | a.cc:1:7: error: expected unqualified-id at end of input
1 | inline
| ^
|
s891613175 | p03953 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
int n,m,x[N],a[N];
int b[N],vis[N],tmp[N],t;
int ans[N];
LL K;
int main(){
scanf("%d",&n);
for (int i=1;i<=n;i++)
scanf("%d",&x[i]);
scanf("%d%lld",&m,&K);
for (int i=1;i<n;i++)
b[i]=i;
for (int i=1;i<=m;i++){
scanf("%d",&a[i]);
swap(b[a[i]-1],b[a[i]]);
}
memset(vis,0,sizeof vis);
for (int i=1;i<n;i++){
if (vis[i])
continue;
vis[i]=1;
tmp[t=1]=i;
for (int j=b[i];j!=i;j=b[j])
vis[tmp[++t]=j]=1;
int d=K%t;
for (int j=1;j<=t;j++)
ans[tmp[(j-1+d)%t+1]]=tmp[j];
}
LL tot=x[1];
printf("%lld\n",tot);
for (int il=1;i<n;i++)
printf("%lld\n",tot+=x[ans[i]+1]-x[ans[i]]);
return 0;
} | a.cc: In function 'int main()':
a.cc:34:23: error: 'i' was not declared in this scope; did you mean 'il'?
34 | for (int il=1;i<n;i++)
| ^
| il
|
s116998634 | p03953 | C++ | #include <cstdio>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
const int N=100005;
int n,m;
int x[N],a[N],poi[N],cf[N],cnt;
long long k;
int block[N],num[N],vis[N];
vector<int>q[N];
void dfs(int x,int dep)
{
num[x]=dep;vis[x]=1;block[x]=cnt;
q[cnt].push_back(x);
if(!vis[poi[x]]) dfs(poi[x],dep+1);
}
signed main()
{
scanf("%lld",&n);
for(int i=1;i<=n;++i) scanf("%lld",&x[i]);
for(int i=1;i<n;++i) cf[i]=x[i+1]-x[i];
scanf("%lld%lld",&m,&k);
for(int i=1;i<n;++i)poi[i]=i;
for(int i=1;i<=m;++i) {scanf("%lld",&a[i]);swap(poi[a[i]],poi[a[i]-1]);}
for(int i=1;i<n;++i) if(!vicf[i]) cnt++,dfs(i,0);
printf("%lld\n",x[1]);
int now=x[1];
for(int i=1;i<n;i++)
{
now+=cf[q[block[i]][(num[i]+k)%q[block[i]].size()]];
printf("%lld\n",now);
}
} | a.cc: In function 'int main()':
a.cc:30:30: error: 'vicf' was not declared in this scope
30 | for(int i=1;i<n;++i) if(!vicf[i]) cnt++,dfs(i,0);
| ^~~~
|
s676196354 | p03953 | C++ | def process(x, a, k):
n = len(x)
f = range(0, n)
for i in a:
f[i], f[i+1] = f[i+1], f[i]
#print 'f=%s' % str(f)
b = 1
while b<=k:
if (k&b)!=0:
t = [0 for i in xrange(n)]
for i in xrange(n):
t[i] = x[f[i]]
x = [i for i in t]
#print 'x=%s' % str(x)
t = [0 for i in f]
for i in xrange(n):
t[i] = f[f[i]]
f = [i for i in t]
#print 'f=%s' % str(f)
b <<= 1
return x
def main():
n = int(raw_input().strip())
x = [int(i) for i in raw_input().strip().split()]
for i in xrange(len(x)-1, 0, -1):
x[i] = x[i]-x[i-1]
m, k = [int(i) for i in raw_input().strip().split()]
a = [int(i) for i in raw_input().strip().split()]
for i in xrange(len(a)):
a[i] -= 2
r = process(x[1:], a, k)
print x[0]
for i in xrange(1, len(x)):
x[i] = x[i-1]+r[i-1]
print x[i]
if __name__ == '__main__':
main() | a.cc:6:6: error: invalid preprocessing directive #print
6 | #print 'f=%s' % str(f)
| ^~~~~
a.cc:14:14: error: invalid preprocessing directive #print
14 | #print 'x=%s' % str(x)
| ^~~~~
a.cc:19:10: error: invalid preprocessing directive #print
19 | #print 'f=%s' % str(f)
| ^~~~~
a.cc:38:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
38 | if __name__ == '__main__':
| ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
1 | def process(x, a, k):
| ^~~
|
s832490578 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,m,f[maxn],fk[maxn],dep[maxn];
LL k,x[maxn],y[maxn];
int main()
{
int i,pos;
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%lld",&x[i]);
for (i=n;i>=1;i--) x[i]-=x[i-1];
for (i=1;i<=n;i++) f[i]=i;
scanf("%d%lld",&m,&k);
for (i=1;i<=m;i++)
{
scanf("%d",&pos);
swap(f[pos],f[pos+1]);
}
for (i=1;i<=n;i++)
if (!dep[i])
{
int u=i,v,move;
while (1)
{
dep[f[u]]=dep[u]+1;
u=f[u];
if (u==i) break;
}
for (move=k%dep[i],v=i;move--;) v=f[v];
for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
}
for (i=1;i<=n;i++) y[i]=x[fk[i]];
for (i=1;i<=n;i++)
y[i]+=y[i-1],printf("%lld\n",y[d]);
}
| a.cc:6:11: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:20: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:30: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:7:8: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc:7:16: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:13:42: error: 'x' was not declared in this scope
13 | for (i=1;i<=n;i++) scanf("%lld",&x[i]);
| ^
a.cc:14:28: error: 'x' was not declared in this scope
14 | for (i=n;i>=1;i--) x[i]-=x[i-1];
| ^
a.cc:15:28: error: 'f' was not declared in this scope
15 | for (i=1;i<=n;i++) f[i]=i;
| ^
a.cc:20:22: error: 'f' was not declared in this scope
20 | swap(f[pos],f[pos+1]);
| ^
a.cc:23:22: error: 'dep' was not declared in this scope; did you mean 'dup'?
23 | if (!dep[i])
| ^~~
| dup
a.cc:28:37: error: 'f' was not declared in this scope
28 | dep[f[u]]=dep[u]+1;
| ^
a.cc:32:59: error: 'f' was not declared in this scope
32 | for (move=k%dep[i],v=i;move--;) v=f[v];
| ^
a.cc:33:30: error: 'fk' was not declared in this scope; did you mean 'k'?
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^~
| k
a.cc:33:40: error: 'f' was not declared in this scope
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^
a.cc:35:28: error: 'y' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:33: error: 'x' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:35: error: 'fk' was not declared in this scope; did you mean 'k'?
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^~
| k
a.cc:37:17: error: 'y' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[d]);
| ^
a.cc:37:48: error: 'd' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[d]);
| ^
|
s771521929 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,m,f[maxn],fk[maxn],dep[maxn];
LL k,x[maxn],y[maxn];
int main()
{
int i,pos;
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%lld",&x[i]);
for (i=n;i>=1;i--) x[i]-=x[i-1];
for (i=1;i<=n;i++) f[i]=i;
scanf("%d%lld",&m,&k);
for (i=1;i<=m;i++)
{
scanf("%d",&pos);
swap(f[pos],f[pos+1]);
}
for (i=1;i<=n;i++)
if (!dep[i])
{
int u=i,v,move;
while (1)
{
dep[f[u]]=dep[u]+1;
u=f[u];
if (u==i) break;
}
for (move=k%dep[i],v=i;move--;) v=f[v];
for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
}
for (i=1;i<=n;i++) y[i]=x[fk[i]];
for (i=1;i<=n;i++)
y[i]+=y[i-1],printf("%lld\n",y[i]);
}
| a.cc:6:11: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:20: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:30: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:7:8: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc:7:16: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:13:42: error: 'x' was not declared in this scope
13 | for (i=1;i<=n;i++) scanf("%lld",&x[i]);
| ^
a.cc:14:28: error: 'x' was not declared in this scope
14 | for (i=n;i>=1;i--) x[i]-=x[i-1];
| ^
a.cc:15:28: error: 'f' was not declared in this scope
15 | for (i=1;i<=n;i++) f[i]=i;
| ^
a.cc:20:22: error: 'f' was not declared in this scope
20 | swap(f[pos],f[pos+1]);
| ^
a.cc:23:22: error: 'dep' was not declared in this scope; did you mean 'dup'?
23 | if (!dep[i])
| ^~~
| dup
a.cc:28:37: error: 'f' was not declared in this scope
28 | dep[f[u]]=dep[u]+1;
| ^
a.cc:32:59: error: 'f' was not declared in this scope
32 | for (move=k%dep[i],v=i;move--;) v=f[v];
| ^
a.cc:33:30: error: 'fk' was not declared in this scope; did you mean 'k'?
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^~
| k
a.cc:33:40: error: 'f' was not declared in this scope
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^
a.cc:35:28: error: 'y' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:33: error: 'x' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:35: error: 'fk' was not declared in this scope; did you mean 'k'?
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^~
| k
a.cc:37:17: error: 'y' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[i]);
| ^
|
s134742663 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,m,f[maxn],fk[maxn],dep[maxn];
LL k,x[maxn],y[maxn];
int main()
{
int i,pos;
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%lld",&x[i]);
for (i=n;i>=1;i--) x[i]-=x[i-1];
for (i=1;i<=n;i++) f[i]=i;
scanf("%d%lld",&m,&k);
for (i=1;i<=m;i++)
{
scanf("%d",&pos);
swap(f[pos],f[pos+1]);
}
for (i=1;i<=n;i++)
if (!dep[i])
{
int u=i,v,move;
while (1)
{
dep[f[u]]=dep[u]+1;
u=f[u];
if (u==i) break;
}
for (move=k%dep[i],v=i;move--;) v=f[v];
for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
}
for (i=1;i<=n;i++) y[i]=x[fk[i]];
for (i=1;i<=n;i++)
y[i]+=y[i-1],printf("%lld\n",y[d]);
}
| a.cc:6:11: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:20: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:30: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:7:8: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc:7:16: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:13:42: error: 'x' was not declared in this scope
13 | for (i=1;i<=n;i++) scanf("%lld",&x[i]);
| ^
a.cc:14:28: error: 'x' was not declared in this scope
14 | for (i=n;i>=1;i--) x[i]-=x[i-1];
| ^
a.cc:15:28: error: 'f' was not declared in this scope
15 | for (i=1;i<=n;i++) f[i]=i;
| ^
a.cc:20:22: error: 'f' was not declared in this scope
20 | swap(f[pos],f[pos+1]);
| ^
a.cc:23:22: error: 'dep' was not declared in this scope; did you mean 'dup'?
23 | if (!dep[i])
| ^~~
| dup
a.cc:28:37: error: 'f' was not declared in this scope
28 | dep[f[u]]=dep[u]+1;
| ^
a.cc:32:59: error: 'f' was not declared in this scope
32 | for (move=k%dep[i],v=i;move--;) v=f[v];
| ^
a.cc:33:30: error: 'fk' was not declared in this scope; did you mean 'k'?
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^~
| k
a.cc:33:40: error: 'f' was not declared in this scope
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^
a.cc:35:28: error: 'y' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:33: error: 'x' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:35: error: 'fk' was not declared in this scope; did you mean 'k'?
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^~
| k
a.cc:37:17: error: 'y' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[d]);
| ^
a.cc:37:48: error: 'd' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[d]);
| ^
|
s296024806 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,m,f[maxn],fk[maxn],dep[maxn];
LL k,x[maxn],y[maxn];
int main()
{
int i,pos;
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%lld",&x[i]);
for (i=n;i>=1;i--) x[i]-=x[i-1];
for (i=1;i<=n;i++) f[i]=i;
scanf("%d%lld",&m,&k);
for (i=1;i<=m;i++)
{
scanf("%d",&pos);
swap(f[pos],f[pos+1]);
}
for (i=1;i<=n;i++)
if (!dep[i])
{
int u=i,v,move;
while (1)
{
dep[f[u]]=dep[u]+1;
u=f[u];
if (u==i) break;
}
for (move=k%dep[i],v=i;move--;) v=f[v];
for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
}
for (i=1;i<=n;i++) y[i]=x[fk[i]];
for (i=1;i<=n;i++)
y[i]+=y[i-1],printf("%lld\n",y[i]);
}
| a.cc:6:11: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:20: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:30: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:7:8: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc:7:16: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:13:42: error: 'x' was not declared in this scope
13 | for (i=1;i<=n;i++) scanf("%lld",&x[i]);
| ^
a.cc:14:28: error: 'x' was not declared in this scope
14 | for (i=n;i>=1;i--) x[i]-=x[i-1];
| ^
a.cc:15:28: error: 'f' was not declared in this scope
15 | for (i=1;i<=n;i++) f[i]=i;
| ^
a.cc:20:22: error: 'f' was not declared in this scope
20 | swap(f[pos],f[pos+1]);
| ^
a.cc:23:22: error: 'dep' was not declared in this scope; did you mean 'dup'?
23 | if (!dep[i])
| ^~~
| dup
a.cc:28:37: error: 'f' was not declared in this scope
28 | dep[f[u]]=dep[u]+1;
| ^
a.cc:32:59: error: 'f' was not declared in this scope
32 | for (move=k%dep[i],v=i;move--;) v=f[v];
| ^
a.cc:33:30: error: 'fk' was not declared in this scope; did you mean 'k'?
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^~
| k
a.cc:33:40: error: 'f' was not declared in this scope
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^
a.cc:35:28: error: 'y' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:33: error: 'x' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:35: error: 'fk' was not declared in this scope; did you mean 'k'?
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^~
| k
a.cc:37:17: error: 'y' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[i]);
| ^
|
s106164161 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,m,f[maxn],fk[maxn],dep[maxn];
LL k,x[maxn],y[maxn];
int main()
{
int i,pos;
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%lld",&x[i]);
for (i=n;i>=1;i--) x[i]-=x[i-1];
for (i=1;i<=n;i++) f[i]=i;
scanf("%d%lld",&m,&k);
for (i=1;i<=m;i++)
{
scanf("%d",&pos);
swap(f[pos],f[pos+1]);
}
for (i=1;i<=n;i++)
if (!dep[i])
{
int u=i,v,move;
while (1)
{
dep[f[u]]=dep[u]+1;
u=f[u];
if (u==i) break;
}
for (move=k%dep[i],v=i;move--;) v=f[v];
for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
}
for (i=1;i<=n;i++) y[i]=x[fk[i]];
for (i=1;i<=n;i++)
y[i]+=y[i-1],printf("%lld\n",y[d]);
}
| a.cc:6:11: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:20: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:30: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:7:8: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc:7:16: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:13:42: error: 'x' was not declared in this scope
13 | for (i=1;i<=n;i++) scanf("%lld",&x[i]);
| ^
a.cc:14:28: error: 'x' was not declared in this scope
14 | for (i=n;i>=1;i--) x[i]-=x[i-1];
| ^
a.cc:15:28: error: 'f' was not declared in this scope
15 | for (i=1;i<=n;i++) f[i]=i;
| ^
a.cc:20:22: error: 'f' was not declared in this scope
20 | swap(f[pos],f[pos+1]);
| ^
a.cc:23:22: error: 'dep' was not declared in this scope; did you mean 'dup'?
23 | if (!dep[i])
| ^~~
| dup
a.cc:28:37: error: 'f' was not declared in this scope
28 | dep[f[u]]=dep[u]+1;
| ^
a.cc:32:59: error: 'f' was not declared in this scope
32 | for (move=k%dep[i],v=i;move--;) v=f[v];
| ^
a.cc:33:30: error: 'fk' was not declared in this scope; did you mean 'k'?
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^~
| k
a.cc:33:40: error: 'f' was not declared in this scope
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^
a.cc:35:28: error: 'y' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:33: error: 'x' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:35: error: 'fk' was not declared in this scope; did you mean 'k'?
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^~
| k
a.cc:37:17: error: 'y' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[d]);
| ^
a.cc:37:48: error: 'd' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[d]);
| ^
|
s674045174 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,m,f[maxn],fk[maxn],dep[maxn];
LL k,x[maxn],y[maxn];
int main()
{
int i,pos;
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%lld",&x[i]);
for (i=n;i>=1;i--) x[i]-=x[i-1];
for (i=1;i<=n;i++) f[i]=i;
scanf("%d%lld",&m,&k);
for (i=1;i<=m;i++)
{
scanf("%d",&pos);
swap(f[pos],f[pos+1]);
}
for (i=1;i<=n;i++)
if (!dep[i])
{
int u=i,v,move;
while (1)
{
dep[f[u]]=dep[u]+1;
u=f[u];
if (u==i) break;
}
for (move=k%dep[i],v=i;move--;) v=f[v];
for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
}
for (i=1;i<=n;i++) y[i]=x[fk[i]];
for (i=1;i<=n;i++)
y[i]+=y[i-1],printf("%lld\n",y[i]);
}
| a.cc:6:11: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:20: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:6:30: error: 'maxn' was not declared in this scope
6 | int n,m,f[maxn],fk[maxn],dep[maxn];
| ^~~~
a.cc:7:8: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc:7:16: error: 'maxn' was not declared in this scope
7 | LL k,x[maxn],y[maxn];
| ^~~~
a.cc: In function 'int main()':
a.cc:13:42: error: 'x' was not declared in this scope
13 | for (i=1;i<=n;i++) scanf("%lld",&x[i]);
| ^
a.cc:14:28: error: 'x' was not declared in this scope
14 | for (i=n;i>=1;i--) x[i]-=x[i-1];
| ^
a.cc:15:28: error: 'f' was not declared in this scope
15 | for (i=1;i<=n;i++) f[i]=i;
| ^
a.cc:20:22: error: 'f' was not declared in this scope
20 | swap(f[pos],f[pos+1]);
| ^
a.cc:23:22: error: 'dep' was not declared in this scope; did you mean 'dup'?
23 | if (!dep[i])
| ^~~
| dup
a.cc:28:37: error: 'f' was not declared in this scope
28 | dep[f[u]]=dep[u]+1;
| ^
a.cc:32:59: error: 'f' was not declared in this scope
32 | for (move=k%dep[i],v=i;move--;) v=f[v];
| ^
a.cc:33:30: error: 'fk' was not declared in this scope; did you mean 'k'?
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^~
| k
a.cc:33:40: error: 'f' was not declared in this scope
33 | for (fk[i]=v;u=f[u],v=f[v],u!=i;) fk[u]=v;
| ^
a.cc:35:28: error: 'y' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:33: error: 'x' was not declared in this scope
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^
a.cc:35:35: error: 'fk' was not declared in this scope; did you mean 'k'?
35 | for (i=1;i<=n;i++) y[i]=x[fk[i]];
| ^~
| k
a.cc:37:17: error: 'y' was not declared in this scope
37 | y[i]+=y[i-1],printf("%lld\n",y[i]);
| ^
|
s820192303 | p03953 | C++ | #include<bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;
int n,m,x[N],a[N];
long long k;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>x[i];
cin>>m>>k;
for(int i=1;i<=m;i++)cin>>a[i];
k%=4;
for(int cas=1;cas<=k;cas++)
{
for(int i=1;i<=m;i++)
{
int p=a[i];
x[p]=2*x[p-1]-x[p]+2*x[p+1]-x[p];
x[p]/=2;
}
// for(int i=1;i<=n;i++)cout<<x[i]<<' ';
// puts("");
}
for(int i=1;i<=n;i++)cout<<x[i]<<endl;
return 0;
}
| cc1plus: error: '::main' must return 'int'
|
s254532055 | p03953 | C++ | #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const int N = 1e5+5;
ll A[N];
a[N];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
for(int i = 1; i <= n; ++i)
cin >> A[i];
int m;
ll k;
cin >> m >> k;
for(int i = 0; i < m; ++i)
cin >> a[i];
k %= 4;
while(k--)
for(int i = 0; i < m; ++i)
A[a[i]] = A[a[i]-1] + A[a[i]+1] - A[a[i]];
for(int i = 1; i <= n; ++i)
cout << A[i] << "\n";
}
| a.cc:13:1: error: 'a' does not name a type
13 | a[N];
| ^
a.cc: In function 'int main()':
a.cc:25:24: error: 'a' was not declared in this scope
25 | cin >> a[i];
| ^
a.cc:29:27: error: 'a' was not declared in this scope
29 | A[a[i]] = A[a[i]-1] + A[a[i]+1] - A[a[i]];
| ^
|
s482910317 | p03953 | C++ | #include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m;
ll k;
ll x[100005];
int a[100005];
int next[100005];
int tmp[100005];
int res[100005];
int main(void){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lld",&x[i]);
}
for(int i=0;i<n-1;i++){
next[i]=i;
res[i]=i;
}
scanf("%d%lld",&m,&k);
for(int i=0;i<m;i++){
scanf("%d",&a[i]);
a[i]--;
}
for(ll i=0;i<m;i++){
swap(next[a[i]-1],next[a[i]]);
}
while(k>0){
if(k&1){
for(int i=0;i<n-1;i++){
res[i]=next[res[i]];
}
}
for(int i=0;i<n-1;i++){
tmp[i]=next[next[i]];
}
for(int i=0;i<n-1;i++){
next[i]=tmp[i];
}
k>>=1;
}
ll now=x[0];
for(int i=0;i<n;i++){
printf("%lld\n",now);
now+=x[res[i]+1]-x[res[i]];
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:34:17: error: reference to 'next' is ambiguous
34 | next[i]=i;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/vector:62,
from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:24:5: note: 'int next [100005]'
24 | int next[100005];
| ^~~~
a.cc:43:22: error: reference to 'next' is ambiguous
43 | swap(next[a[i]-1],next[a[i]]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:24:5: note: 'int next [100005]'
24 | int next[100005];
| ^~~~
a.cc:43:35: error: reference to 'next' is ambiguous
43 | swap(next[a[i]-1],next[a[i]]);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:24:5: note: 'int next [100005]'
24 | int next[100005];
| ^~~~
a.cc:48:40: error: reference to 'next' is ambiguous
48 | res[i]=next[res[i]];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:24:5: note: 'int next [100005]'
24 | int next[100005];
| ^~~~
a.cc:52:32: error: reference to 'next' is ambiguous
52 | tmp[i]=next[next[i]];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:24:5: note: 'int next [100005]'
24 | int next[100005];
| ^~~~
a.cc:52:37: error: reference to 'next' is ambiguous
52 | tmp[i]=next[next[i]];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:24:5: note: 'int next [100005]'
24 | int next[100005];
| ^~~~
a.cc:55:25: error: reference to 'next' is ambiguous
55 | next[i]=tmp[i];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:24:5: note: 'int next [100005]'
24 | int next[100005];
| ^~~~
|
s099224303 | p03953 | C++ | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
void solve() throws IOException {
int n = ni();
int[] x = nia(n);
int m = ni();
long k = nl();
int[] a = nia(m);
int[] y = new int[n - 1];
for (int i = 0; i < n - 1; i++) {
y[i] = i;
}
for (int i = 0; i < m; i++) {
int tmp = y[a[i] - 2];
y[a[i] - 2] = y[a[i] - 1];
y[a[i] - 1] = tmp;
}
y = mul(y, k);
int[] d = new int[n - 1];
for (int i = 0; i < n - 1; i++) {
d[i] = x[i + 1] - x[i];
}
int[] d2 = new int[n - 1];
for (int i = 0; i < n - 1; i++) {
d2[i] = d[y[i]];
}
long ans = x[0];
out.println(ans);
for (int i = 0; i < n - 1; i++) {
ans += d2[i];
out.println(ans);
}
}
int[] mul(int[] a, long x) {
int n = a.length;
int[] b = a.clone();
int[] ret = new int[n];
for (int i = 0; i < n; i++) {
ret[i] = i;
}
while (x > 0) {
if ((x & 1) == 1) {
int[] next = new int[n];
for (int i = 0; i < n; i++) {
next[i] = ret[b[i]];
}
ret = next;
}
int[] tmp = new int[n];
for (int i = 0; i < n; i++) {
tmp[i] = b[b[i]];
}
b = tmp;
x >>= 1;
}
return ret;
}
String ns() throws IOException {
while (!tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine(), " ");
}
return tok.nextToken();
}
int ni() throws IOException {
return Integer.parseInt(ns());
}
long nl() throws IOException {
return Long.parseLong(ns());
}
double nd() throws IOException {
return Double.parseDouble(ns());
}
String[] nsa(int n) throws IOException {
String[] res = new String[n];
for (int i = 0; i < n; i++) {
res[i] = ns();
}
return res;
}
int[] nia(int n) throws IOException {
int[] res = new int[n];
for (int i = 0; i < n; i++) {
res[i] = ni();
}
return res;
}
long[] nla(int n) throws IOException {
long[] res = new long[n];
for (int i = 0; i < n; i++) {
res[i] = nl();
}
return res;
}
class INA {
int[][] a;
INA(int n, int m) throws IOException {
this(n, m, -1);
}
INA(int n, int m, int t) throws IOException {
a = new int[m][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[j][i] = ni() + t;
}
}
}
int[] get(int i) {
return a[i - 1];
}
}
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
public static void main(String[] args) throws IOException {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
tok = new StringTokenizer("");
Main main = new Main();
main.solve();
out.close();
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.io.BufferedReader;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.io.IOException;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.io.InputStreamReader;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.io.PrintWriter;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.*;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Main {
| ^~~~~~
|
s550584284 | p03953 | C++ | #include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);
vector<int> prod_perm(const vector<int>&a, const vector<int> &b) {
//bに置換aを実行して返す。
//すなわち、[0..N]→a になるような置換"→"によって、
//b→ansとなるようなansを求めて返す。
assert(a.size() == b.size());
vector<int>ans(b.size());
rep(i, b.size())ans[i] = b[a[i]];
return ans;
}
vector<int> pow_perm(const vector<int>&perm, const int K) {
//置換permのK乗を返す。
if (K == 0) {
vector<int>ans(K - 1);
rep(i, ans.size())ans[i] = i;
return ans;
}
if (K == 1)return perm;
vector<int>half = pow_perm(perm, K / 2);
if (K % 2 == 0)return prod_perm(half, half);
else return prod_perm(prod_perm(half, half), perm);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M, K;
cin >> N;
int x[100000];
rep(i, N)cin >> x[i];
cin >> M >> K;
int a[100000];
rep(i, M)cin >> a[i];
int perm[100000];
rep(i, N - 1)perm[i] = i;
rep(i, M)swap(perm[a[i] - 2], perm[a[i] - 1]);
auto permK = pow_perm(perm, K);
int dx[100000];
rep(i, N - 1)dx[i] = x[i + 1] - x[i];
int ans = x[0];
rep(i, N - 1) {
cout << ans << endl;
ans += dx[permK[i]];
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:81:31: error: invalid initialization of reference of type 'const std::vector<long int>&' from expression of type 'int64_t [100000]' {aka 'long int [100000]'}
81 | auto permK = pow_perm(perm, K);
| ^~~~
a.cc:50:40: note: in passing argument 1 of 'std::vector<long int> pow_perm(const std::vector<long int>&, int64_t)'
50 | vector<int> pow_perm(const vector<int>&perm, const int K) {
| ~~~~~~~~~~~~~~~~~~^~~~
|
s017183510 | p03953 | Java | import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
public class Main {
void run() {
int n = ni();
long[] x = new long[n + 1];
for (int i = 1; i <= n; ++i) {
x[i] = ni();
}
int m = ni();
long k = sc.nextLong();
int[] a = new int[m];
for (int i = 0; i < m; ++i) {
a[i] = ni();
}
long[] y = x.clone();
long[] d = new long[n];
for (int i = 1; i <= n - 1; ++i) {
d[i] = x[i + 1] - x[i];
}
int[] tikanD = new int[n + 1];
for (int i = 1; i <= n; ++i) {
tikanD[i] = i;
}
for (int i = 0; i < m; ++i) {
int left = a[i] - 1;
int right = a[i];
int tmp = tikanD[left];
tikanD[left] = tikanD[right];
tikanD[right] = tmp;
}
tikanD = pow_tikan(tikanD, k);
int[] d_ = new int[n];
for (int i = 1; i <= n - 1; ++i) {
d_[i] = d[tikanD[i]];
}
d = d_;
long ite = x[1];
System.out.println(ite);
for (int i = 1; i <= n - 1; ++i) {
ite += d[i];
System.out.println(ite);
}
}
int[] tikan(int[] a, int[] b) {
int[] res = new int[a.length];
for (int i = 0; i < a.length; ++i) {
res[i] = i;
}
for (int i = 0; i < a.length; ++i) {
res[i] = b[a[res[i]]];
}
return res;
}
int[] pow_tikan(int[] d, long k) {
int[] res = new int[d.length];
for (int i = 0; i < d.length; ++i) {
res[i] = i;
}
int[] v = d.clone();
while (k > 0) {
if (k % 2 == 1) {
res = tikan(res, v);
}
v = tikan(v, v);
k /= 2;
}
return res;
}
Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
new Main().run();
}
int ni() {
return Integer.parseInt(sc.next());
}
void debug(Object... os) {
System.err.println(Arrays.deepToString(os));
}
class BIT<T> {
int n;
ArrayList<T> bit;
BiFunction<T, T, T> bif;
/**
* 1-indexed なBinary Indexed Treeを構築する
*
* @param n 容量
* @param bif 適用させる関数
* @param sup 初期値
*/
BIT(int n, BiFunction<T, T, T> bif, Supplier<T> sup) {
this.n = n;
bit = new ArrayList<>(n + 1);
for (int i = 0; i < n + 1; ++i) {
bit.add(sup.get());
}
this.bif = bif;
}
/**
* iの位置の値をvで更新する
*
* @param i index
* @param v 新しい値
*/
void update(int i, T v) {
for (int x = i; x <= n; x += x & -x) {
bit.set(x, bif.apply(bit.get(x), v));
}
}
/**
* クエリー
*
* @param defaultValue 初期値
* @param i index
* @return [1, i]までfを適用した結果
*/
T reduce(T defaultValue, int i) {
T ret = defaultValue;
for (int x = i; x > 0; x -= x & -x) {
ret = bif.apply(ret, bit.get(x));
}
return ret;
}
}
long MOD = 1_000_000_007;
/**
* 繰り返し2乗法を用いたべき乗の実装
*
* @return a^r (mod 1,000,000,007)
*/
long pow(long a, long r) {
long sum = 1;
while (r > 0) {
if ((r & 1) == 1) {
sum *= a;
sum %= MOD;
}
a *= a;
a %= MOD;
r >>= 1;
}
return sum;
}
/**
* 組み合わせ
* O(n)
*
* @return {}_nC_r
*/
long C(int n, int r) {
long sum = 1;
for (int i = n; 0 < i; --i) {
sum *= i;
sum %= MOD;
}
long s = 1;
for (int i = r; 0 < i; --i) {
s *= i;
s %= MOD;
}
sum *= pow(s, MOD - 2);
sum %= MOD;
long t = 1;
for (int i = n - r; 0 < i; --i) {
t *= i;
t %= MOD;
}
sum *= pow(t, MOD - 2);
sum %= MOD;
return sum;
}
double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;
/**
* 黄金分割探索
*
* @param left 下限
* @param right 上限
* @param f 探索する関数
* @param comp 上に凸な関数を探索するときは、Comparator.comparingDouble(Double::doubleValue)
* 下に凸な関数を探索するときは、Comparator.comparingDouble(Double::doubleValue).reversed()
* @return 極値の座標x
*/
double goldenSectionSearch(double left, double right, Function<Double, Double> f, Comparator<Double> comp) {
double c1 = divideInternally(left, right, 1, GOLDEN_RATIO);
double c2 = divideInternally(left, right, GOLDEN_RATIO, 1);
double d1 = f.apply(c1);
double d2 = f.apply(c2);
while (right - left > 1e-9) {
if (comp.compare(d1, d2) > 0) {
right = c2;
c2 = c1;
d2 = d1;
c1 = divideInternally(left, right, 1, GOLDEN_RATIO);
d1 = f.apply(c1);
} else {
left = c1;
c1 = c2;
d1 = d2;
c2 = divideInternally(left, right, GOLDEN_RATIO, 1);
d2 = f.apply(c2);
}
}
return right;
}
/**
* [a,b]をm:nに内分する点を返す
*/
double divideInternally(double a, double b, double m, double n) {
return (n * a + m * b) / (m + n);
}
/**
* http://qiita.com/p_shiki37/items/65c18f88f4d24b2c528b
*/
static class FastScanner {
private final InputStream in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
public FastScanner(InputStream in) {
this.in = in;
}
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte()) return buffer[ptr++];
else return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
}
} | Main.java:41: error: incompatible types: possible lossy conversion from long to int
d_[i] = d[tikanD[i]];
^
Main.java:43: error: incompatible types: int[] cannot be converted to long[]
d = d_;
^
2 errors
|
s142791659 | p03953 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
void solve(){
int n;
cin >> n;
vector<int64_t> x(n),y;
rep(i,0,n) cin >> x[i];
y=x;
int m;
int64_t k;
cin >> m >> k;
vector<int64_t> a(m);
rep(i,0,m){
cin >> a[i];
--a[i];
}
int64_t loop=n-1;
vector<int> diff(n-1);
rep(i,0,n-1) diff[i]=x[i+1]-x[i];
vector<int> ans(n);
ans[0]=x[0];
ans[n-1]=x[n-1];
rep(i,1,n) ans[i]=diff[(i+k%loop)%n]);
rep(i,0,n) cout << ans[i] << endl;
}
int main(){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(10);
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:48:41: error: expected ';' before ')' token
48 | rep(i,1,n) ans[i]=diff[(i+k%loop)%n]);
| ^
| ;
|
s685687249 | p03953 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N,M;
ll K;
ll x[100000];
int s[100000];
int ans[100000];
bool vis[100000];
int main(){
cin>>N;
rep(i,N) cin>>x[i];
rep(i,N) x[i]-=x[i+1];
cin>>M>>K;
rep(i,M){
int a;
cin>>a;
a--;
swap(s[a],s[a+1]);
}
rep(i,N-1) if(!vis[i]){
dfs(i,-1);
int n=0;
int v=i;
vector<int> vc;
while(!vis[v]){
vis[v]=1;
vc.pb(v);
v=s[v];
n++;
}
ans[vc[i]]=x[vc[(i+K)%n]];
}
double sum=0;
rep(i,N){
sum+=ans[i];
cout<<sum<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:33:17: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
33 | dfs(i,-1);
| ^~~
| ffs
|
s566139308 | p03953 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'
const int eps = 1e-9;
int N;
ll x[100005], y[100005];
int M;
ll K k;
int a[100005];
bool same(ll x[], ll y[]) {
rep(i, N) if (x[i] != y[i]) return false;
return true;
}
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
rep(i, N) cin >> x[i], y[i] = x[i];
cin >> M >> K;
k = K;
rep(i, M) cin >> a[i], a[i]--;
int cnt = 0;
while (k--) {
rep(i, M) {
y[a[i]] = y[a[i] - 1] + y[a[i] + 1] - y[a[i]];
}
cnt++;
if (same(x, y)) break;
}
if (k > 0) {
K %= cnt;
while (K--) {
rep(i, M) {
x[a[i]] = x[a[i] - 1] + x[a[i] + 1] - x[a[i]];
}
}
rep(i, N) printf("%.10f\n", (double)x[i]);
} else {
rep(i, N) printf("%.10f\n", (double)y[i]);
}
return 0;
}
| a.cc:18:6: error: expected initializer before 'k'
18 | ll K k;
| ^
a.cc: In function 'int main()':
a.cc:32:15: error: 'K' was not declared in this scope
32 | cin >> M >> K;
| ^
a.cc:33:3: error: 'k' was not declared in this scope
33 | k = K;
| ^
|
s939882007 | p03953 | C++ | #include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
namespace {
int x[100000];
int a[100000];
using S = map<int, int>;
S op(const S &p, const S &q, const S &r) { // p + q - r
S ans;
for(auto i : p)
ans[i.first] += i.second;
for(auto i : q)
ans[i.first] += i.second;
for(auto i : r)
ans[i.first] -= i.second;
for(auto i = ans.begin(); i != ans.end();)
if(i->second == 0)
i = ans.erase(i);
else
++i;
return ans;
}
void op(const S *l, const S *r, S *out, int n) {
for(int i = 0; i < n; i++) {
out[i].clear();
for(auto j : r[i])
for(auto k : l[j.first])
out[i][k.first] += k.second * j.second;
for(auto i = ans.begin(); i != ans.end();)
if(i->second == 0)
i = ans.erase(i);
else
++i;
}
}
S s[100000];
S t[100000];
S buf[100000];
}
int main() {
int n, m;
long long k;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", x + i);
scanf("%d %lld", &m, &k);
for(int i = 0; i < m; i++) {
scanf("%d", a + i);
a[i]--;
}
for(int i = 0; i < n; i++)
s[i][i] = t[i][i] = 1;
for(int j = 0; j < m; j++)
s[a[j]] = op(s[a[j] - 1], s[a[j] + 1], s[a[j]]);
for(; k; k >>= 1) {
if(k & 1) {
op(s, t, buf, n);
move(buf, buf + n, t);
}
op(s, s, buf, n);
move(buf, buf + n, s);
}
for(int i = 0; i < n; i++) {
long long ans = 0;
for(auto j : t[i])
ans += (long long) x[j.first] * j.second;
printf("%lld\n", ans);
}
}
| a.cc: In function 'void {anonymous}::op(const S*, const S*, S*, int)':
a.cc:30:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
30 | for(auto i = ans.begin(); i != ans.end();)
| ^~~
| abs
|
s877976149 | p03953 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
int N, M;
ll K;
int x[100010];
int k[100010];
int main() {
scanf("%d", &N);
rep(i, N) {
scanf("%d", &x[i]);
}
scanf("%d %lld", &M, &K);
rep(i, M) {
scanf("%d", &k[i]);
--k[i];
}
if (K>=1000000) return ;
rep(tt, K) {
rep(i, M) {
x[k[i]] = x[k[i]-1]+x[k[i]+1]-x[k[i]];
}
}
rep(i, N) cout << x[i] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:36:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
36 | if (K>=1000000) return ;
| ^~~~~~
|
s806329959 | p03953 | C | #include<stdio.h>
#define NMAX 100001
int x[NMAX], x_fast[NMAX], x_slow[NMAX], a[NMAX];
int main(void){
int N, j, M;
__int64 i, start, end, period, K;
scanf("%ld", &N);
for(j = 1; j <= N; j++){
scanf("%ld", &(x[j]));
x_fast[j] = x_slow[j] = x[j];
}
scanf("%ld", &M);
scanf("%lld", &K);
for(j = 0; j < M; j++) scanf("%ld", &(a[j]));
for(i = 0; i < K; i++){
for(j = 0; j < M; j++) x_fast[a[j]] = x_fast[a[j] - 1] + x_fast[a[j] + 1] - x_fast[a[j]];
for(j = 0; j < M; j++) x_fast[a[j]] = x_fast[a[j] - 1] + x_fast[a[j] + 1] - x_fast[a[j]];
for(j = 0; j < M; j++) x_slow[a[j]] = x_slow[a[j] - 1] + x_slow[a[j] + 1] - x_slow[a[j]];
for(j = 1; j <= N; j++) if(x_fast[j] != x_slow[j]) break;
if(j > N) break;
}
start = i;
for(; i < K; i++){
for(j = 0; j < M; j++) x_fast[a[j]] = x_fast[a[j] - 1] + x_fast[a[j] + 1] - x_fast[a[j]];
for(j = 0; j < M; j++) x_fast[a[j]] = x_fast[a[j] - 1] + x_fast[a[j] + 1] - x_fast[a[j]];
for(j = 0; j < M; j++) x_slow[a[j]] = x_slow[a[j] - 1] + x_slow[a[j] + 1] - x_slow[a[j]];
for(j = 1; j <= N; j++) if(x_fast[j] != x_slow[j]) break;
if(j > N) break;
}
end = i;
period = end - start;
K = (K - i) % period;
for(i = 0; i < K; i++){
for(j = 0; j < M; j++) x_slow[a[j]] = x_slow[a[j] - 1] + x_slow[a[j] + 1] - x_slow[a[j]];
}
for(j = 1; j <= N; j++){
printf("%ld\n", x_slow[j]);
}
return 0;
}
| main.c: In function 'main':
main.c:9:5: error: unknown type name '__int64'; did you mean '__int64_t'?
9 | __int64 i, start, end, period, K;
| ^~~~~~~
| __int64_t
|
s444983957 | p03953 | C++ | #include<bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 9;
int a[100005], h[100005];
map<long long, int> M;
int n, m;
long long k;
long long v[100005];
long long hash() {
long long res = 0;
for (int i = 0; i < n; i++)
res = ((res * v[i]) % mod + a[i]) % mod;
return res;
}
int main() {
ios::sync_with_stdio(false);
scanf("%d", &n);
for (int i = 0; i < n; i++)
v[i] = rand() % mod;
for (int i = 0; i < n; i++)
scanf("%d", a + i);
scanf("%d%lld", &m, &k);
for (int i = 0; i < m; i++)
scanf("%d", h + i), h[i]--;
M[hash()] = 0;
bool d = true;
for (long long x = 0; x < k; ) {
for (int i = 0; i < n; i++)
a[h[i]] = a[h[i] - 1] + a[h[i] + 1] - a[h[i]];
x++;
if (d || x < k) {
d = false;
long long hsh = hash();
if (M.find(hsh) != M.end()) {
long long len = x - M[hsh];
x += ((k - x) / len) * len;
}
else
M[hsh] = x;
}
}
for (int i = 0; i < n; i++)
printf("%d\n", a[i]);
return 0;
}
| a.cc: In function 'int main()':
a.cc:30:11: error: reference to 'hash' is ambiguous
30 | M[hash()] = 0;
| ^~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:11:11: note: 'long long int hash()'
11 | long long hash() {
| ^~~~
a.cc:39:41: error: reference to 'hash' is ambiguous
39 | long long hsh = hash();
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:11:11: note: 'long long int hash()'
11 | long long hash() {
| ^~~~
|
s052830645 | p03954 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
scanf("%d",&n);
printf("%d\n",n);
return 0;
} | a.cc: In function 'int main()':
a.cc:5:17: error: 'n' was not declared in this scope; did you mean 'yn'?
5 | scanf("%d",&n);
| ^
| yn
|
s102154144 | p03954 | C++ | #include<bits/stdc++.h>
using namespace std;
int a[400005],n;
int small(int i,int k)
{
return a[i+1]<=k&&a[i]<=k;//判断小于等于
}
int big(int i,int k)
{
return a[i+1]>k&&a[i]>k;//判断大于
}
int check(int k)
{
for(int i=0;i<=n-1;i++)//从中心开始看是否有两个连续的1或0
{
if(small(n+i,k)==1||small(n-i-1,k)==1)//如果小于等于k的数在最上面
{
return 1;
}
if(big(n+i,k)==1||big(n-i-1,k)==1)如果大于k的数在最上面
{
return 0;
}
}
if(a[1]<=k)
{
return 1;
}else
{
return 0;
}
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=2*n-1;i++)
{
scanf("%d",&a[i]);
}
int l=1,r=2*n-1;//这里r是2*n-1
while(l<r)//二分答案
{
int mid=(l+r)>>1;
if(check(mid)==1)
{
r=mid;
}else
{
l=mid+1;
}
}
cout<<r;
return 0;
} | a.cc: In function 'int check(int)':
a.cc:20:43: error: '\U00005982\U0000679c\U00005927\U00004e8ek\U00007684\U00006570\U00005728\U00006700\U00004e0a\U00009762' was not declared in this scope
20 | if(big(n+i,k)==1||big(n-i-1,k)==1)如果大于k的数在最上面
| ^~~~~~~~~~~~~~~~~~~~~
|
s913180894 | p03954 | C++ | /*************************************************************************
> File Name: AT2165.cpp
> Author: s-k-y
> Mail: zhoutianyi0330@qq.com
> Created Time: 2019年11月07日 星期四 08时54分07秒
************************************************************************/
#include<bits/stdc++.h>
#define ll long long
#define ul unsigned long long
#define F(i,a,b) for(register long long i=a;i<=b;i++)
#define K(i,a,b) for(register long long i=a;i>=b;i--)
using namespace std;
ll a[1000001],n,f[1000001],t,k,l,r,o;
ll pd(ll x){
t=0;
if(a[1]>x)f[1]=1;
else f[1]=0;
o=f[1];
F(i,2,n*2-1){
if(a[i]>x)f[i]=1;
else f[i]=0;
if(t==0){
if(f[i]==f[i-1]){
t=i;
o=f[i];
}
}
else if(f[i]==f[i-1]&&abs(n-i)<abs(n-t)){
t=i;
o=f[i];
}
}
return o;
}
int main(){
cin>>n;
F(i,1,n*2-1)cin>>a[i];
l=1;r=n*2-1;
while(l<r){
ll mid=(l+r)>>1;
if(pd(b[mid])==0){
r=mid;
}
else l=mid+1;
}
cout<<r;
return 0;
} | a.cc: In function 'long long int pd(long long int)':
a.cc:20:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
20 | F(i,2,n*2-1){
| ^
a.cc:11:41: note: in definition of macro 'F'
11 | #define F(i,a,b) for(register long long i=a;i<=b;i++)
| ^
a.cc: In function 'int main()':
a.cc:38:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
38 | F(i,1,n*2-1)cin>>a[i];
| ^
a.cc:11:41: note: in definition of macro 'F'
11 | #define F(i,a,b) for(register long long i=a;i<=b;i++)
| ^
a.cc:42:23: error: 'b' was not declared in this scope
42 | if(pd(b[mid])==0){
| ^
|
s835739221 | p03954 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
const int N = 1e5 + 10, inf = 1e6;
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n + n - 1; i++)
cin >> a[i];
int ans;
for (int i = 1; i < n + n - 2; i++)
{
if(a[i] <= a[i + 1] && a[i] >= a[i - 1])
ans = a[i];
else if(a[i] >= a[i + 1] && a[i] <= a[i - 1])
ans = a[i];
}
cout << ans << "\n";
} | a.cc: In function 'int main()':
a.cc:16:24: error: 'a' was not declared in this scope
16 | cin >> a[i];
| ^
a.cc:20:20: error: 'a' was not declared in this scope
20 | if(a[i] <= a[i + 1] && a[i] >= a[i - 1])
| ^
|
s442274582 | p03954 | C++ | #include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rof(i,a,b) for(int i=a;i>=b;--i)
#define Go(x) for(int i=First[x];i;i=Next[i])
#define mp maxe_pair
#define fi first
#define se second
typedef long long longint;
using namespace std;
/*************head*************/
const int MAXN=1e5+10;
bool t[2*MAXN];
int n,f[2*MAXN];
inline int Read()
{
char c=getchar();
int f=1,x=0;
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
return f*x;
}
inline Init(int x)
{
For(i,1,(n<<1)-1)
t[i]=(f[i]<=x);
}
inline bool Check(int x)
{
Init(x);
for(int i=1;i<n-1;i++)
{
if(t[n-i]==t[n-i+1]) return t[n-i];
if(t[n+i]==t[n+i-1]) return t[n+i];
}
return t[1];
}
int main()
{
n=Read();
For(i,1,(n<<1)-1)
f[i]=Read();
int l=1,r=(n<<1)-1,Mid;
while(l<r)
{
Mid=(l+r)>>1;
if(Check(Mid))
r=Mid;
else
l=Mid+1;
}
printf("%d\n",l);
} | a.cc:22:8: error: ISO C++ forbids declaration of 'Init' with no type [-fpermissive]
22 | inline Init(int x)
| ^~~~
a.cc: In function 'int Init(int)':
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
26 | }
| ^
|
s734764680 | p03954 | C++ | #include <iostream>
using namespace std;
int a[200005],n;
bool b[200005];
bool pd(int x){for(int i=1;i<=n*2-1;i++) b[i]=(a[i]>=x);b[0]=b[1];
for(int i=n;i<=n+n;i++){if(b[i]==b[i+1])return b[i];if(b[n+n-i]==b[n+n-i-1])return b[n+n-i];}
}
int main(){
cin>>n;
for(int i=1;i<=n*2-1;i++)cin>>a[i];
int l=1,r=n*2,A=0,md;
while(l<=r){md=(l+r)/2;if(pd(md))l=md+1,A=md;elser=md-1;}cout<<A;} | a.cc: In function 'int main()':
a.cc:12:46: error: 'elser' was not declared in this scope
12 | while(l<=r){md=(l+r)/2;if(pd(md))l=md+1,A=md;elser=md-1;}cout<<A;}
| ^~~~~
a.cc: In function 'bool pd(int)':
a.cc:7:1: warning: control reaches end of non-void function [-Wreturn-type]
7 | }
| ^
|
s630405030 | p03954 | C++ | #include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rof(i,a,b) for(int i=a;i>=b;--i)
#define Go(x) for(int i=First[x];i;i=Next[i])
#define mp make_pair
#define fi first
#define se second
typedef long long longint;
using namespace std;
/*************head*************/
const int MAXN=1e5+10;
bool t[2*MAXN];
int n,f[2*MAXN];
inline int Read()
{
char c=getchar();
int f=1,x=0;
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
return f*x;
}
inline bool Check(int x)
{
Init(x);
For(i,1,n-1)
{
if(t[n-i]>=x&&t[n-i+1]>=x||t[n+i]>=x&&t[n+i-1]>=x) return 1;
if(t[n-i]< x&&t[n-i+1]< x||t[n+i]< x&&t[n+i-1]< x) return 0;
}
return t[1]<=x;
}
int main()
{
n=Read();
For(i,1,n<<1-1)
f[i]=Read();
int l=1,r=n<<1-1,Mid;
while(l<r)
{
Mid=(l+r)>>1;
if(Check(Mid))
r=Mid;
else
l=Mid+1;
}
printf("%d\n",l);
} | a.cc: In function 'bool Check(int)':
a.cc:24:9: error: 'Init' was not declared in this scope
24 | Init(x);
| ^~~~
|
s045383267 | p03954 | C | #include<bits/stdc++.h>
using namespace std;
const int Max_N=1e5;
int N,A[Max_N*2+10]={},B[Max_N*2+10]={};
inline bool Chck(int x){
if(B[N-1]==B[N]||B[N]==B[N+1]) return B[N];
int L=N-2,R=N+2;
for(;L>=1&&R<=2*N-1;){
if(B[L]==B[L+1]) return B[L];
if(B[R]==B[R-1]) return B[R];
--L; ++R;
}
return B[1];
}
int main(){
scanf("%d",&N);
for(int i=1;i<=2*N-1;i++) scanf("%d",&A[i]);
int l=1,r=N;
for(;l+1<r;){
int mid=(l+r);
for(int i=1;i<=2*N-1;i++)
B[i]=A[i]<=mid?0:1;
if(Chck(mid)==0) l=mid;
else r=mid;
}
if(Chck(r)==0) printf("%d\n",r);
else printf("%d\n",l);
return 0;
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s119053958 | p03954 | C++ | #if 0
date
假设最终答案为 x ,那么其他的数其实可以分为三种:x ,小于 x 和大于 x 。
只需要关注与 x 的大小,把小于 x 的全设为 -INF ,大于 x 的全设为 INF ,得出的结果一定仍是 x 。
但这仍然难以处理,考虑枚举一个值 x ,把所有数分为两种:小于等于 x (0) 和大于 x (1) 。
如此将原数列转换为 01 串,若最后剩下的是 0 ,那么答案一定小于 x ,否则答案一定大于 x 。
那么 x 的值可以二分,接下来问题转换为 01 串上求最后剩下的数。
首先,如果两个相等的值相邻,那么在之后的操作中这两个位置的值始终不变。
那么如果中间的值 a[mid] 与 a[mid - 1] 或 a[mid + 1] 相等,即中间的值是 xx? 或 ?xx 形式,最后的结果一定是 a[mid] ,即 x。
否则 a[mid - 1] 到 a[mid + 1] 一定是 xyx 形式。
那么考虑 a[mid - 2] 到 a[mid + 2] ,若为 xxyx? 形式,一次操作后转换为 xx? 形式,最后结果一定是 x 。
?xyxx 形式同理,否则一定是 xyxyx 形式。
以此类推,从中间向两边找到第一个相邻且相等的 a[i] = a[i + 1] ,那么 a[i] 即最后的结果。
如果不存在此 a[i] ,那么就是 0101...01010 的形式,最终结果是 a[mid] 。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)
inline int input() {
int c = getchar(), x = 0;
while(c < '0' or c > '9') c = getchar();
while(c >= '0' and c <= '9') x = x * 10 + c - '0', c = getchar();
return x;
}
const int maxn = 200005;
int a[maxn];
bool b[maxn];
bool check(int x, int n) {
// debug("check %d\n", x);
for(int i = 1; i <= n; i++)
b[i] = a[i] > x;
int mid = (1 + n) >> 1;
for(int i = 0; i < mid; i ++) {
if(b[mid + i] == b[mid + i + 1])
return b[mid + i];
if(b[mid - i] == b[mid - i - 1])
return b[mid - i];
}
return b[mid];
}
int main() {
int n = input() * 2 - 1, min = INT_MAX, max = 0;
for(int i = 1; i <= n; i ++) {
a[i] = input();
min = std::min(a[i], min);
max = std::max(a[i], max);
}
int l = min, r = max;
while(l < r) {
int mid = (l + r) >> 1;
if(check(mid, n))
l = mid + 1;
else
r = mid;
}
printf("%d\n", l);
}
| a.cc:4:70: error: extended character 。 is not valid in an identifier
4 | 假设最终答案为 x ,那么其他的数其实可以分为三种:x ,小于 x 和大于 x 。
| ^
a.cc:5:92: error: extended character 。 is not valid in an identifier
5 | 只需要关注与 x 的大小,把小于 x 的全设为 -INF ,大于 x 的全设为 INF ,得出的结果一定仍是 x 。
| ^
a.cc:7:84: error: extended character 。 is not valid in an identifier
7 | 但这仍然难以处理,考虑枚举一个值 x ,把所有数分为两种:小于等于 x (0) 和大于 x (1) 。
| ^
a.cc:8:86: error: extended character 。 is not valid in an identifier
8 | 如此将原数列转换为 01 串,若最后剩下的是 0 ,那么答案一定小于 x ,否则答案一定大于 x 。
| ^
a.cc:9:42: error: extended character 。 is not valid in an identifier
9 | 那么 x 的值可以二分,接下来问题转换为 01 串上求最后剩下的数。
| ^
a.cc:11:1: error: extended character 。 is not valid in an identifier
11 | 首先,如果两个相等的值相邻,那么在之后的操作中这两个位置的值始终不变。
| ^
a.cc:12:119: error: extended character 。 is not valid in an identifier
12 | 那么如果中间的值 a[mid] 与 a[mid - 1] 或 a[mid + 1] 相等,即中间的值是 xx? 或 ?xx 形式,最后的结果一定是 a[mid] ,即 x。
| ^
a.cc:13:42: error: extended character 。 is not valid in an identifier
13 | 否则 a[mid - 1] 到 a[mid + 1] 一定是 xyx 形式。
| ^
a.cc:14:98: error: extended character 。 is not valid in an identifier
14 | 那么考虑 a[mid - 2] 到 a[mid + 2] ,若为 xxyx? 形式,一次操作后转换为 xx? 形式,最后结果一定是 x 。
| ^
a.cc:15:34: error: extended character 。 is not valid in an identifier
15 | ?xyxx 形式同理,否则一定是 xyxyx 形式。
| ^
a.cc:17:74: error: extended character 。 is not valid in an identifier
17 | 以此类推,从中间向两边找到第一个相邻且相等的 a[i] = a[i + 1] ,那么 a[i] 即最后的结果。
| ^
a.cc:18:69: error: extended character 。 is not valid in an identifier
18 | 如果不存在此 a[i] ,那么就是 0101...01010 的形式,最终结果是 a[mid] 。
| ^
a.cc: In function 'int main()':
a.cc:50:40: error: 'INT_MAX' was not declared in this scope
50 | int n = input() * 2 - 1, min = INT_MAX, max = 0;
| ^~~~~~~
a.cc:22:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
21 | #include <algorithm>
+++ |+#include <climits>
22 | #define debug(...) fprintf(stderr, __VA_ARGS__)
a.cc:54:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
54 | max = std::max(a[i], max);
| ^~~
| std::max
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:21:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
a.cc:56:26: error: 'max' was not declared in this scope; did you mean 'std::max'?
56 | int l = min, r = max;
| ^~~
| 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)
| ^~~
|
s243354722 | p03954 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
vector<int> geko;
int solve(int now) {
vector<int> newer;
REP(i, geko.size()) {
if (geko[i] >= now) {
newer.push_back(1);
}
else {
newer.push_back(0);
}
}
int itr[2] = { 1e9,1e9};
int ans[2] = {};
int mid = geko.size() / 2;
for (int i = mid; i < geko.size()-1; ++i) {
if (newer[i] == newer[i + 1]) {
itr[0] = i;
ans[0] = newer[i];
break;
}
}
for (int i = mid; i >= 1; --i) {
if (newer[i] == newer[i - 1]) {
itr[1] = i;
ans[1] = newer[i];
break;
}
}
if (abs((int)geko.size()/2 - itr[0]) > abs((int)geko.size()/2 - itr[1])) {
return ans[1];
}
else {
return ans[0];
}
}
int main() {
int n;
cin >> n;
REP(i, 2 * n - 1) {
int a;
cin >> a;
geko.push_back(a);
}
int bot = 1;
int top = 2 * n;
while (top - bot > 1) {
int mid = (top + bot) / 2;
if (solve(mid) == 1) {
bot = mid;
}
else {
top = mid;
}
}
cout << bot << endl;
}
| a.cc: In function 'int solve(int)':
a.cc:52:24: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
52 | int itr[2] = { 1e9,1e9};
| ^~~
a.cc:52:28: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
52 | int itr[2] = { 1e9,1e9};
| ^~~
|
s693815109 | p03954 | C++ | #include<bits\stdc++.h>
using namespace std;
int n,a[200001];
bool checx(int x)
{
if((a[n-1]<=x&&a[n]<=x)||(a[n]<=x&&a[n+1]<=x))return 1;
if((a[n-1]> x&&a[n]> x)||(a[n]> x&&a[n+1]> x))return 0;
for(int i=1;i<n-1;i++){
if((a[n+i]<=x&&a[n+i+1]<=x)||(a[n-i]<=x&&a[n-i-1]<=x))return 1;
if((a[n+i]> x&&a[n+i+1]> x)||(a[n-i]> x&&a[n-i-1]> x))return 0;
}
return a[1]<=x;
}
int main(){
cin>>n;
for(int i=1;i<n<<1;i++)cin>>a[i];
int l=1,r=(n<<1)-1;
while(l<r)
{
int mid=(l+r)/2;
if(checx(mid))r=mid;
else l=mid+1;
}
cout<<l;
}
| a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
1 | #include<bits\stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s888879179 | p03954 | C | #include<bits/stdc++.h>
using namespace std;
int n;
vector<int>v;
int main()
{
cin>>n;
for(int i=1;i<2*n;i++)
{
int a;
cin>>a;
v.push_back(a);
}
while(v.size()!=1)
{
vector<int>vv;
for(int i=1;i<v.size()-1;i++)vv.push_back(v[i-1]+v[i]+v[i+1]-min(v[i-1],min(v[i],v[i+1]))-max(v[i-1],max(v[i],v[i+1])));
v=vv;
}
cout<<v[0]<<endl;
return 0;
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s146794691 | p03954 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,ans=-1;
vector<int> v;
int middle(int a,int b,int c)
{
if((a>=b&&a<=c)||(a>=c&&a<=b))
return a;
if((b>=a&&b<=c)||(b>=c&&b<=a))
return b;
if((c>=a&&c<=b)||(c>=b&&c<=a))
return c;
}
void dfs(vector<int> a)
{
if(a.size()==1)
{
ans=a[0];
return;
}
vector<int> next;
for(int i=0;i<a.size()-2;i++)
next.push_back(middle(a[i],a[i+1],a[i+2]));
dfs(next);
}
int main()
{
cin>>n;
for(int i=0;i<2*n-1;i++)
{
int x;
cin>>x;
v.push_back(x);
}
dfs(v);
cout<<ans<<endl;
return 0;
}#include<bits/stdc++.h>
using namespace std;
int n,ans=-1;
vector<int> v;
int middle(int a,int b,int c)
{
if((a>=b&&a<=c)||(a>=c&&a<=b))
return a;
if((b>=a&&b<=c)||(b>=c&&b<=a))
return b;
if((c>=a&&c<=b)||(c>=b&&c<=a))
return c;
}
void dfs(vector<int> a)
{
if(a.size()==1)
{
ans=a[0];
return;
}
vector<int> next;
for(int i=0;i<a.size()-2;i++)
next.push_back(middle(a[i],a[i+1],a[i+2]));
dfs(next);
}
int main()
{
cin>>n;
for(int i=0;i<2*n-1;i++)
{
int x;
cin>>x;
v.push_back(x);
}
dfs(v);
cout<<ans<<endl;
return 0;
} | a.cc:38:2: error: stray '#' in program
38 | }#include<bits/stdc++.h>
| ^
a.cc:38:3: error: 'include' does not name a type
38 | }#include<bits/stdc++.h>
| ^~~~~~~
a.cc:40:5: error: redefinition of 'int n'
40 | int n,ans=-1;
| ^
a.cc:3:5: note: 'int n' previously declared here
3 | int n,ans=-1;
| ^
a.cc:40:7: error: redefinition of 'int ans'
40 | int n,ans=-1;
| ^~~
a.cc:3:7: note: 'int ans' previously defined here
3 | int n,ans=-1;
| ^~~
a.cc:41:13: error: redefinition of 'std::vector<int> v'
41 | vector<int> v;
| ^
a.cc:4:13: note: 'std::vector<int> v' previously declared here
4 | vector<int> v;
| ^
a.cc:42:5: error: redefinition of 'int middle(int, int, int)'
42 | int middle(int a,int b,int c)
| ^~~~~~
a.cc:5:5: note: 'int middle(int, int, int)' previously defined here
5 | int middle(int a,int b,int c)
| ^~~~~~
a.cc:51:6: error: redefinition of 'void dfs(std::vector<int>)'
51 | void dfs(vector<int> a)
| ^~~
a.cc:14:6: note: 'void dfs(std::vector<int>)' previously defined here
14 | void dfs(vector<int> a)
| ^~~
a.cc:63:5: error: redefinition of 'int main()'
63 | int main()
| ^~~~
a.cc:26:5: note: 'int main()' previously defined here
26 | int main()
| ^~~~
a.cc: In function 'int middle(int, int, int)':
a.cc:13:1: warning: control reaches end of non-void function [-Wreturn-type]
13 | }
| ^
a.cc: In function 'int middle(int, int, int)':
a.cc:50:1: warning: control reaches end of non-void function [-Wreturn-type]
50 | }
| ^
|
s759226682 | p03954 | C++ | //NOT A FSKY CODE
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios>
#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[200004],b[200004];
bool check(int x){
for (int i=1;i<=m;i++){
if (a[i]<x) b[i]=0;
else b[i]=1;
}
int l,r;
for (l=n-1;l>0 && b[l]^b[l+1];l--);
for (r=n+1;r<=m && b[r]^b[r-1];r++);
if (l==0 && r==m+1) return b[1];
return r-n>n-l?b[l]:b[r];
}
int main(){
cin>>n;
m=n*2-1;
for (int i=1;i<=m;i++) scanf ("%d",&a[i]);
int l=-1,r=m+1;
while (r>l+1){
int mid=(l+r)/2;
if (check(mid)) l=mid;
else r=mid;
}
cout<<mid;
} | a.cc: In function 'int main()':
a.cc:55:15: error: 'mid' was not declared in this scope
55 | cout<<mid;
| ^~~
|
s238277062 | p03954 | C++ | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios>
#include <bits/stdc++.h>
using namespace std;
int n;
void qq(){
long long sum=0;
for (int i=0;i<n;i++){
long long x;
cin>>x;
sum+=x;
}
cout<<sum/x
}
int main(){
vector <long long> v,t;
cin>>n;
if (n>=4500){
qq();
return 0;
}
for(int i=0;i<n;i++){
long long x;
cin>>x;
v.push_back(x);
}
n=n*2-1;
int tw=0;
while (1){
tw^=1;
if (tw==0){
v.clear();
for (int i=0;i+2<t.size();i++)
v.push_back((t[i]+t[i+1]+t[i+2])/3);
}else{
t.clear();
for (int i=0;i+2<v.size();i++)
t.push_back((v[i]+v[i+1]+v[i+2])/3);
}
if (t.size()==1 || v.size()==1) break;
}
if (t.size()==1) cout<<t[0];
else cout<<v[0];
}
| a.cc: In function 'void qq()':
a.cc:39:19: error: 'x' was not declared in this scope
39 | cout<<sum/x
| ^
|
s945001997 | p03954 | C++ | #include<bits/stdc++.h>
using namespace std;
int arr[100010];
int main(0)
{
int n;
cin >> n;
for(int i=0; i<n; i++)
{
cin >> arr[i];
}
sort(arr, arr+n);
cout << arr[n-1] << endl;
return 0;
} | a.cc:4:5: error: cannot declare '::main' to be a global variable
4 | int main(0)
| ^~~~
a.cc:5:1: error: expected ',' or ';' before '{' token
5 | {
| ^
|
s690283028 | p03954 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, a[N << 1];
int sma (int i, int j, int k) {
return a[i] <= k && a[j] <= k;
}
int big (int i, int j, int k) {
return a[i] > k && a[j] > k;
}
int check (int k) {
for (int i = 0; i < n - 1; ++i) {//枚举距离判断
if (big (n + i, n + i + 1, k) || big (n - i, n - i - 1, k)) return 0;
if (sma (n + i, n + i + 1, k) || sma (n - i, n - i - 1, k)) return 1;
}
return small (1, 1, k);//没有重合的特判
}
int main(){
cin >> n;
for (int i = 1; i <= (n << 1) - 1; ++i) {
cin >> a[i];
}
int l = 1, r = 2 * n - 1, ans;
while (l < r) {//二分判断
int mid = (l + r) >> 1;
if (check (mid)) {
r = mid;
} else {
l = mid + 1;
}
}
cout << r;
return 0;
}
| a.cc: In function 'int check(int)':
a.cc:21:12: error: 'small' was not declared in this scope; did you mean 'sma'?
21 | return small (1, 1, k);//没有重合的特判
| ^~~~~
| sma
|
s479231463 | p03954 | C++ | #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N=2e5+2,inf=1e9;
int a[N],b[N];
int n,m,i,x,l,r,mid,c,zx,as;
inline void read(int &x)
{
c=getchar();
while ((c<48)||(c>57)) c=getchar();
x=c^48;c=getchar();
while ((c>=48)&&(c<=57))
{
x=x*10+(c^48);
c=getchar();
}
}
inline int ab(int x)
{
if (x>=0) return x;
return -x;
}
bool pd()
{
for (i=1;i<=m;i++) b[i]=(a[i]>=mid);zx=inf;
for (i=2;i<=m;i++) if (b[i]==b[i-1])
{
if ((i==n)||(i==n+1)) return b[i];
x=min(ab(i-n),ab(n-(i-1)));
if (x<zx)
{
zx=x;
as=b[i];
}
if (zx!=inf) return as;
return b[1];
}
int main()
{
read(n);m=(n<<1)-1;
for (i=1;i<=m;i++) read(a[i]);
l=1;r=m;
while (l<r)
{
mid=l+r+1>>1;
if (pd()) l=mid; else r=mid-1;
}
printf("%d",l);
} | a.cc: In function 'bool pd()':
a.cc:39:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
39 | int main()
| ^~
a.cc:39:9: note: remove parentheses to default-initialize a variable
39 | int main()
| ^~
| --
a.cc:39:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:40:1: error: a function-definition is not allowed here before '{' token
40 | {
| ^
a.cc:50:2: error: expected '}' at end of input
50 | }
| ^
a.cc:25:1: note: to match this '{'
25 | {
| ^
a.cc:50:2: warning: control reaches end of non-void function [-Wreturn-type]
50 | }
| ^
|
s458261847 | p03954 | C++ | #include <bits/stdc++.h>
using namespace std;
int kt(vector<int> &vi)
{
int n = vi.size();
int mid = vi.size()/2;
{
int a1 = vi[mid], a2 = vi[mid-1], a3 = vi[mid+1];
if(a1==a2||a2==a3)
return a2;
}
int l = mid, r = mid;
while(l>=0)
{
if(a[l]==(1-a[l-1]))
l--;
else
break;
}
while(r<n)
{
if(a[r]==(1-a[r+1]))
r++;
else
break;
}
int x = r-mid;
int y = mid-l;
if(x>y) return a[l];
return a[r];
}
int main()
{
int n;
cin >> n;
vector<int> a(n);
for(int i = 0;i<n;i++)
cin >> a[i];
int l = 1;
int r = n;
int soll = -1;
while(l<r)
{
int mid = (l+r)/2;
vector<int> b;
for(int i = 0;i<n;i++)
b.push_back((a[i]>=mid));
int sol = kt(b);
if(sol==0)
l = mid+1;
if(sol==1)
{
r = mid - 1;
soll = mid;
}
}
cout << soll;
return 0;
}
| a.cc: In function 'int kt(std::vector<int>&)':
a.cc:16:12: error: 'a' was not declared in this scope
16 | if(a[l]==(1-a[l-1]))
| ^
a.cc:23:12: error: 'a' was not declared in this scope
23 | if(a[r]==(1-a[r+1]))
| ^
a.cc:30:20: error: 'a' was not declared in this scope
30 | if(x>y) return a[l];
| ^
a.cc:31:12: error: 'a' was not declared in this scope
31 | return a[r];
| ^
|
s930642054 | p03954 | C++ | //============================================================================
// Name : test.cpp
// Author : aelgawah
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <set.h>
using namespace std;
#define GET_MEDIUM(x,y,z) ((x>y)?((x<z)?(x):((y>z)?y:z)):((x<z)?((y>z)?z:y):x))
int N=100000;
int main()
{
int steps,blk[N],temp;
cin>>steps;
for(int i=0; i<(2*steps -1); i++)
{
cin>>blk[i];
}
for(int i=0; i<steps -1; i++)
{
for(int j=0; j<(((2*steps -1)-2)-(2*i)) ; j++)
{
temp=GET_MEDIUM(blk[j],blk[j+1],blk[j+2]);
blk[j]=temp;
/*cout <<blk[0] <<blk[1] <<blk[2] <<blk[3] <<blk[4] <<blk[5] <<blk[6] << endl;
cout <<blk[j] << endl;*/
}
}
cout <<blk[0] << endl; // prints !!!Hello World!!!
return 0;
}
| a.cc:10:10: fatal error: set.h: No such file or directory
10 | #include <set.h>
| ^~~~~~~
compilation terminated.
|
s328332364 | p03954 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int n,a[200005];
inline bool check(const int &k){
if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;
if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;
for(int i=1;i<n-1;i++){
if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;
if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;
}
return a[1]<=k;
}
int main(){
scanf("%d",&n);
for(int i=1;i<n<<1;i++)scanf("%d",a+i);
int l=1,r=(n<<1)-1;
while(l<r){
int mid=l+r>>1;
if(check(mid))r=mid;
else l=mid+1;
}
printf("%d",l); | a.cc: In function 'int main()':
a.cc:26:20: error: expected '}' at end of input
26 | printf("%d",l);
| ^
a.cc:17:11: note: to match this '{'
17 | int main(){
| ^
|
s201269170 | p03954 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,a[2000005];
inline bool check(int k)
{
if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))
return true;
if((a[n-1]>k&&a[n]>k)||(a[n]>k&&a[n+1]>k))
return false;
for(int i=1;i<n-1;i++)
{
if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))
return true;
if((a[n+i]>k&&a[n+i+1]>k)||(a[n-i]>k&&a[n-i-1]>k))
return false;
}
if(a[1]<=k);
return true;
else
return false;
}
int main()
{
freopen
scanf("%d",&n);
for(int i=1;i<n*2;i++)
scanf("%d",&a[i]);
int l=1,r=n*2-1;
while(l<r)
{
int mid=(l+r)/2;
if(check(mid))
r=mid;
else
l=mid+1;
}
printf("%d",l);
} | a.cc: In function 'bool check(int)':
a.cc:19:5: error: 'else' without a previous 'if'
19 | else
| ^~~~
a.cc: In function 'int main()':
a.cc:24:12: error: expected ';' before 'scanf'
24 | freopen
| ^
| ;
25 | scanf("%d",&n);
| ~~~~~
|
s736245432 | p03954 | C++ | #include <iostream>
#include<bits/stdc++.h>
#define RE register
using namespace std;
const int maxn = 1e6;
int n,a[maxn*2 - 1];
void read(int &x){
x=0;int f=1;char s ;s=getline();
while(s<'0'||s>'9'){if(s='-')f=-1;s=getline();}
while(s>='0'&&s<='9'){x=x*10+s-'0';s=getline()}
x*=f;
}
inline bool small(int x,int y,int k){
return a[x]<=k&&a[y]<=k;
}
inline bool big(int x,int y,int k){
return a[x]>=k&&a[y]>=k;
}
inline bool check(int x){
for(RE int i=0;i<n-1;i++){
if(big(n+i,n+1+i,x)||big(n-i,n-1-i,x))return 1;
if(small(n+i,n+1+i,x)||small(n-i,n-1-i,x))return 0;
}
}
int main()
{
// freopen("pyramid.in","r",stdin);
// freopen("pyramid.out","w",stdout);
read(n);
for(RE int i=1;i<=n*2;i++){
read(a[i]);
}
int l=1,r=2*n;
while(l<r){
int mid=(l+r)/2;
if(check)
r=mid;
else
l=mid+1;
}
cout<<r<<endl;
return 0;
}
| a.cc: In function 'void read(int&)':
a.cc:8:34: error: no matching function for call to 'getline()'
8 | x=0;int f=1;char s ;s=getline();
| ~~~~~~~^~
In file included from /usr/include/c++/14/string:55,
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/basic_string.tcc:907:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
907 | getline(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:907:5: note: candidate expects 3 arguments, 0 provided
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:4117:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4117 | getline(basic_istream<_CharT, _Traits>& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4117:5: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
4125 | getline(basic_istream<_CharT, _Traits>&& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4132:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4132 | getline(basic_istream<_CharT, _Traits>&& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4132:5: note: candidate expects 2 arguments, 0 provided
In file included from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154:
/usr/include/stdio.h:697:18: note: candidate: '__ssize_t getline(char**, size_t*, FILE*)'
697 | extern __ssize_t getline (char **__restrict __lineptr,
| ^~~~~~~
/usr/include/stdio.h:697:18: note: candidate expects 3 arguments, 0 provided
a.cc:9:48: error: no matching function for call to 'getline()'
9 | while(s<'0'||s>'9'){if(s='-')f=-1;s=getline();}
| ~~~~~~~^~
/usr/include/c++/14/bits/basic_string.tcc:907:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
907 | getline(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:907:5: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4117:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4117 | getline(basic_istream<_CharT, _Traits>& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4117:5: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
4125 | getline(basic_istream<_CharT, _Traits>&& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4132:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4132 | getline(basic_istream<_CharT, _Traits>&& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4132:5: note: candidate expects 2 arguments, 0 provided
/usr/include/stdio.h:697:18: note: candidate: '__ssize_t getline(char**, size_t*, FILE*)'
697 | extern __ssize_t getline (char **__restrict __lineptr,
| ^~~~~~~
/usr/include/stdio.h:697:18: note: candidate expects 3 arguments, 0 provided
a.cc:10:49: error: no matching function for call to 'getline()'
10 | while(s>='0'&&s<='9'){x=x*10+s-'0';s=getline()}
| ~~~~~~~^~
/usr/include/c++/14/bits/basic_string.tcc:907:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
907 | getline(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:907:5: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4117:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4117 | getline(basic_istream<_CharT, _Traits>& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4117:5: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
4125 | getline(basic_istream<_CharT, _Traits>&& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/basic_string.h:4132:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4132 | getline(basic_istream<_CharT, _Traits>&& __is,
| ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:4132:5: note: candidate expects 2 arguments, 0 provided
/usr/include/stdio.h:697:18: note: candidate: '__ssize_t getline(char**, size_t*, FILE*)'
697 | extern __ssize_t getline (char **__restrict __lineptr,
| ^~~~~~~
/usr/include/stdio.h:697:18: note: candidate expects 3 arguments, 0 provided
a.cc: In function 'bool check(int)':
a.cc:23:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
23 | for(RE int i=0;i<n-1;i++){
| ^
a.cc: In function 'int main()':
a.cc:33:16: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
33 | for(RE int i=1;i<=n*2;i++){
| ^
|
s308845090 | p03954 | C++ | #include <iostream>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 200005;
int a[MAXN],t[MAXN],n;
inline bool check(int limit)
{
for(int i=1;i<=n*2-1;++i)
t[i]=(a[i]>=limit);
int l=-1,r=-1,lpos=-0x3f3f3f3f,rpos=0x3f3f3f3f;
for(int i=n+1;i<=n*2-1;++i)
if(t[i]==t[i-1]){r=t[i],rpos=i-1;break;}
for(int i=n-1;i>0;--i)
if(t[i]==t[i+1]){l=t[i],lpos=i+1;break;}
if(l==-1 && r==-1)
if(mid&1)return t[mid];
else return t[mid]^1;
else return (rpos-mid>mid-lpos?l:r);
return 0;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n*2-1;++i)
scanf("%d",a+i);
int l=1,r=n*2-1,mid,ans=0;
while(l<=r){
mid=(l+r)>>1;
if(check(mid))l=mid+1,ans=mid;
else r=mid-1;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'bool check(int)':
a.cc:20:20: error: 'mid' was not declared in this scope
20 | if(mid&1)return t[mid];
| ^~~
a.cc:22:27: error: 'mid' was not declared in this scope
22 | else return (rpos-mid>mid-lpos?l:r);
| ^~~
|
s637649540 | p03954 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
scanf("%d",&n);
printf("%d\n",n);
} | a.cc: In function 'int main()':
a.cc:4:13: error: 'n' was not declared in this scope; did you mean 'yn'?
4 | scanf("%d",&n);
| ^
| yn
|
s643667341 | p03954 | C++ | #include<cstdio>
#include<algorithm>
using namespace std;
int n,a[200010],ans;
bool p[200010];
bool check(int mid){
for(int i=1;i<=n*2-1;i++)
p[i]=(a[i]<=mid);
for(int i=0;i<n-1;i++){
if(p[n-i]==p[n-i-1])
return p[n-i];
if(p[n+i]==p[n+i+1])
return p[n+i+1];
}
return p[1];
}
int rd(){
int x=0;
char c;
do c=getchar();
while(!isdigit(c));
do{
x=(x<<1)+(x<<3)+(c^48);
c=getchar();
}while(isdigit(c));
return x;
}
int main(){
n=rd();
for(int i=1;i<=n*2-1;i++)
scanf("%d",a+i);
int l=2,r=n*2-2;
while(l<=r){
int mid=(l+r)>>1;
if(check(mid)){
ans=mid;
r=mid-1;
}
else l=mid+1;
}
printf("%d",ans);
return 0;
} | a.cc: In function 'int rd()':
a.cc:21:16: error: 'isdigit' was not declared in this scope
21 | while(!isdigit(c));
| ^~~~~~~
|
s358158603 | p03954 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,a[20000010];
bool x(int i,int j,int k) {
return a[i]<=k&&a[j]<=k;
}
bool y(int i,int j,int k){
return a[i]>k&&a[j]>k;
}
bool check(int a){
for(int i=0;i<n-1;i++){
if(y(n+i,n+i+1,a)||y(n-i,n-i-1,a)) return 0;
if(x(n+i,n+i+1,a)||x(n-i,n-i-1,a)) return 1;
}
return x(1,1,k);
}
int main(){
scanf("%d",&n);
for(int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);
int l=1,r=2*n-1,mid;
while(l<r){
mid=(l+r)/2;
if(check(mid)) r=mid;
else l=mid+1;
}
printf("%d",l);
return 0;
} | a.cc: In function 'bool check(int)':
a.cc:15:18: error: 'k' was not declared in this scope
15 | return x(1,1,k);
| ^
|
s070512299 | p03954 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,a[20000010];
bool x(int i,int j,int k) {
return a[i]<=k&&a[j]<=k;
}
bool y(int i,int j,int k){
return a[i]>k&&a[j]>k;
}
bool check(int a){
for(int i=0;i<n-1;i++){
if(y(n+i,n+i+1,a)||y(n-i,n-i-1,a)) return 0;
if(x(n+i,n+i+1,a)||x(n-i,n-i-1,a)) return 1;
}
return a(1,1,k);
}
int main(){
scanf("%d",&n);
for(int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);
int l=1,r=2*n-1,mid;
while(l<r){
mid=(l+r)/2;
if(check(mid)) r=mid;
else l=mid+1;
}
printf("%d",l);
return 0;
} | a.cc: In function 'bool check(int)':
a.cc:15:18: error: 'k' was not declared in this scope
15 | return a(1,1,k);
| ^
a.cc:15:19: error: 'a' cannot be used as a function
15 | return a(1,1,k);
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.