Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
Untitled Diff
생성일
6년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
0 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
134 행
복사
6 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
136 행
복사
/*
/*
// sol used...
// sol used...
credits: @yash_daga
credits: @yash_daga
author : Aryan Agarwal, IIT KGP
author : Aryan Agarwal, IIT KGP
created : 18-December-2020 12:24:57 IST
created : 18-December-2020 12:24:57 IST
*/
*/
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using namespace std;
#define int long long
#define int long long
const int mxn = 1e5;
const int mxn = 1e5;
const long long INF = 2e18;
const long long INF = 2e18;
const int32_t M = 1000000007; /*more than (10)^9*/ /*7 + 1e9*/
const int32_t M = 1000000007; /*more than (10)^9*/ /*7 + 1e9*/
// const int32_t M = 998244353; /*less than (10)^9*/ /*1 + 7*17*(2)^23*/
// const int32_t M = 998244353; /*less than (10)^9*/ /*1 + 7*17*(2)^23*/
const long double pie = acos(-1);
const long double pie = acos(-1);
#define X first
#define X first
#define Y second
#define Y second
#define pb push_back
#define pb push_back
#define sz(a) ((int)(a).size())
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()
#define all(a) (a).begin(), (a).end()
#define F(i, a, b) for (int i = a; i <= b; i++)
#define F(i, a, b) for (int i = a; i <= b; i++)
#define RF(i, a, b) for (int i = a; i >= b; i--)
#define RF(i, a, b) for (int i = a; i >= b; i--)
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
void __f(const char* name, Arg1&& arg1){
cout << name << " : " << arg1 << std::endl;
cout << name << " : " << arg1 << std::endl;
}
}
template <typename Arg1, typename... Args>
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
}
void solve()
void solve()
{
{
int n;
int n;
cin>>n;
cin>>n;
vector <int> b(n),a(n),cnt(2*n+1,0);
vector <int> b(n),a(n),cnt(2*n+1,0);
F(i,0,n-1){cin>>b[i];cnt[b[i]]++;}
F(i,0,n-1){cin>>b[i];cnt[b[i]]++;}
int ind=0;
int ind=0;
F(i,1,2*n)
F(i,1,2*n)
{
{
if(cnt[i]==0)a[ind++]=i;
if(cnt[i]==0)a[ind++]=i;
}
}
set<int> s[2][2];
set<int> s[2][2];
F(i,0,n-1)
F(i,0,n-1)
{
{
if(b[i]>a[i])
if(b[i]>a[i])
{
{
s[0][0].insert(b[i]);
s[0][0].insert(b[i]);
s[0][1].insert(a[i]);
s[0][1].insert(a[i]);
}
}
else
else
{
{
s[1][0].insert(b[i]);
s[1][0].insert(b[i]);
s[1][1].insert(a[i]);
s[1][1].insert(a[i]);
}
}
}
}
int ans=0;
int ans=0;
for(int x : s[0][0])
for(int x : s[0][0])
{
{
복사
복사됨
복사
복사됨
auto it=upper_bound(all(s[0][1]),x);
//
auto it=upper_bound(all(s[0][1]),x);
auto it=s[0][1].upper_bound(x);
if(it!=s[0][1].end())
if(it!=s[0][1].end())
{
{
ans++;
ans++;
s[0][1].erase(it);
s[0][1].erase(it);
}
}
else
else
{
{
break;
break;
}
}
}
}
for(int x : s[1][1])
for(int x : s[1][1])
{
{
복사
복사됨
복사
복사됨
auto it=upper_bound(all(s[1][0]),x);
//
auto it=upper_bound(all(s[1][0]),x);
auto it=s[1][0].upper_bound(x);
if(it!=s[1][0].end())
if(it!=s[1][0].end())
{
{
ans++;
ans++;
s[1][0].erase(it);
s[1][0].erase(it);
}
}
else
else
{
{
break;
break;
}
}
}
}
cout<<ans+1;
cout<<ans+1;
cout<<"\n";
cout<<"\n";
}
}
signed main()
signed main()
{
{
ios_base::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin.tie(NULL);
cout.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// freopen("output.txt","w",stdout);
#endif
#endif
#ifdef ARYAN_SIEVE
#ifdef ARYAN_SIEVE
// defualt mxn_sieve = 1e5
// defualt mxn_sieve = 1e5
sieve();
sieve();
#endif
#endif
#ifdef ARYAN_SEG_SIEVE
#ifdef ARYAN_SEG_SIEVE
// default [L,R] = [1,1e5]
// default [L,R] = [1,1e5]
segmented_sieve();
segmented_sieve();
#endif
#endif
#ifdef ARYAN_FACT
#ifdef ARYAN_FACT
// default mxn_fact = 1e5
// default mxn_fact = 1e5
fact_init();
fact_init();
#endif
#endif
// cout<<fixed<<setprecision(10);
// cout<<fixed<<setprecision(10);
int _t=1;
int _t=1;
cin>>_t;
cin>>_t;
for (int i=1;i<=_t;i++)
for (int i=1;i<=_t;i++)
{
{
// cout<<"Case #"<<i<<": ";
// cout<<"Case #"<<i<<": ";
solve();
solve();
}
}
return 0;
return 0;
}
}
저장된 비교 결과
원본
파일 열기
/* // sol used... credits: @yash_daga author : Aryan Agarwal, IIT KGP created : 18-December-2020 12:24:57 IST */ #include <bits/stdc++.h> using namespace std; #define int long long const int mxn = 1e5; const long long INF = 2e18; const int32_t M = 1000000007; /*more than (10)^9*/ /*7 + 1e9*/ // const int32_t M = 998244353; /*less than (10)^9*/ /*1 + 7*17*(2)^23*/ const long double pie = acos(-1); #define X first #define Y second #define pb push_back #define sz(a) ((int)(a).size()) #define all(a) (a).begin(), (a).end() #define F(i, a, b) for (int i = a; i <= b; i++) #define RF(i, a, b) for (int i = a; i >= b; i--) #define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cout << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); } void solve() { int n; cin>>n; vector <int> b(n),a(n),cnt(2*n+1,0); F(i,0,n-1){cin>>b[i];cnt[b[i]]++;} int ind=0; F(i,1,2*n) { if(cnt[i]==0)a[ind++]=i; } set<int> s[2][2]; F(i,0,n-1) { if(b[i]>a[i]) { s[0][0].insert(b[i]); s[0][1].insert(a[i]); } else { s[1][0].insert(b[i]); s[1][1].insert(a[i]); } } int ans=0; for(int x : s[0][0]) { auto it=upper_bound(all(s[0][1]),x); if(it!=s[0][1].end()) { ans++; s[0][1].erase(it); } else { break; } } for(int x : s[1][1]) { auto it=upper_bound(all(s[1][0]),x); if(it!=s[1][0].end()) { ans++; s[1][0].erase(it); } else { break; } } cout<<ans+1; cout<<"\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); #endif #ifdef ARYAN_SIEVE // defualt mxn_sieve = 1e5 sieve(); #endif #ifdef ARYAN_SEG_SIEVE // default [L,R] = [1,1e5] segmented_sieve(); #endif #ifdef ARYAN_FACT // default mxn_fact = 1e5 fact_init(); #endif // cout<<fixed<<setprecision(10); int _t=1; cin>>_t; for (int i=1;i<=_t;i++) { // cout<<"Case #"<<i<<": "; solve(); } return 0; }
수정본
파일 열기
/* // sol used... credits: @yash_daga author : Aryan Agarwal, IIT KGP created : 18-December-2020 12:24:57 IST */ #include <bits/stdc++.h> using namespace std; #define int long long const int mxn = 1e5; const long long INF = 2e18; const int32_t M = 1000000007; /*more than (10)^9*/ /*7 + 1e9*/ // const int32_t M = 998244353; /*less than (10)^9*/ /*1 + 7*17*(2)^23*/ const long double pie = acos(-1); #define X first #define Y second #define pb push_back #define sz(a) ((int)(a).size()) #define all(a) (a).begin(), (a).end() #define F(i, a, b) for (int i = a; i <= b; i++) #define RF(i, a, b) for (int i = a; i >= b; i--) #define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cout << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); } void solve() { int n; cin>>n; vector <int> b(n),a(n),cnt(2*n+1,0); F(i,0,n-1){cin>>b[i];cnt[b[i]]++;} int ind=0; F(i,1,2*n) { if(cnt[i]==0)a[ind++]=i; } set<int> s[2][2]; F(i,0,n-1) { if(b[i]>a[i]) { s[0][0].insert(b[i]); s[0][1].insert(a[i]); } else { s[1][0].insert(b[i]); s[1][1].insert(a[i]); } } int ans=0; for(int x : s[0][0]) { // auto it=upper_bound(all(s[0][1]),x); auto it=s[0][1].upper_bound(x); if(it!=s[0][1].end()) { ans++; s[0][1].erase(it); } else { break; } } for(int x : s[1][1]) { // auto it=upper_bound(all(s[1][0]),x); auto it=s[1][0].upper_bound(x); if(it!=s[1][0].end()) { ans++; s[1][0].erase(it); } else { break; } } cout<<ans+1; cout<<"\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); #endif #ifdef ARYAN_SIEVE // defualt mxn_sieve = 1e5 sieve(); #endif #ifdef ARYAN_SEG_SIEVE // default [L,R] = [1,1e5] segmented_sieve(); #endif #ifdef ARYAN_FACT // default mxn_fact = 1e5 fact_init(); #endif // cout<<fixed<<setprecision(10); int _t=1; cin>>_t; for (int i=1;i<=_t;i++) { // cout<<"Case #"<<i<<": "; solve(); } return 0; }
비교하기