QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#650986#8554. Bot FriendsMiniLongWA 25ms5936kbC++203.6kb2024-10-18 17:15:152024-10-18 17:15:15

Judging History

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

  • [2024-10-18 17:15:15]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:5936kb
  • [2024-10-18 17:15:15]
  • 提交

answer

#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
    #ifdef ONLINE_JUDGE
    char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
    #define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
    #else
    #define get() getchar()
    #endif
    template<typename T> inline void read(T &t){
        T x = 0, f = 1;
        char c = getchar();
        while(!isdigit(c)){
            if(c == '-') f = -f;
            c = getchar();
        }
        while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
        t = x * f;
    }
    template<typename T, typename ... Args> inline void read(T &t, Args&... args){
        read(t);
        read(args...);
    }
    template<typename T> void write(T t){
        if(t < 0) putchar('-'), t = -t;
        if(t >= 10) write(t / 10);
        putchar(t % 10 + '0');
    }
    template<typename T, typename ... Args> void write(T t, Args... args){
        write(t), putchar(' '), write(args...);
    }
    template<typename T> void writeln(T t){
        write(t);
        puts("");
    }
    template<typename T> void writes(T t){
        write(t), putchar(' ');
    }
    #undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
    const ll mod = 998244353;
    ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
    void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
    void add(ll &x, ll y){x = (x + y) % mod;}
    void mul(ll &x, ll y){x = x * y % mod;}
    ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
    ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
    ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 5005, inf = 0x3f3f3f3f;
int n, f[N][N][2];
char s[N];
int main(){
    multitest(){
        scanf("%s", s + 1), n = strlen(s + 1);
        _rep(i, 0, n) _rep(j, 0, n) _rep(k, 0, 1) f[i][j][k] = -inf;
        f[0][0][0] = 0;
        _rep(i, 0, n - 1){
            _rep(j, 0, i){
                if(j){
                    if(s[i + 1] != '>'){//i + 1 往左走
                        f[i + 1][j - 1][0] = max(f[i + 1][j - 1][0], f[i][j][0] + 2);
                        f[i + 1][j - 1][0] = max(f[i + 1][j - 1][0], f[i][j][1] + 1);
                        f[i + 1][j][0] = max(f[i + 1][j][0], f[i][j][1]);
                    }
                    if(s[i + 1] != '<'){//i + 1 往右走
                        f[i + 1][j][1] = max(f[i + 1][j][1], f[i][j][0] + 1);
                        f[i + 1][j + 1][1] = max(f[i + 1][j + 1][1], f[i][j][1]);
                    }
                }else{
                    if(s[i + 1] != '>'){
                        f[i + 1][j][0] = max(f[i + 1][j][0], f[i][j][0]);
                    }
                    if(s[i + 1] != '<'){
                        f[i + 1][j + 1][1] = max(f[i + 1][j + 1][1], f[i][j][0]);
                    }
                }
            }
        }
        debug("%d\n", f[2][2][1]);
        int ans = 0;
        _rep(i, 0, n) ans = max(ans, max(f[n][i][0] + (i > 0), f[n][i][1]));
        writeln(ans);
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 5936kb

input:

10
?>?
>?<
??<?
?><?<
??????
>?<?<>?<?<
?><???><><
??>>><><??
<>>?>>?>?>
<?<>>??<?>

output:

2
2
3
4
5
8
7
8
5
6

result:

ok 10 numbers

Test #2:

score: -100
Wrong Answer
time: 25ms
memory: 3892kb

input:

100000
>?<?<>?<?<
?><???><><
??>>><><??
<>>?>>?>?>
<?<>>??<?>
>><>><<<<<
>?>?>?<<>>
?><?<<?<><
???><>?>?>
<??>?<<><?
??>><?<>>>
<><><?<>>?
?>>?>???><
?<?><?<<>?
>>><?<??><
><><<>?>?<
>?><>><<<?
>??>?><?<>
?????<><?>
<><<?<<>?<
><?>>?>?>?
?><><<<>>?
?<>?<>?<<<
<><<<<<>>>
?>?>?><<>>
<>?<>><>?<
<<<?<>>...

output:

8
7
8
5
6
7
6
6
6
7
6
5
8
6
8
7
8
7
7
6
6
7
7
2
6
6
3
9
6
5
5
7
5
8
7
6
8
7
7
6
6
7
4
2
7
5
8
7
8
5
6
5
7
8
8
8
8
7
5
5
7
7
6
8
7
5
8
6
6
8
7
7
6
8
5
7
6
6
5
5
7
7
5
3
8
6
5
7
5
7
6
7
7
8
3
8
8
7
8
7
7
4
8
8
7
5
8
6
7
7
8
7
5
7
8
5
7
6
5
8
8
7
7
8
6
7
8
6
6
8
7
8
7
6
5
5
7
8
6
8
6
7
5
7
4
6
6
7
7
7
...

result:

wrong answer 6th numbers differ - expected: '8', found: '7'