# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
402582 |
2021-05-12T02:10:35 Z |
jamezzz |
Colors (RMI18_colors) |
C++14 |
|
3000 ms |
6908 KB |
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#include <ext/rope>
using namespace __gnu_cxx;
typedef tree<long long, null_type, less<long long>,
rb_tree_tag, tree_order_statistics_node_update> pbds;
//less_equal for identical elements
#define DEBUG
#ifdef DEBUG
#define debug(...) printf(__VA_ARGS__);
#else
#define debug(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define sz(x) (int)x.size()
#define mnto(x,y) x=min(x,(__typeof__(x))y)
#define mxto(x,y) x=max(x,(__typeof__(x))y)
#define INF 1023456789
#define LINF 1023456789123456789
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vll;
int n,m,a[150005],b[150005],u,v;
bool found,vis[150005];
vi AL[150005];
stack<int> s;
void dfs(int u,int w){
if(a[u]==w)found=true;
vis[u]=true;s.push(u);
for(int v:AL[u]){
if(vis[v]||w<b[v]||a[v]<w)continue;
dfs(v,w);
}
}
int main(){
int t;sf("%d",&t);
while(t--){
sf("%d%d",&n,&m);
bool pos=true;
for(int i=1;i<=n;++i){
AL[i].clear();
sf("%d",&a[i]);
}
for(int i=1;i<=n;++i){
sf("%d",&b[i]);
if(b[i]>a[i])pos=false;
}
for(int i=0;i<m;++i){
sf("%d%d",&u,&v);
AL[u].pb(v);
AL[v].pb(u);
}
for(int i=1;i<=n;++i){
found=false;dfs(i,b[i]);
pos=pos&&found;
if(!pos)break;
while(!s.empty())vis[s.top()]=false,s.pop();
}
pf("%d\n",pos);
}
}
Compilation message
colors.cpp: In function 'int main()':
colors.cpp:56:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
56 | int t;sf("%d",&t);
| ^
colors.cpp:58:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
58 | sf("%d%d",&n,&m);
| ^
colors.cpp:62:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
62 | sf("%d",&a[i]);
| ^
colors.cpp:65:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
65 | sf("%d",&b[i]);
| ^
colors.cpp:69:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
69 | sf("%d%d",&u,&v);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
5316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
103 ms |
5500 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
93 ms |
5216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
93 ms |
5216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
5316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
243 ms |
6908 KB |
Output is correct |
2 |
Execution timed out |
3088 ms |
6212 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
4604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
5316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |