QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#781515#9802. Light Up the GridA_J1e#WA 14ms3804kbC++231.4kb2024-11-25 16:19:412024-11-25 16:19:43

Judging History

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

  • [2024-11-25 16:19:43]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3804kb
  • [2024-11-25 16:19:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using i32 = int;
using i64 = long long;
using i128=__int128;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    i32 t=1;
    vector<i32> a(4);
    cin>>t;
    for(auto &i:a) cin>>i;
    vector<i32> f(16);
    f[0]=min({4*a[0],2*a[1],2*a[2],a[3]});
    f[15]=2*min({a[0],a[1],a[2],a[3]});
    for(i32 i=1;i<16;i*=2) f[15-i]=a[0],f[i]=min({3*a[0],a[0]+a[1],a[0]+a[2],a[0]+a[3]});
    f[3]=min(a[1],2*a[0]);f[12]=f[3];
    f[5]=min(a[2],2*a[0]);f[10]=f[5];
    f[6]=min(a[0]+a[0],a[1]+a[2]);f[9]=f[6];
    auto solve=[&]()->void
    {
        i32 n;cin>>n;
        vector<i32> g;
        while(n--)
        {
            string s1,s2;cin>>s1>>s2;
            i32 t=0;
            t+=(s1[0]-'0')*1+(s1[1]-'0')*2;
            t+=(s2[0]-'0')*4+(s2[1]-'0')*8;
            g.push_back(t);
        }
        i32 sum=0;
        while(!g.empty())
        {
            //for(auto it:g) cout<<it<<' ';
            //cout<<'\n';
            i32 pos=0;
            for(i32 i=1;i<(i32)g.size();++i)
            {
                if(f[g[i]]<f[g[pos]]) pos=i;
            }
            sum+=f[g[pos]];
            vector<i32> h;
            for(i32 i=0;i<(i32)g.size();++i) if(pos!=i) h.push_back(g[i]^(15^g[pos]));
            g.clear();g=h;
            //cout<<sum<<'\n';
        }
        cout<<sum<<'\n';
    };
    while(t--) solve();
}

详细

Test #1:

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

input:

2 1000 100 10 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

1121
2

result:

ok 2 number(s): "1121 2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

2 1 1 1 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

5
2

result:

ok 2 number(s): "5 2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

1 1000000 1000000 1000000 1000000
1
11
11

output:

2000000

result:

ok 1 number(s): "2000000"

Test #4:

score: -100
Wrong Answer
time: 14ms
memory: 3776kb

input:

10000 8 2 7 8
8
00
01

00
11

00
10

11
11

10
10

01
10

01
00

10
11
8
11
01

11
00

01
10

11
11

00
01

01
01

01
00

11
10
9
00
00

01
01

10
11

00
01

11
10

11
00

11
11

00
11

01
10
9
11
11

10
00

11
00

11
01

00
10

01
11

00
01

01
01

10
01
11
00
01

01
01

10
10

00
11

11
11

11
10
...

output:

34
32
36
36
40
38
42
38
40
42
36
44
34
37
39
34
29
39
40
40
38
41
46
38
31
40
37
38
34
35
32
42
34
38
42
40
46
34
39
36
29
38
40
40
45
39
39
38
38
40
42
29
43
42
36
42
46
40
41
34
42
40
37
33
34
40
38
37
42
40
36
38
29
34
34
38
36
39
38
38
36
38
35
36
36
34
42
42
38
38
40
40
40
42
38
29
36
40
38
36
...

result:

wrong answer 6th numbers differ - expected: '36', found: '38'