#include <cstdio>#include <vector>#include <algorithm>usingnamespacestd;#define EPS 1e-9#define abs(x) (((x) > 0) ? (x) : -(x))structPoint{doublex,y;Point(doublea=0.0,doubleb=0.0):x(a),y(b){}booloperator==(constPoint&a)const{return(abs(x-a.x)<EPS)&&(abs(y-a.y)<EPS);}};boollowerLeft(constPoint&a,constPoint&b){if(a.y<b.y)returntrue;if(a.y>b.y)returnfalse;if(a.x<b.x)returntrue;if(a.x>b.x)returnfalse;returnfalse;}inlinedoubleisLeft(constPoint&p0,constPoint&p1,constPoint&p2){return((p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y));}doubledist(constPoint&a,constPoint&b){return(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}Pointo;boolangleComp(constPoint&a,constPoint&b){doublev=isLeft(o,a,b);if(v>0)returntrue;if(v<0)returnfalse;returndist(o,a)<dist(o,b);}vector<Point>convex(vector<Point>a){if(a.size()<3)returna;vector<Point>r;r.clear();intn=a.size();sort(a.begin(),a.end(),lowerLeft);a.erase(unique(a.begin(),a.end()),a.end());o=a[0];sort(a.begin()+1,a.end(),angleComp);a.push_back(a[0]);inttop=2;r.push_back(a[0]);r.push_back(a[1]);for(inti=2;i<=n;i++){while(top>1&&isLeft(r[top-2],r[top-1],a[i])<=0){r.pop_back();top--;}r.push_back(a[i]);top++;}r.pop_back();top--;returnr;}vector<Point>a,b;boolcheck(){intc[3],d[3];for(inti=0;i<a.size();i++){for(intj=0;j<b.size();j++){doublep;c[0]=c[1]=c[2]=d[0]=d[1]=d[2]=0;for(intk=0;k<a.size();k++){p=isLeft(a[i],b[j],a[k]);if(p<-EPS)c[0]=1;elseif(p>EPS)c[2]=1;elsec[1]=1;}if(c[0]+c[2]==2)continue;for(intk=0;k<b.size();k++){p=isLeft(a[i],b[j],b[k]);if(p<-EPS)d[0]=1;elseif(p>EPS)d[2]=1;elsed[1]=1;}if(d[0]+d[2]==2)continue;if(c[0]+d[0]==2||d[2]+d[2]==2)continue;returntrue;}}returnfalse;}intmain(){intn,m,Q=0;while(scanf("%d %d",&n,&m)==2){if(n==0&&m==0)break;a.clear(),b.clear();intsx,sy,ex,ey;for(inti=0;i<n;i++){scanf("%d %d %d %d",&sx,&sy,&ex,&ey);a.push_back(Point(sx,sy));a.push_back(Point(sx,ey));a.push_back(Point(ex,sy));a.push_back(Point(ex,ey));}for(inti=0;i<m;i++){scanf("%d %d %d %d",&sx,&sy,&ex,&ey);b.push_back(Point(sx,sy));b.push_back(Point(sx,ey));b.push_back(Point(ex,sy));b.push_back(Point(ex,ey));}a=convex(a);b=convex(b);if(Q)printf("\n");printf("Case %d: ",++Q);if(check()){printf("It is possible to separate the two groups of vendors.\n");}else{printf("It is not possible to separate the two groups of vendors.\n");}}}
#include <cstdio>#include <string>#include <vector>#include <algorithm>usingnamespacestd;#define REP(i, n) for(int i = 0; i < (n); ++i)#define sz(x) ((x).size())chartmp[13];structMatrix{vector<longlong>left;vector<longlong>right;boolcheck(){REP(i,sz(left))if(left[i]!=0)returnfalse;returntrue;}};intmain(){intn;while(scanf("%d",&n)==1&&n){vector<string>a(n);vector<Matrix>T(n);stringS="";for(inti=0;i<n;i++){scanf("%s",&tmp);a[i]=tmp;S+=a[i];}sort(S.begin(),S.end());S.erase(unique(S.begin(),S.end()),S.end());REP(i,n){T[i].left.assign(sz(S),0);T[i].right.assign(n,0);REP(j,sz(a[i]))T[i].left[S.find(a[i][j])]++;T[i].right[i]=1;}intlast=0;REP(i,sz(S)){boolsw=false;for(intj=i;j<n;j++){if(T[j].left[i]!=0){swap(T[last],T[j]);sw=true;break;}}if(!sw)continue;for(intj=last+1;j<n;j++){if(T[j].left[i]!=0){longlongg=__gcd(T[last].left[i],T[j].left[i]);longlongl=T[last].left[i]*T[j].left[i]/g;longlongv1=l/T[last].left[i];longlongv2=l/T[j].left[i];REP(k,sz(S))T[j].left[k]=v1*T[last].left[k]-v2*T[j].left[k];REP(k,n)T[j].right[k]=v1*T[last].right[k]-v2*T[j].right[k];}}last++;if(last==n)break;}boolsw=false;REP(i,n){if(T[i].check()){sw=true;printf("yes\n");REP(j,n){printf("%s",a[j].c_str());longlongv=T[i].right[j];if(v<0)printf(" L %lld\n",-v);if(v>0)printf(" R %lld\n",v);if(v==0)printf(" N 0\n");}break;}}if(!sw)printf("no\n");}}
astein
소스코드 저장을 안해두니까 제가 다 짜서 올려야 하는군요 -_-;;;
A번 소스 코드.
[spoiler="더 보기..."]
[/spoiler]
B번 소스 코드.
[spoiler="더 보기.."]
[/spoiler]
C번 소스 코드.
[spoiler="더 보기..."]
[/spoiler]
D번 소스 코드.
[spoiler="더 보기..."]
[/spoiler] a(n, 0);
E번 소스 코드.
[spoiler="더 보기..."]
[code]
#include
#include
using namespace std;
int main() {
int n;
while (scanf("%d", &n) == 1) {
if (n == 0) break;
vector
for (int i = 0; i < n; i++) {
int v;
scanf("%d", &v);
for (int j = 0; j < n; j++) {
if (a[j] == 0) {
if (v == 0) {
a[j] = i + 1;
break;
}
v--;
}
}
}
for (int i = 0; i < n - 1; i++)
printf("%d,", a[i]);
printf("%d\n", a[n - 1]);
}
}
[/code]
[/spoiler]
F번 소스 코드.
[spoiler="더 보기..."]
[/spoiler]
G번 소스 코드.
[spoiler="더 보기..."]
[/spoiler]
H번 소스 코드.
[spoiler="더 보기..."]
[/spoiler]
I번 소스 코드.
[spoiler="더 보기..."]
[/spoiler]
17년 전