3.2.1
URL DjangoRuby on Rails (web frameworks) HTTP URL URL URL
URL URL URL URL
URL / - _ ./person/123/ URL /person/123? ? /case/ /CAse/ URL
URL URL 3
<str>abcde0123
<int>01234
<path>abcd/0123/
3 <str> <int> <path> URL
n mURL URL
2 n+1 URL i+1 pi ri pi 琛ㄧず URL ri URL
n+2 n+m+1 URL n+1+i qi URL
m i qi pj rj 404
5 4
/articles/2003/ special_case_2003
/articles/<int>/ year_archive
/articles/<int>/<int>/ month_archive
/articles/<int>/<int>/<str>/ article_detail
/static/<path> static_serve
/articles/2004/
/articles/1985/09/aloha/
/articles/hello/
/static/js/jquery.js
article_detail 1985 9 aloha
404
static_serve js/jquery.js
#include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; struct all { char s[110]; }a[110],b[110]; int ku(char *a,char *b) { int c[110],d[110],fl=0,flap=0,fs=0,fn,fk=0; int numa=0,numb=0,i,j,la,lb; for(i=1;;i++) { if(a[i]=='\0') break; } la=i-1; for(i=1;;i++) { if(b[i]=='\0') break; } lb=i-1; for(i=1;i<=la;i++) { if(a[i]=='/') { numa++; c[numa]=i; } } for(i=1;i<=lb;i++) { if(b[i]=='/') { numb++; d[numb]=i; } } c[0]=d[0]=0; c[numa+1]=la; d[numb+1]=lb; for(i=1;i<=lb-6;i++) { flap=0; if(a[i]=='/'&&a[i+1]=='<'&&a[i+2]=='p'&&a[i+3]=='a'&&a[i+4]=='t'&&a[i+5]=='h'&&a[i+6]=='>') { fs=1; flap=1; break; } } if(flap==1) { for(j=1;j<=i-1;j++) if(a[j]!=b[j]) { fl=1; break; } } else { if(numa!=numb) { fl=1; } else { if(a[c[numa-1]+1]!='<') { for(i=c[numa-1]+1,j=d[numb-1]+1;i<=c[numa]-1;j++,i++) { if(a[i]!=b[j]) { fl=1; break; } if(i==c[numa]-1) { for(i=c[numa]+2;i<=la;i++) { if(a[i-1]=='<'&&a[i]=='p'&&a[i+1]=='a'&&a[i+2]=='t'&&a[i+3]=='h'&&a[i+4]=='>') { i=i+5; continue; } cout << a[i]; } cout << endl; fk=1; } } } for(i=1;i<=numa;i++) { if(fl==1) break; if(a[c[i-1]+1]=='<'&&a[c[i-1]+2]=='i'&&a[c[i-1]+3]=='n'&&a[c[i-1]+4]=='t'&&a[c[i-1]+5]=='>') { fn=1; for(j=d[i-1]+1;j<=d[i]-1;j++) { if(b[j]=='0'&&fn==1) b[j]='?'; else fn=0; if ((b[j]>='0'&&b[j]<='9')||b[j]=='?') continue; else { fl=1; break; } } } } } } if(fl==0&&fk==0) { for(i=c[numa]+2;i<=la;i++) { if(a[i-1]=='<'&&a[i]=='p'&&a[i+1]=='a'&&a[i+2]=='t'&&a[i+3]=='h'&&a[i+4]=='>') { i=i+5; continue; } cout << a[i]; } cout << " "; int fm=0; for(i=d[2]+1;i<=lb-1;i++) { if(b[i]=='/'&&fs!=1) cout << " "; if(b[i]!='/'||fs==1) if(b[i]!='?') { fm=1; cout << b[i]; } } if(b[i]!='/') cout << b[i]; if(fm==0) cout << "0"; cout << endl; } return fl; } int main() { int m,n,i,j,k,fl; cin >> n >> m; scanf("%c"); for(i=1;i<=n;i++) { for(j=1;;j++) { scanf("%c",&a[i].s[j]); if(a[i].s[j]=='\n') { a[i].s[j]='\0'; break; } } } for(i=1;i<=m;i++) { for(j=1;;j++) { scanf("%c",&b[i].s[j]); if(b[i].s[j]=='\n') { b[i].s[j]='\0'; break; } } fl=0; for(j=1;j<=n;j++) { if(ku(a[j].s,b[i].s)==0) { fl=1; break; } } if(fl==0) cout << "404" << endl; } return 0; }
1 /articles/2004/ 1 2 2004
2 /articles/1985/09/aloha/ 4 19859 aloha
3 /articles/hello/
4 /static/js/jquery.js js/jquery.js
100
strintpathspecialcasepath//<>