Can anyone tell me why I'm getting WA on Test case 1 ?? Since it was Constructive Algo, I'm not able to figure out what's wrong in the logic .
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3821 |
3 | Benq | 3736 |
4 | Radewoosh | 3631 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3388 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
Can anyone tell me why I'm getting WA on Test case 1 ?? Since it was Constructive Algo, I'm not able to figure out what's wrong in the logic .
Dear MikeMirzayanov , Today I received a mail saying the submission of Problem A and B coincides with a lot of many participants.
I don't know what they all submitted. I believe problem A was pretty straightforward, I saw the same solution in almost 90-95 % of participants after the Contest.
Talking about problem B, I did it by myself only. First I did it by map ,but got WA on Testcase 2 . After thinking a lot only solution was left in my mind was Brute Force for me which took a lot of time (for me).
I didn't involve in any unfair practice. I'm saying this because I have been wrongly penalized before also. I was new at this platform so didn't know how to appeal. But this time it's 2nd time that I have been penalized after giving fair competition also.
My 1st Solution for B (which got WA on TC-2 ) : Submission-1
After devoting a lot of time I finally came up with a brute force solution which got AC: Submission-2
I can say that this time also I didn't cheat and gave fair competition.
I hope you take the necessary steps regarding this and overturn the penalty.
Thank you to devote your time to read this blog
Hey everyone! I hope you are doing extremely well. I have been doing Graphs from CSES Problem set and unfortunately got stuck in SHORTEST PATH — 1 Problem.
I'm getting WA in 6th , 7th , 8th , 9th and 12th TestCase. Though I have used long long int then also , its giving WA .
If you have got AC, then please help me out.
Thank you, to give your precious time to read this blog and pointing out mistakes :)
Keep Coding !!
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define time cerr<<"Time taken : " <<(float)clock()/CLOCKS_PER_SEC <<" secs"<<"\n" ;
#define F first
#define S second
#define pb push_back
typedef long long int ll ;
#define INF 1e15
#define MOD 1000000007
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
int32_t main() {
fast ;
ll n , m ;
cin >> n >> m ;
vector<vector<pair<ll, ll>>>adj;
adj.resize(n + 1) ;
for (ll i = 0; i < m ; i++) {
ll a , b , w ;
cin >> a >> b >> w;
adj[a].pb({b, w}) ;
}
vector<ll>dist ;
dist.resize(n + 1) ;
for (ll i = 0 ; i <= n ; i++) {
dist[i] = INT_MAX;
}
priority_queue < pair<ll, ll> , vector<pair<ll, ll>>, greater<pair<ll, ll>> > pq ;
dist[1] = 0 ;
pq.push({0, 1}) ;
while (!pq.empty()) {
ll d = pq.top().F ;
ll n = pq.top().S;
pq.pop() ;
if (dist[n] < d ) continue ;
for (auto x : adj[n]) {
ll n1 = x.F;
ll d1 = x.S;
if (dist[n1] <= d1 + d) continue ;
else if (dist[n1] > d + d1 ) {
dist[n1] = d + d1;
pq.push({dist[n1] , n1}) ;
}
}
}
for (ll i = 1; i <= n; i++) {
cout << dist[i] << " " ;
}
return 0 ;
}
Can anyone just tell me Whats's wrong with my Code ??
Problem : Daniel is a chess player. At his free time, he usually plays chess with his family or his friends. But, sometimes they have their own activities, so Daniel can't play chess. He spends his time to learn about knight's move. He has 1,000 x 1,000 chessboard, numbered from 1 to 1,000. He wants to move his knight from (a,b) to (1,1) with minimum movement. Help Daniel to solve it.
MY CODE :
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define time cerr<<"Time taken : " <<(float)clock()/CLOCKS_PER_SEC <<" secs"<<"\n" ;
#define F first
#define S second
#define pb push_back
typedef long long int ll ;
#define INF 1e15
#define MOD (int)1e9+7
// #define TRACE
// #ifdef TRACE
// #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
// template <typename Arg1>
// void __f(const char* name, Arg1&& arg1) {
// cerr << name << " : " << arg1 << std::endl;
// }
// template <typename Arg1, typename... Args>
// void __f(const char* names, Arg1&& arg1, Args&&... args) {
// const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
// }
// #else
// #define trace(...)
// #endif
ll visit[1004][1004] ;
ll chess[1004][1004] ;
ll dx[] = {2, 2, -2, -2, 1, 1, -1, -1};
ll dy[] = { -1, 1, -1, 1, 2, -2, 2, -2};
bool VALID( ll x , ll y) {
return (x >= 0 && x < 1000 && y >= 0 && y < 1000) ;
}
void BFS(ll a , ll b) {
memset(chess , 0 , sizeof (chess)) ;
memset(visit , 0 , sizeof(visit)) ;
visit[a][b] = 1;
chess[a][b] = 0;
queue<pair<ll, ll>>q ;
q.push({a , b}) ;
while (!q.empty()) {
pair<ll, ll>curr = q.front() ;
q.pop() ;
for (int i = 0 ; i < 8 ; i++) {
ll curr_x = curr.F + dx[i];
ll curr_y = curr.S + dy[i];
if (VALID(curr_x , curr_y) && !visit[curr_x][curr_y]) {
visit[curr_x][curr_y] = 1 ;
chess[curr_x][curr_y] = chess[curr.F][curr.S] + 1;
q.push({curr_x , curr_y}) ;
}
}
}
}
int32_t main() {
fast ; time;
BFS(1, 1) ;
#ifndef ONLINE_JUDGE
freopen("input.txt" , "r" , stdin) ;
freopen("output.txt" , "w" , stdout) ;
#endif
ll t = 1;
cin >> t;
while (t--) {
ll x, y;
cin >> x >> y;
cout << chess[x][y] << "\n" ;
}
return 0 ;
}
Hey Everyone, I hope everyone is doing great and healthy !!
I recently studied Graphs and also solved basic questions on them. Now I want to solve Questions from Codeforces. If anyone had any list of Graph Question ( topic wise like DFS, BFS, Bipartite, etc ) from Codeforces, then please share it. It will be very helpful for me.
Thank you
Are we not having any Div. Contest in May month ??
Name |
---|