# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
931420 |
2024-02-21T18:43:15 Z |
YassirSalama |
Game (APIO22_game) |
C++17 |
|
4000 ms |
3760 KB |
#include "game.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <limits>
#include <map>
#include <utility>
#include <cctype>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include<assert.h>
#include <functional>
#include <iterator>
using namespace std;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
#define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n";
#ifdef IOI
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#else
#define dbg(...) 1337;
#endif
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define ll long long
#define mod 1000000007
#define all(v) v.begin(),v.end()
const int MAXN=3e4+100;
vector<int> v[MAXN];
int k;
int n;
void init(int N, int K) {
n=N;
k=K;
for(int i=0;i<=k-2;i++){
// dbg(i,i+1)
v[i].pb(i+1);
}
}
bool visited[MAXN];
bool check(int a){
return 0<=a&&a<=k-1;
}
bool dfs(int node,int top){
dbg(node,top)
if(visited[node]) {
if(top>=node) return true;
else return false;
}
visited[node]=true;
for(auto x:v[node]){
if(check(node)&&check(x)) {
if(x-node==1) {
if(dfs(x,x)) return true;
}else {
// dbg(x,node,visited[x])
if(dfs(x,node)) return true;
}
}else{
if(dfs(x,top)) return true;
}
}
return false;
}
int add_teleporter(int a, int b) {
v[a].pb(b);
memset(visited,false,sizeof(visited));
bool ok=dfs(0,0);
dbg(ok);
return ok;
}
#ifdef IOI
#include <cstdio>
#include <cstdlib>
#include <vector>
#include "game.h"
namespace {
int read_int() {
int x;
if (scanf("%d", &x) != 1) {
fprintf(stderr, "Error while reading input\n");
exit(1);
}
return x;
}
} // namespace
int main() {
int N = read_int();
int M = read_int();
int K = read_int();
std::vector<int> u(M), v(M);
for (int i = 0; i < M; ++i) {
u[i] = read_int();
v[i] = read_int();
}
init(N, K);
int i;
for (i = 0; i < M; ++i) {
int answer = add_teleporter(u[i], v[i]);
if (answer != 0 && answer != 1) {
i = -1;
break;
} else if (answer == 1) {
break;
}
}
printf("%d\n", i);
return 0;
}
#endif
Compilation message
game.cpp: In function 'bool dfs(int, int)':
game.cpp:29:18: warning: statement has no effect [-Wunused-value]
29 | #define dbg(...) 1337;
| ^~~~
game.cpp:55:3: note: in expansion of macro 'dbg'
55 | dbg(node,top)
| ^~~
game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:29:18: warning: statement has no effect [-Wunused-value]
29 | #define dbg(...) 1337;
| ^~~~
game.cpp:79:3: note: in expansion of macro 'dbg'
79 | dbg(ok);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
1 ms |
1364 KB |
Output is correct |
21 |
Correct |
1 ms |
1112 KB |
Output is correct |
22 |
Correct |
2 ms |
1444 KB |
Output is correct |
23 |
Correct |
1 ms |
1112 KB |
Output is correct |
24 |
Correct |
7 ms |
1368 KB |
Output is correct |
25 |
Correct |
30 ms |
1368 KB |
Output is correct |
26 |
Correct |
33 ms |
1368 KB |
Output is correct |
27 |
Correct |
40 ms |
1112 KB |
Output is correct |
28 |
Correct |
14 ms |
1112 KB |
Output is correct |
29 |
Correct |
32 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
1 ms |
1364 KB |
Output is correct |
21 |
Correct |
1 ms |
1112 KB |
Output is correct |
22 |
Correct |
2 ms |
1444 KB |
Output is correct |
23 |
Correct |
1 ms |
1112 KB |
Output is correct |
24 |
Correct |
7 ms |
1368 KB |
Output is correct |
25 |
Correct |
30 ms |
1368 KB |
Output is correct |
26 |
Correct |
33 ms |
1368 KB |
Output is correct |
27 |
Correct |
40 ms |
1112 KB |
Output is correct |
28 |
Correct |
14 ms |
1112 KB |
Output is correct |
29 |
Correct |
32 ms |
1112 KB |
Output is correct |
30 |
Correct |
91 ms |
2120 KB |
Output is correct |
31 |
Correct |
60 ms |
1804 KB |
Output is correct |
32 |
Correct |
55 ms |
2928 KB |
Output is correct |
33 |
Correct |
27 ms |
2392 KB |
Output is correct |
34 |
Correct |
1074 ms |
3760 KB |
Output is correct |
35 |
Execution timed out |
4027 ms |
2632 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1112 KB |
Output is correct |
12 |
Correct |
1 ms |
1112 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
1 ms |
1112 KB |
Output is correct |
15 |
Correct |
1 ms |
1112 KB |
Output is correct |
16 |
Correct |
1 ms |
1112 KB |
Output is correct |
17 |
Correct |
1 ms |
1112 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1112 KB |
Output is correct |
20 |
Correct |
1 ms |
1364 KB |
Output is correct |
21 |
Correct |
1 ms |
1112 KB |
Output is correct |
22 |
Correct |
2 ms |
1444 KB |
Output is correct |
23 |
Correct |
1 ms |
1112 KB |
Output is correct |
24 |
Correct |
7 ms |
1368 KB |
Output is correct |
25 |
Correct |
30 ms |
1368 KB |
Output is correct |
26 |
Correct |
33 ms |
1368 KB |
Output is correct |
27 |
Correct |
40 ms |
1112 KB |
Output is correct |
28 |
Correct |
14 ms |
1112 KB |
Output is correct |
29 |
Correct |
32 ms |
1112 KB |
Output is correct |
30 |
Correct |
91 ms |
2120 KB |
Output is correct |
31 |
Correct |
60 ms |
1804 KB |
Output is correct |
32 |
Correct |
55 ms |
2928 KB |
Output is correct |
33 |
Correct |
27 ms |
2392 KB |
Output is correct |
34 |
Correct |
1074 ms |
3760 KB |
Output is correct |
35 |
Execution timed out |
4027 ms |
2632 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |