Submission #111980

#TimeUsernameProblemLanguageResultExecution timeMemory
111980AMO5Memory 2 (JOI16_memory2)C++98
0 / 100
3 ms384 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include "Memory2_lib.h" using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key #define all(x) (x).begin(), (x).end() typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef pair <ll, int> pli; typedef vector<int> vi; typedef vector<ll> vll; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set<int>::iterator sit; typedef map<int,int>::iterator mit; typedef vector<int>::iterator vit; long long INF=numeric_limits<long long>::max(); void Solve(int T, int N){ int p[1011],visit[1011]; int adj[55][55]; vector < pair < int, pii> > pos[55]; if(T==1) { int n = N*2; memset(p,0,sizeof(p)); for(int i = 1; i <= n; i++) { for(int j = i+1; j <= n; j++) { int x = Flip(i,j); adj[i-1][j-1] = x; adj[j-1][i-1] = x; } } for(int i = 0; i < n; i++) { for(int j = i+1; j < n; j++) { for(int k = j+1; k < n; k++) { if(adj[i][j]==adj[i][k]&&adj[i][j]==adj[j][k]) { int curr = adj[i][j]; pos[curr].pb(mp(i,mp(j,k))); //cout << adj[i][j] << " " << i << " " << j << " " << k << endl; } } } } /* cout << "***" << endl; for(int i = 0; i <= 50; i++) { if(pos[i].empty())continue; cout << i << endl; for(int j = 0; j < pos[i].size(); j++) { cout << pos[i][j].fi << " " << pos[i][j].se.fi << " " << pos[i][j].se.se << endl; } cout << endl; } cout << "***" << endl; */ int pos1(-1),pos2(-1); for(int i = 0; i <= 50; i++) { pos1 = -1; if(pos[i].empty())continue; int vis[n]; memset(vis,0,sizeof(vis)); //cout << i << " "; for(int j = 0; j < 2; j++) { //cout << pos[i][j].fi << " " << pos[i][j].se.fi << " " << pos[i][j].se.se << " "; if(!vis[pos[i][j].fi]) { vis[pos[i][j].fi] = 1; } else { if(pos1==-1)pos1 = pos[i][j].fi; else pos2 = pos[i][j].fi; } if(!vis[pos[i][j].se.fi]) { vis[pos[i][j].se.fi] = 1; } else { if(pos1==-1)pos1 = pos[i][j].se.fi; else pos2 = pos[i][j].se.fi; } if(!vis[pos[i][j].se.se]) { vis[pos[i][j].se.se] = 1; } else { if(pos1==-1)pos1 = pos[i][j].se.se; else pos2 = pos[i][j].se.se; } } //cout << endl; //cout << " ~ " << pos1 << " " << pos2 << endl; Answer(pos1,pos2,i); visit[pos1] = 1; visit[pos2] = 1; } pos1 = -1, pos2 = -1; for(int i = 0; i < n; i++) { if(visit[i]==0) { if(pos1==-1)pos1 = i; else { pos2 = i; break; } } } Answer(pos1,pos2,n/2-1); //for(int i = 0; i < n; i++)cout << p[i] << " " ; //cout << endl; } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...