QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#852556#2351. Lost in TransferthanhsCompile Error//C++233.0kb2025-01-11 12:45:172025-01-11 12:45:19

Judging History

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

  • [2025-01-11 12:45:19]
  • 评测
  • [2025-01-11 12:45:17]
  • 提交

answer

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

#define name "TENBAI"
#define fi first
#define se second
#define int long long
#define endl '\n'
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))

mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}



void solve()
{
    string _;
    cin >> _;
    if (_ == "transmit")
    {
        int q;
        cin >> q;
        while (q--)
        {
            deque<int> v;
            int n, xr = 0;
            cin >> n;
            for (int i = 1; i <= n; i++)
            {
                int x;
                cin >> x;
                v.push_back(x);
                xr ^= x;
            }
            sort(v.begin(), v.end());
            vector<int> res;
            for (int i = 0; i < 9; i++)
            {
                int t = xr >> i & 1;
                if (t)
                {
                    res.push_back(v.back());
                    v.pop_back();
                    res.push_back(v.back());
                    v.pop_back();
                }
                else
                {
                    res.push_back(v.front());
                    v.pop_front();
                    res.push_back(v.front());
                    v.pop_front();
                }
            }
            for (int t : v)
                res.push_back(t);
            cout << bitset<9>(xr) << endl;
            for (int i = 1; i < n; i++)
                cout << (res[i] < res[i - 1]);
            cout << endl;
            for (int t : res)
                cout << t << ' ';
            cout << endl;
        }
    }
    else
    {
        int q;
        cin >> q;
        while (q--)
        {
            vector<int> a;
            int n;
            cin >> n;
            int xr = 0;
            for (int i = 1; i <= n; i++)
            {
                int x;
                cin >> x;
                a.push_back(x);
                xr ^= x;
            }
            // for (int i = 1; i < n; i++)
            //     cout <<
            // for (int i = 0; i < 9; i++)
            //     cout << (a[i << 1 | 1] < a[i << 1]);
            for (int i = 0; i < 9; i++)
                xr ^= (a[i << 1 | 1] < a[i << 1]) << i;
            if (xr)
                a.push_back(xr);
            for (int t : a)
                cout << t << ' ';
            cout << endl;
        }
    }
}

signed main()
{
    if (fopen("in.txt", "r")) 
    {
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    else if (fopen(name".inp", "r"))
    {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int tc = 1; 
    // cin >> tc;
    while (tc--)
        solve();
}

Details

answer.code:13:1: error: ‘mt19937’ does not name a type
   13 | mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
      | ^~~~~~~
answer.code: In function ‘long long int rand(long long int, long long int)’:
answer.code:14:37: error: ‘hdp’ was not declared in this scope
   14 | int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}
      |                                     ^~~
answer.code: In function ‘void solve()’:
answer.code:58:26: warning: range-based ‘for’ loops only available with ‘-std=c++11’ or ‘-std=gnu++11’
   58 |             for (int t : v)
      |                          ^
answer.code:58:26: error: forming reference to reference type ‘std::deque<long long int>&’
answer.code:64:26: warning: range-based ‘for’ loops only available with ‘-std=c++11’ or ‘-std=gnu++11’
   64 |             for (int t : res)
      |                          ^~~
answer.code:64:26: error: forming reference to reference type ‘std::vector<long long int>&’
answer.code:94:26: warning: range-based ‘for’ loops only available with ‘-std=c++11’ or ‘-std=gnu++11’
   94 |             for (int t : a)
      |                          ^
answer.code:94:26: error: forming reference to reference type ‘std::vector<long long int>&’
answer.code: In function ‘int main()’:
answer.code:113:47: error: ‘nullptr’ was not declared in this scope
  113 |     ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
      |                                               ^~~~~~~
answer.code:105:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  105 |         freopen("in.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
answer.code:106:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  106 |         freopen("out.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:110:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  110 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:111:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  111 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~