QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#689826#9255. Python ProgramYipChipCompile Error//C++117.0kb2024-10-30 18:50:262024-10-30 18:50:29

Judging History

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

  • [2024-10-30 18:50:29]
  • 评测
  • [2024-10-30 18:50:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 210;
typedef __int128 ll;
string line1, line2, line3, line4, line5;
char value1[N], value2[N];
ll a, b, c, d, e, f;

int main()
{
    getline(cin, line1);
    getline(cin, line2);
    getline(cin, line3);
    getline(cin, line4);
    getline(cin, line5);
    for (int i = 0, space = 0; i < line2.length(); i ++ )
    {
        if (line2[i] == ' ' && !space)
        {
            int n = 0;
            space ++ ;
            i ++ ;
            while (line2[i] != ' ') value1[n ++ ] = line2[i], i ++ ;
        }
        if (line2[i] == '(')
        {
            i ++ ;
            int pd = 0;
            if (line2[i] == '-') pd = 1, i ++ ;
            while (line2[i] != ',')
            {
                a = a * 10 + line2[i] - '0';
                i ++ ;
            }
            if (pd) a = -a;
            i ++ ;
            pd = 0;
            if (line2[i] == '-') pd = 1, i ++ ;
            while (line2[i] != ',' && line2[i] != ')')
            {
                b = b * 10 + line2[i] - '0';
                i ++ ;
            }
            if (pd) b = -b;
            if (line2[i] == ')')
            {
                c = 1;
                break;
            }
            else
            {
                i ++ ;
                pd = 0;
                if (line2[i] == '-') pd = 1, i ++ ;
                while (line2[i] != ')') c = c * 10 + line2[i] - '0', i ++ ;
                if (pd) c = -c;
                break;
            }
        }
    }

    int cases = 0;
    for (int i = 4, space = 0; i < line3.length(); i ++ )
    {
        if (line3[i] == ' ' && !space)
        {
            int n = 0;
            space ++ ;
            i ++ ;
            while (line3[i] != ' ') value2[n ++ ] = line3[i], i ++ ;
        }
        if (line3[i] == '(')
        {
            i ++ ;
            int pd = 0;
            if (line3[i] != '-' && (line3[i] < '0' || line3[i] > '9'))
            {
                cases = 1;
                while (line3[i] != ',') i ++ ;
                i ++ ;
            }
            else
            {
                if (line3[i] == '-') pd = 1, i ++ ;
                while (line3[i] != ',' && line3[i] != ')') d = d * 10 + line3[i] - '0', i ++ ;
                if (pd) d = -d;
                i ++ ;
            }
            pd = 0;
            if (line3[i] != '-' && (line3[i] < '0' || line3[i] > '9'))
            {
                cases = 2;
                while (line3[i] != ',') i ++ ;
                i ++ ;
            }
            else
            {
                if (line3[i] == '-') pd = 1, i ++ ;
                while (line3[i] != ',') e = e * 10 + line3[i] - '0', i ++ ;
                if (pd) e = -e;
                i ++ ;
            }
            if (line3[i] == ')')
            {
                f = 1;
                break;
            }
            else
            {
                pd = 0;
                if (line3[i] != '-' && (line3[i] < '0' || line3[i] > '9'))
                {
                    cases = 3;
                    while (line3[i] != ',') i ++ ;
                }
                else
                {
                    if (line3[i] == '-') pd = 1, i ++ ;
                    while (line3[i] != ')') f = f * 10 + line3[i] - '0', i ++ ;
                    if (pd) f = -f;
                    i ++ ;
                }
                break;
            }
        }
    }
    // a, b, c, d, e, f
    // for (i = a, i < b, i += c)
    //     for (j = d, j < e, j += f)
    //          ans += j
    // cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << "\n";
    ll ans = 0;
    // const
    if (cases == 0)
    {
        ll times;
        if (f > 0)
        {
            ll times = (e - d - 1) / f + 1;
            e = d + (times - 1) * f;
        }
        else
        {
            swap(d, e), f = -f;
            times = (e - d - 1) / f + 1;
            d = e - (times - 1) * f;
        }
        if (c > 0)
        {
            ll times = (b - a - 1) / c + 1;
            b = a + (times - 1) * c;
        }
        else
        {
            swap(a, b), c = -c;
            times = (b - a - 1) / c + 1;
            a = b - (times - 1) * c;
        }
        for (int i = a; i <= b; i += c)
            ans += (d + e) * times / 2;
    }
    // d = i
    if (cases == 1)
    {
        ll times, tmp = e, tmp2 = f;
        if (c > 0)
        {
            ll times = (b - a - 1) / c + 1;
            b = a + (times - 1) * c;
        }
        else
        {
            swap(a, b), c = -c;
            times = (b - a - 1) / c + 1;
            a = b - (times - 1) * c;
        }
        for (int i = a; i <= b; i += c)
        {
            d = i, e = tmp, f = tmp2;
            if (f > 0)
            {
                if (d >= e) continue;
            }
            else
            {
                if (e >= d) continue;
            }
            if (f > 0)
            {
                times = (e - d - 1) / f + 1;
                e = d + (times - 1) * f;
            }
            else
            {
                swap(d, e), f = -f;
                times = (e - d - 1) / f + 1;
                d = e - (times - 1) * f;
            }
            ans += (d + e) * times / 2;
        }
    }
    // e = i
    if (cases == 2)
    {
        ll times, tmp = d, tmp2 = f;
        if (c > 0)
        {
            ll times = (b - a - 1) / c + 1;
            b = a + (times - 1) * c;
        }
        else
        {
            swap(a, b), c = -c;
            times = (b - a - 1) / c + 1;
            a = b - (times - 1) * c;
        }
        for (int i = a; i <= b; i += c)
        {
            f = tmp2;
            d = tmp, e = i;
            if (f > 0)
            {
                times = (e - d - 1) / f + 1;
                e = d + (times - 1) * f;
            }
            else
            {
                swap(d, e), f = -f;
                times = (e - d - 1) / f + 1;
                d = e - (times - 1) * f;
            }
            ans += (d + e) * times / 2;
        }
    }
    // f = i
    if (cases == 3)
    {
        ll times;
        if (c > 0)
        {
            ll times = (b - a - 1) / c + 1;
            b = a + (times - 1) * c;
        }
        else
        {
            swap(a, b), c = -c;
            times = (b - a - 1) / c + 1;
            a = b - (times - 1) * c;
        }
        for (int i = a; i <= b; i += c)
        {
            f = i;
            if (f > 0)
            {
                times = (e - d - 1) / f + 1;
                e = d + (times - 1) * f;
            }
            else
            {
                swap(d, e), f = -f;
                times = (e - d - 1) / f + 1;
                d = e - (times - 1) * f;
            }
            ans += (d + e) * times / 2;
        }
    }
    cout << ans << '\n';
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:267:10: error: ambiguous overload for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘ll’ {aka ‘__int128’})
  267 |     cout << ans << '\n';
      |     ~~~~ ^~ ~~~
      |     |       |
      |     |       ll {aka __int128}
      |     std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/13/istream:41,
                 from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 from answer.code:1:
/usr/include/c++/13/ostream:168:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  168 |       operator<<(long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:172:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  172 |       operator<<(unsigned long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:176:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  176 |       operator<<(bool __n)
      |       ^~~~~~~~
In file included from /usr/include/c++/13/ostream:880:
/usr/include/c++/13/bits/ostream.tcc:96:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]’
   96 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/ostream:183:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  183 |       operator<<(unsigned short __n)
      |       ^~~~~~~~
/usr/include/c++/13/bits/ostream.tcc:110:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]’
  110 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/ostream:194:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  194 |       operator<<(unsigned int __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:203:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  203 |       operator<<(long long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:207:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  207 |       operator<<(unsigned long long __n)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:222:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  222 |       operator<<(double __f)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:226:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  226 |       operator<<(float __f)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:234:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’
  234 |       operator<<(long double __f)
      |       ^~~~~~~~
/usr/include/c++/13/ostream:564:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char) [with _CharT = char; _Traits = char_traits<char>]’
  564 |     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
      |     ^~~~~~~~
/usr/include/c++/13/ostream:570:5: note: candidate: ‘std...