QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#759647#9345. Artful PaintingsScene#WA 701ms3920kbC++142.7kb2024-11-18 10:49:182024-11-18 10:49:24

Judging History

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

  • [2024-11-18 10:49:24]
  • 评测
  • 测评结果:WA
  • 用时:701ms
  • 内存:3920kb
  • [2024-11-18 10:49:18]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define PII pair<int,int>
namespace IO {
    #define gh getchar
    inline int read(){char ch=gh();int x=0;bool t=0;while(ch<'0'||ch>'9')   t|=ch=='-',ch=gh();while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh();return t?-x:x;}
    inline char getc(){char ch=gh();while(ch<'a'||ch>'z') ch=gh();return ch;}
    inline void write(int x){if(x < 0){putchar('-');x = -x;}if(x > 9){write(x / 10);}putchar((x % 10 + '0'));}
}
using namespace IO;
using namespace std;
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else                                               
	#define gdb(...) void()
	#endif
}using namespace Debug;
const int Maxn = 3010, mod = 1e9 + 7;
int n,m1,m2;
int f[Maxn]; vector<pair<int,int>> G[Maxn];
int l1[Maxn], r1[Maxn], k1[Maxn];
int l2[Maxn], r2[Maxn], k2[Maxn];
int num[Maxn];
bool check(int x){
    queue<int> q;
    bitset<Maxn> vis;
    memset(f,0x3f,sizeof f);
    memset(num,0,sizeof num);
    f[0]=0;q.push(0);vis[0]=1;
    while(!q.empty()){
        int u = q.front(); q.pop();
        num[u]++;
        if(num[u]>=n){
            return 0;
        }
        vis[u]=0;
        int v=0,w=0;
        for(auto [v,w] : G[u]){
            if(f[v]>f[u]+w){
                f[v]=f[u]+w;
                if(!vis[v]){
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
    return 1;
}
void work(){
    n = read(), m1 = read(), m2 = read();
    for(int i = 1; i <= m1; i++){
        l1[i] = read(), r1[i] = read(), k1[i] = read();
    }
    for(int i = 1; i <= m2; i++){
        l2[i] = read(), r2[i] = read(), k2[i] = read();
    }
    for(int i=0;i<=n;++i) G[i].clear();
    for(int i=1;i<=n;++i) G[i].pb({i-1,0});
    for(int i=1;i<=n;++i) G[i-1].pb({i,1});
    for(int i = 1; i <= m1; i++){
        G[r1[i]].pb({l1[i] - 1, -k1[i]});
    }
    int l = 0, r = n;
    int ans=0;
    while(l <= r){
        int mid = (l + r) >> 1;
        for(int i = 1; i <= m2; i++){
            G[l2[i]-1].pb({r2[i],mid-k2[i]});
        }
        G[0].pb({n,mid});G[n].pb({0,-mid});
        if(check(mid)){
            r = mid - 1, ans = mid;
        }else l = mid + 1;
        for(int i = 1; i <= m2; i++){
            G[l2[i]-1].pop_back();
        }
        G[0].pop_back();G[n].pop_back();
    }
    cout<< ans <<endl;
}
signed main(){
    int t = read();
    while(t--){
        work();
    }
}

詳細信息

Test #1:

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

input:

1
3 1 1
1 2 1
2 2 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 111ms
memory: 3816kb

input:

1
1000 500 500
479 860 170
73 939 25
363 772 30
185 584 89
326 482 10
784 949 23
384 740 114
233 693 45
167 724 211
217 436 95
46 701 153
138 585 67
321 388 11
114 890 194
407 854 74
438 845 117
9 718 259
393 576 35
182 707 257
451 766 136
150 382 31
468 785 40
202 490 46
326 815 59
272 441 77
123 8...

output:

492

result:

ok single line: '492'

Test #3:

score: 0
Accepted
time: 543ms
memory: 3896kb

input:

1
3000 1000 1000
497 660 17
36 1021 195
2363 2786 90
1202 1218 5
1443 1627 76
2398 2642 59
1614 2082 296
2241 2286 3
360 2995 1736
2163 2566 245
526 990 103
916 1774 392
523 762 38
140 1912 187
472 2868 33
945 1039 60
739 2666 99
865 1440 143
1603 2378 97
672 1202 322
75 1406 367
1483 2534 397
1875 ...

output:

1977

result:

ok single line: '1977'

Test #4:

score: 0
Accepted
time: 701ms
memory: 3920kb

input:

1
3000 3000 3000
1277 1792 170
1578 1791 2
880 1814 109
2391 2691 185
385 1470 379
882 1802 315
1104 1616 310
121 1609 358
730 1880 729
1199 2068 535
666 2098 210
1642 1765 64
11 1567 437
188 2911 1398
2255 2257 0
2123 2428 32
797 1981 566
463 2583 125
517 2603 62
35 820 10
1446 2327 142
260 2997 92...

output:

1992

result:

ok single line: '1992'

Test #5:

score: 0
Accepted
time: 139ms
memory: 3740kb

input:

3
1000 500 500
591 664 15
735 959 57
537 897 80
744 964 57
666 917 58
121 545 83
352 374 2
300 377 20
140 889 156
658 905 59
395 595 36
675 784 22
593 967 86
435 620 34
478 846 75
46 680 124
81 882 165
20 471 87
279 393 27
693 716 4
125 734 121
154 921 160
109 691 114
3 802 160
743 833 19
216 236 5
...

output:

204
469
627

result:

ok 3 lines

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3736kb

input:

100
6 0 1
5 5 5
6 8 2
1 2 0
2 4 2
2 5 2
2 5 2
3 6 3
3 5 2
4 6 2
2 2 0
3 4 1
2 4 1
12 7 2
3 7 2
4 7 1
5 10 5
1 7 6
2 3 0
6 9 3
1 5 2
4 9 6
3 11 2
18 1 6
2 10 5
3 17 1
3 11 4
10 18 5
7 18 2
1 13 2
11 18 6
15 4 10
9 15 1
5 11 3
6 14 2
4 12 3
5 13 0
8 9 1
1 4 3
4 5 2
14 14 3
9 15 2
2 4 3
10 14 3
3 6 2
6...

output:

5
3
10
8
3
11
2
12
0
2
7
0
0
1
5
0
0
5
1
11
12
1
2
0
5
1
7
2
2
0
2
3
1
0
9
0
2
0
1
7
2
1
2
5
3
0
8
12
2
2
0
1
0
6
4
1
0
1
9
2
4
4
5
12
3
6
2
4
1
17
1
5
2
7
0
2
4
1
6
1
6
6
4
5
14
2
5
3
0
4
1
1
1
8
10
13
2
0
8
2

result:

wrong answer 24th lines differ - expected: '1', found: '0'