제출 #925397

#제출 시각아이디문제언어결과실행 시간메모리
925397bachhoangxuanAncient Machine (JOI21_ancient_machine)C++17
컴파일 에러
0 ms0 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; namespace{ int F[50]; } int bit_to_fib(string s){ int total=0,pos=39; while(pos>=0){ if(s[pos]=='1') total+=F[pos],pos-=2; else pos--; } return total; } void Anna(int N, std::vector<char> S) { F[0]=1;F[1]=2; for(int i=0;i<=40;i++) F[i]=(F[i-1]+F[i-2]); int f=-1,lst=-1; string res; for(int i=0;i<N;i++){ if(f==-1){ if(S[i]=='X') f=i; res+='0'; } else if(S[i]=='Z'){ if(S[i-1]=='Z') res.back()='0'; res+='1'; } else res+='0'; } while(N%40!=0) res+='0',N++; if(f==-1) f=(1<<17)-1; for(int i=0;i<17;i++) Send(f>>i&1); for(int i=0;i<N;i+=40){ string cur; for(int j=0;j<40;j++) cur+=S[i+j]; int total=bit_to_fib(cur); for(int i=0;i<28;i++) Send(total>>i&1); } }
#include "Bruno.h" #include<bits/stdc++.h> using namespace std; /* namespace{ int F[50]; } */ string fib_to_bit(int total){ string res; int pos=39; while(pos>=0){ if(total>=F[pos]) res+="10",total-=F[pos],pos-=2; else res+='0',pos--; } if((int)res.length()>40) res.pop_back(); reverse(res.begin(),res.end()); return res; } void Bruno(int N, int L,vector<int> A) { F[0]=1;F[1]=2; for(int i=2;i<=40;i++) F[i]=F[i-1]+F[i-2]; int f=0; for(int i=0;i<17;i++) f+=A[i]<<i; if(f>=N){ for(int i=0;i<N;i++) Remove(i); return; } string s; for(int i=0;i<(int)A.size()-17;i+=28){ int total=0; for(int j=0;j<28;j++) total+=A[17+i+j]<<j; s+=fib_to_bit(total); } while((int)s.length()>N) s.pop_back(); for(int i=0;i<f;i++) Remove(i); int lst=f; for(int i=f+1;i<N;i++){ if(s[i]=='1'){ for(int j=i-1;j>lst;j--) Remove(j); Remove(i);lst=i; } } for(int i=lst+1;i<N;i++) Remove(i); Remove(f); }

컴파일 시 표준 에러 (stderr) 메시지

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:22:14: warning: unused variable 'lst' [-Wunused-variable]
   22 |     int f=-1,lst=-1;
      |              ^~~

Bruno.cpp: In function 'std::string fib_to_bit(int)':
Bruno.cpp:13:19: error: 'F' was not declared in this scope
   13 |         if(total>=F[pos]) res+="10",total-=F[pos],pos-=2;
      |                   ^
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:22:5: error: 'F' was not declared in this scope
   22 |     F[0]=1;F[1]=2;
      |     ^