이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma optimize("O3")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include <ext/pb_ds/assoc_container.hpp>
#define ve vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define si(v) (int)v.size()
#define en '\n'
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_muiltiset tree<int, null_type,less_equal<>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e4 + 228;
const int big = 1e9;
const ll llbig = 1e18 + 228;
//ordered_set os; // os.order_of_key(4), (*os.find_by_order(5))
int n, m, k;
string a[N];
gp_hash_table<string, int> mem;
set<string> ans;
bool getbit(int x, int bit){
bit--;
return (x & (1 << bit)) == (1 << bit);
}
int main(){
cin >> n >> k;
for (int i = 1; i <= n; i++){
cin >> a[i];
mem[a[i]] = i;
/*for (int mask = 0; mask <= (1 << (k + 1)); mask++){
for (int j = 1; j <= k; j++){
if (getbit(mask, j)){
if (a[i][j] == 1) str += "q";
if (a[i][j] == 2) str += "w";
if (a[i][j] == 3) str += "e";
}else{
if (a[i][j] == 1) str += "1";
if (a[i][j] == 2) str += "2";
if (a[i][j] == 3) str += "3";
}
}
}*/
}
for (int x = 1; x <= n; x++){
for (int y = x + 1; y <= n; y++){
string str = "";
for (int i = 0; i < k; i++){
if (a[x][i] == a[y][i]){
str += a[x][i];
}
if (a[x][i] != a[y][i]){
char c1 = a[x][i]; if ((int)a[x][i] > (int)a[y][i]) c1 = a[y][i];
char c2 = a[x][i]; if ((int)a[x][i] < (int)a[y][i]) c2 = a[y][i];
if (c1 == '2' && c2 == '3') str += "1";
if (c1 == '1' && c2 == '3') str += "2";
if (c1 == '1' && c2 == '2') str += "3";
}
}
if (mem[str]) {
ve v;
v.pb(x);
v.pb(y);
v.pb(mem[str]);
sort(all(v));
//ans[to_string(v[0]) + "_" + to_string(v[1]) + "_" + to_string(v[2])] = 1;
ans.insert(to_string(v[0]) + "_" + to_string(v[1]) + "_" + to_string(v[2]));
}
}
}
cout << si(ans);
return 0;
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
2 | #pragma optimize("O3")
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |