QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#759580#9345. Artful PaintingsScene#WA 37ms4000kbC++143.1kb2024-11-18 10:14:132024-11-18 10:14:13

Judging History

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

  • [2024-11-18 10:14:13]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:4000kb
  • [2024-11-18 10:14:13]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#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<tuple<bool,int,int>> G[Maxn];
int num[Maxn];
bool check(int x){
    // for(int i=0;i<=n;++i){
    //     bool fl;
    //     int v,w;
    //     // gdb(G[i].size());
    //     for(auto [fl,v,w]:G[i]){
    //         if(fl) w=x-w;
    //         // cerr<<i<<" "<<v<<" "<<w<<endl;
    //     }
    // }
    queue<int> q;
    memset(f,1,sizeof f);
    memset(num,0,sizeof num);
    bitset<Maxn> vis;
    f[0]=0;q.push(0);vis[0]=1;
    // for(int i=0;i<=n;++i){
    //     q.push(i);
    //     vis[i]=1;
    // }
    while(!q.empty()){
        int u = q.front(); q.pop();
        num[u]++;
        if(num[u]>n){
            return 0;
        }
        vis[u]=0;
        bool fl;
        int v=0,w=0;
        for(auto [fl,v,w] : G[u]){
            if(fl) w=x-w;
            if(f[v]>f[u]+w){
                f[v]=f[u]+w;
                if(!vis[v]){
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
    // for(int i=0;i<=n;++i){
    //     cerr<<i<<":"<<f[i]<<endl;
    // }
    // for(int i=n;i>=0;--i) f[i]-=f[0];
    // for(int i=0;i<=n;++i){
    //     cerr<<i<<":"<<f[i]<<endl;
    // }
    // for(int i=0;i<=n;++i){
    //     if(f[i]==f[n+1]) continue;
    //     if(f[i]>i||f[i]>x){
    //         return 0;
    //     }
    // }
    return 1;
}
void work(){
    n = read(), m1 = read(), m2 = read();
    for(int i=0;i<=n;++i) G[i].clear();
    for(int i=1;i<=n;++i) G[i].pb({0,0,0});
    for(int i=1;i<=n;++i) G[0].pb({0,i,i});
    int l, r, k;
    for(int i = 1; i <= m1; i++){
        l = read(), r = read(), k = read();
        G[r].pb({0,l - 1, -k});
    }
    for(int i = 1; i <= m2; i++){
        l = read(), r = read(), k = read();
        G[l-1].pb({1,r,k});
    }
    // check(1);
    l = 0, r = n;
    int ans=0;
    while(l <= r){
        int mid = (l + r) >> 1;
        if(check(mid)){
            r = mid - 1, ans = mid;
        }else l = mid + 1;
    }
    cout<< ans <<endl;
}
signed main(){
    int t = read();
    while(t--){
        work();
    }
}

詳細信息

Test #1:

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

input:

1
3 1 1
1 2 1
2 2 1

output:

1

result:

ok single line: '1'

Test #2:

score: -100
Wrong Answer
time: 37ms
memory: 4000kb

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:

421

result:

wrong answer 1st lines differ - expected: '492', found: '421'