# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199832 | 2020-02-03T14:53:33 Z | Mercenary | Flood (IOI07_flood) | C++14 | 101 ms | 13812 KB |
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 2e5 + 5; int n , m; int d[maxn][4]; ii a[maxn]; vector<int> res; ii b[maxn]; int dir(int x , int y){ if(a[x].first == a[y].first){ if(a[x].second < a[y].second)return 0; else return 2; } if(a[x].first < a[y].first)return 1; return 3; } bool vis[maxn]; int flag = 0; void dfs(int u , int dir){ if(vis[u]){ flag = u;return; }; vis[u] = 1; for(int i = 5 ; i >= 2 ; --i){ int cur = (dir + i) % 4; if(!d[u][cur])continue; int c = d[u][cur]; int v = b[c].first + b[c].second - u; d[u][cur] = d[v][(cur + 2) % 4] = 0; dfs(v , cur); if(!flag){ res.pb(c); continue; } if(flag != u){ vis[u] = 0; return; } } flag = 0; vis[u] = 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n; vector<int> val(n);iota(val.begin(),val.end(),1); for(int i = 1 ; i <= n ; ++i)cin >> a[i].first >> a[i].second; sort(val.begin(),val.end(),[&](int x , int y){return a[x] < a[y];}); cin >> m; for(int i = 1 ; i <= m ; ++i){ cin >> b[i].first >> b[i].second; d[b[i].first][dir(b[i].first,b[i].second)] = i; d[b[i].second][dir(b[i].second,b[i].first)] = i; } for(auto & c : val)dfs(c,0); cout << res.size() << '\n';for(auto & c : res)cout << c << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 6 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 504 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 1400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 5116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 3768 KB | Output is correct |
2 | Correct | 101 ms | 5240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 82 ms | 4984 KB | Output is correct |
2 | Correct | 101 ms | 8312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 96 ms | 5112 KB | Output is correct |
2 | Correct | 87 ms | 13812 KB | Output is correct |