80 条题解
-
0zone LV 10 @ 2016-08-03 10:59:57
#include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> #include <vector> #include <queue> #include <sstream> #include <bitset> using namespace std; typedef long long lg; #define min(a,b) (a>b?b:a) #define max(a,b) (a>b?a:b) int tot=0; struct data{ int v; string b; }a[1001]; string s,ss; int in; bool comp(const data a,const data b) { return a.v<b.v; } int main() { ios::sync_with_stdio(0); getline(cin,s); stringstream in(s); while(in>>a[++tot].v); tot=0; getline(cin,s); stringstream ss(s); while(ss>>a[++tot].b); sort(a+1,a+tot,comp); for(int i=1;i<tot;i++) cout<<a[i].b<<endl; return 0; }
-
02016-07-22 20:22:28@
stringstream秒杀。。。
c++
#include<iostream>
#include<sstream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1000 + 5;
struct Letter{
int x; string s;
bool operator < (const Letter& rhs) const {
return x < rhs.x;
}
}letter[maxn];
int n = 1; string str;
int main(){
freopen("in.txt","r",stdin);
getline (cin, str);
stringstream ss(str);
while(ss >> letter[n++].x); n--;n--;
for(int i = 1; i <= n; i++) cin >> letter[i].s;
sort(letter + 1, letter + n + 1);
for(int i = 1; i <= n; i++) cout << letter[i].s << endl;
return 0;
}
-
02016-05-05 19:49:08@
字符串后有‘\0’,共257位。。
-
02016-05-05 19:45:44@
Vj数据太迷了~
说好的255有效数字..加上小数点...
我定义256就不行...500就AC
#include<stdio.h>
#include<string.h>
int c[1005]={0};
char line[100005];
char buck[1005][256];
int main()
{
int point,len,re=1,i,j,n=2,count=1;
gets(line);
len=strlen(line);
for(i=0;i<len;i++)
if(line[i]==' ') count++;
point=count;
for(i=len-1;i>=0;i--)
{
if(line[i]<58&&line[i]>=48)
{
re=1;
while(line[i]!=' ')
{
c[point]=c[point]+re*(line[i]-48);
re=re*10;
if(i>0) i--;
else break;
}
point--;
}
}
for(j=1;j<=count;j++)
{
scanf("%s",buck[c[j]]);
}
for(j=1;j<=count;j++)
if(buck[j]!=0)
printf("%s\n",buck[j]);
return 0;
} -
02016-03-24 21:03:16@
不得不说Collections大法好【其实c++ stl也可以吧
```java
import java.util.*;public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
TreeMap<Integer, String> map = new TreeMap<Integer, String>();
String line1[] = scanner.nextLine().split(" ");
String line2[] = scanner.nextLine().split(" ");
for (int x = 0; x != line1.length; x++) {
map.put(Integer.parseInt(line1[x]), line2[x]);
}
for (Map.Entry<Integer, String> x : map.entrySet()) {
System.out.println(x.getValue());
}
scanner.close();
}
}
``` -
02016-02-20 16:03:46@
/* *********************************************** Author :guanjun Created Time :2016/2/20 15:35:59 File Name :vijosp1389.cpp ************************************************ */ #include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <iomanip> #include <list> #include <deque> #include <stack> #include <sstream> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 0x3f3f3f3f #define maxn 10000+10 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; priority_queue<int,vector<int>,greater<int> >pq; struct Node{ int x,y; }; struct cmp{ bool operator()(Node a,Node b){ if(a.x==b.x) return a.y> b.y; return a.x>b.x; } }; struct node{ int id; string s; }nod[maxn]; bool cmp(node a,node b){ return a.id<b.id; } int a[maxn]; int main() { #ifndef ONLINE_JUDGE //freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); int n=0; string s; stringstream ss; getline(cin,s); ss<<s; while(ss>>a[++n]); n--; for(int i=1;i<=n;i++){ nod[i].id=a[i]; cin>>nod[i].s; } sort(nod+1,nod+1+n,cmp); for(int i=1;i<=n;i++){ cout<<nod[i].s<<endl; } return 0; }
-
02016-02-13 10:40:21@
居然都要用ansistring
Pascal AC
var a:array[1..1000]of longint;
s:array[1..1000]of ansistring;
c:char; x:string;
t,i,j,k:longint;
begin
while not eoln do
begin
inc(t);
read(a[t]);
end;
readln;
t:=1;
while not eoln do
begin
read(c);
if c<>' ' then
s[t]:=s[t]+c
else inc(t);
end;
for i:=1 to t-1 do
for j:=i+1 to t do
if a[i]>a[j] then
begin
k:=a[i];
a[i]:=a[j];
a[j]:=k;
x:=s[i];
s[i]:=s[j];
s[j]:=x;
end;
for i:=1 to t do
writeln(s[i]);
end. -
02015-10-01 22:07:23@
写个C++版的
表示用STL真是神简单
不要喷那一堆include
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <list>
#include <deque>
#include <vector>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <ctime>
#include <stack>
#include <queue>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <functional>
#include <algorithm>
using namespace std;
int main()
{
int n = 0;
string rq;
getline(cin, rq);
string req;
getline(cin, req);
stringstream ss;
stringstream ss2(req);
ss << rq;
typedef pair<int, string> message;
priority_queue <message,vector<message> ,greater<message> > q;
int t;
while (ss >> t)
{
string b;
ss2 >> b;
q.push(make_pair(t, b));
}
while (!q.empty())
{
string o = q.top().second;
cout << o << endl;
q.pop();
}
return 0;
} -
02015-08-21 00:49:46@
用String零分,用Ainsistring就AC了。。。。
-
02015-07-10 17:27:23@
var
a:array[1..1000]of longint;
b:array[1..1000]of ansistring;
s,t1:ansistring;
i,n,t2,j:longint;
begin
while not eoln do
begin
inc(n);
read(a[n]);
end;
readln;
readln(s);
for i:=1 to n-1 do
begin
b[i]:=copy(s,1,pos(' ',s)-1);
delete(s,1,pos(' ',s));
end;
b[n]:=s;
for i:=1 to n-1 do
for j:=1 to n-i do
if a[j]>a[j+1] then
begin
t2:=a[j];a[j]:=a[j+1];a[j+1]:=t2;
t1:=b[j];b[j]:=b[j+1];b[j+1]:=t1;
end;
for i:=1 to n do writeln(b[i]);
end. -
02014-10-04 19:27:19@
var
a,c:array[1..1000]of longint;
b:array[1..1000]of ansistring;
s:ansistring;
i,n:longint;
begin
while not eoln do begin inc(n);read(a[n]);end;readln;
readln(s);
for i:=1 to n-1 do begin
b[i]:=copy(s,1,pos(' ',s)-1);delete(s,1,pos(' ',s));end;b[n]:=s;
for i:=1 to n do c[a[i]]:=i;
for i:=1 to n do writeln(b[c[i]]);
end.
I SMILED. -
02013-11-08 09:37:51@
var
s:ansistring;
n,p,i,j,t:longint;
t2:string;
a:array[0..1000] of longint;
b:array[0..1000] of ansistring;
beginreadln(s);
n:=0;
p:=pos(' ',s);
while p>0 do
begin
inc(n);
val(copy(s,1,p-1),a[n]);
delete(s,1,p);
p:=pos(' ',s);
end;
inc(n);
val(s,a[n]);
readln(s);
n:=0;
p:=pos(' ',s);
while p>0 do
begin
inc(n);
b[n]:=copy(s,1,p-1);
delete(s,1,p);
p:=pos(' ',s);
end;
inc(n);
b[n]:=s;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[j]<a[i] then
begin
t:=a[i];a[i]:=a[j];a[j]:=t;
t2:=b[i];b[i]:=b[j];b[j]:=t2;
end;
for i:=1 to n do
writeln(b[i]);
end.
来写题解了!
开个字符串来记录浮点数。
“不超过255位的浮点数,序号与序号间、特征码与特征码间有一个空格,两行均没有多余的空格。”
看到这些,你想到了什么?
没错,字符串!
第一次我还WA了!
后来,我把b数组的string改成了ansistring,就过了。
看来,数据还是有些问题。 -
02010-03-12 20:46:46@
我真不知道这道题用排序的人是怎么想的,根本不用排序。
首先读入的时候
while not eoln do
begin
read(k);
n:=n+1;
num[n]:=k;
end;
开一个num数组记录序号出现顺序,以便后面读入字符串时对上位。
然后。。。
k:=1;
while not eof do
begin
read(x);
if x=' ' then k:=k+1 else
a[num[k]]:=a[num[k]]+x;
end
这样读完后,a数组中存的字符串已经按照a的下标升序排列了。
最后
for i:=1 to n do
writeln(a[i]);
即可。。 -
02009-10-29 20:53:49@
ansistring!!!!!!
-
02009-10-18 14:28:47@
kao
用了string全错
改成ansistring全对
成心整我
第100题 -
02009-10-14 21:47:43@
又找到了這么一道水題!難得的一次A
沒有要注意的東西,覺得沒必要用快排,其實桶排也可以,還簡單一點。
PS:要用ansistring!
哈哈,慶祝本人100道!
-
02009-10-08 15:01:01@
奇怪的vijos...
交上去提示 No Compiled...
然后,点开,显示:
编译失败...|错误号:-1
---|---|---|---|---|---|---|---|-
Unaccepted 有效得分:0 有效耗时:0ms然后,看左上角:
Flag Accepted
奇怪为什么会编译失败...
vijos:NoCompiled.-->NC...
果然NC了... -
02009-09-13 17:12:20@
大家要记住......VJ的数据永远都是很扯得.......
要用Ansistring...........
String是0分的........ -
02009-09-03 22:19:58@
感谢wzc1995……
-
02009-08-28 21:39:18@
var
b:array[1..1000] of ansistring;
c:array[1..1000] of integer;
v:char;
i,m,n:longint;
begin
repeat
read(m);
n:=n+1;
c[n]:=m;
until eoln;
readln;
m:=n;n:=1;
repeat
read(v);
if v' ' then b[c[n]]:=b[c[n]]+v
else
n:=n+1;
until eoln;
for i:=1 to m do writeln(b[i]);
end.ansistring魔力无边
0-AC的究极变化
晕