QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#414868#8058. Binary vs Ternarykevinshan#Compile Error//C++172.4kb2024-05-19 23:10:572024-05-19 23:10:58

Judging History

你现在查看的是最新测评结果

  • [2024-05-19 23:10:58]
  • 评测
  • [2024-05-19 23:10:57]
  • 提交

answer

#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,lzcnt,popcnt,sse,sse2,sse3,ssse3,sse4")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ps push
#define in insert
#define f first
#define s second
#define nl cout<<"\n"
#define ca(v) for(auto i:v) cout<<i<<" ";
#define cbit(x) __builtin_popcount(x)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a*b/gcd(a, b))
const int xm[4] = {-1, 1, 0, 0};
const int ym[4] = {0, 0, -1, 1};
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;
const ll POW = 9973;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int t; cin>>t;
    while(t--){
        string a;
        string b;
        cin>>a>>b;
        if(a.size() == 1 && b.size() == 1) {
            cout<<0<<"\n";
        }
        else if(a.size() == 1) {
            cout<<-1<<"\n";
        }
        else if(b.size() == 1) {
            cout<<-1<<"\n";
        }
        else {
            // first reduce a
            int sz = a.size();
            int bk;
            vector<pair<int, int>> mv;
            for(int i=a.size()-1; i>=0; i--){
                if(a[i] == '1') {
                    bk = i;
                    break;
                }
            }
            mv.pb({bk+2, a.size()});
            sz -= sz - 2 - bk;
            for(int j=sz-3; j>=0; j--) {
                if(a[j] == '0') {
                    mv.pb({j+1, j+2});
                }
                else {
                    mv.pb({j+1, j+2});
                    mv.pb({j+2, j+4});
                }
            }
            // string should be 10
            mv.pb({1,2});
            // now string is 11
            int c = 2;
            while(c<b.size()) {
                mv.pb({c-1,c});
                c++;
                mv.pb({c-2, c-1});
                mv.pb({c-1,c});
            }
            for(int i=b.size()-1; i>=1; i--){
                if(b[i] == '0') {
                    mv.pb({i,i+1});
                    mv.pb({i+1,i+2});
                }
            }
            cout<<mv.size()<<"\n";
            for(auto p:mv) cout<<p.f<<" "<<p.s<<"\n";
        }
    }

}


详细

answer.code: In function ‘int main()’:
answer.code:30:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         freopen("input.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:31:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         freopen("output.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~